Просмотр исходного кода

com.simple -> com.iformall

release_toaliyun_real
Stormeye.Wu 7 лет назад
Родитель
Сommit
7bbeca4c5a
100 измененных файлов: 8512 добавлений и 264 удалений
  1. +2
    -2
      mallinkAdmin/pom.xml
  2. +24
    -0
      mallinkAdmin/src/main/java/com/iformall/UserApplication.java
  3. +52
    -0
      mallinkAdmin/src/main/java/com/iformall/config/AwsProperty.java
  4. +22
    -0
      mallinkAdmin/src/main/java/com/iformall/config/CorsConfig.java
  5. +32
    -0
      mallinkAdmin/src/main/java/com/iformall/config/KaptchaConfig.java
  6. +24
    -0
      mallinkAdmin/src/main/java/com/iformall/config/PayProperty.java
  7. +50
    -0
      mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java
  8. +58
    -0
      mallinkAdmin/src/main/java/com/iformall/config/RestFilter.java
  9. +24
    -0
      mallinkAdmin/src/main/java/com/iformall/config/RestTemplateConfig.java
  10. +288
    -0
      mallinkAdmin/src/main/java/com/iformall/config/ShiroConfig.java
  11. +31
    -0
      mallinkAdmin/src/main/java/com/iformall/config/ShiroLoginFilter.java
  12. +34
    -0
      mallinkAdmin/src/main/java/com/iformall/config/WebConfig.java
  13. +47
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/BaseController.java
  14. +98
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/CouponInjectController.java
  15. +56
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/DataTowerController.java
  16. +135
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/HomeController.java
  17. +64
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/MallPermissionController.java
  18. +121
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/MallRoleController.java
  19. +236
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/MallUserInfoController.java
  20. +65
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/MarkingDataReportController.java
  21. +59
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java
  22. +190
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/UploadController.java
  23. +77
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxAdminLogController.java
  24. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxAppinfoController.java
  25. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxBLogController.java
  26. +66
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxBillRentController.java
  27. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxBusinessController.java
  28. +70
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCLogController.java
  29. +213
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java
  30. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserCarController.java
  31. +70
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserController.java
  32. +302
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserDataController.java
  33. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserTagsController.java
  34. +137
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCampaignController.java
  35. +352
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCarCallBackController.java
  36. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCarCmdLogController.java
  37. +326
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java
  38. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxChannelController.java
  39. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponActionLogController.java
  40. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponCarController.java
  41. +120
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponChannelController.java
  42. +170
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java
  43. +107
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponOrderController.java
  44. +102
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponSendController.java
  45. +90
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponSpreadController.java
  46. +69
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponTypeController.java
  47. +61
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxGroupController.java
  48. +91
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxLevelConfigController.java
  49. +74
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMallApplyController.java
  50. +81
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMallBuildingController.java
  51. +116
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMallConfigController.java
  52. +70
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMallController.java
  53. +77
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMallFloorController.java
  54. +75
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantBUserController.java
  55. +103
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantController.java
  56. +80
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantShopController.java
  57. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantTradeDailyController.java
  58. +97
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMsgCallbackController.java
  59. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMsgConfigController.java
  60. +99
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMsgController.java
  61. +74
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMsgModelController.java
  62. +74
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMsgSignatureController.java
  63. +95
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java
  64. +61
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxMsgValidationcodeModelController.java
  65. +74
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxOrderController.java
  66. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxParkController.java
  67. +70
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxPayAccountController.java
  68. +183
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxPayController.java
  69. +78
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxPayOrderController.java
  70. +85
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxProfitSharingReceiverController.java
  71. +70
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxRefundOrderController.java
  72. +62
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxRentContractController.java
  73. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxScoreHistoryController.java
  74. +70
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxScoreRulesController.java
  75. +67
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxScoreValidityPeriodController.java
  76. +98
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java
  77. +164
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxTagsController.java
  78. +66
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxUserChannelController.java
  79. +39
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxUserCouponController.java
  80. +309
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java
  81. +39
    -0
      mallinkAdmin/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java
  82. +69
    -0
      mallinkAdmin/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java
  83. +141
    -0
      mallinkAdmin/src/main/java/com/iformall/schedule/DaliyAmountSchedule.java
  84. +110
    -0
      mallinkAdmin/src/main/java/com/iformall/schedule/MsgSendingSchedule.java
  85. +62
    -0
      mallinkAdmin/src/main/java/com/iformall/schedule/OrderExpiringSchedule.java
  86. +21
    -0
      mallinkAdmin/src/main/java/com/iformall/schedule/SchedulingConfig.java
  87. +132
    -0
      mallinkAdmin/src/main/java/com/iformall/schedule/WxAppVisitSchedule.java
  88. +85
    -0
      mallinkAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java
  89. +33
    -0
      mallinkAdmin/src/main/java/com/iformall/shiro/PasswordHelper.java
  90. +127
    -0
      mallinkAdmin/src/main/java/com/iformall/shiro/ShiroService.java
  91. +9
    -0
      mallinkAdmin/src/main/java/com/iformall/shiro/UserSession.java
  92. +6
    -0
      mallinkAdmin/src/main/java/com/iformall/utils/Constant.java
  93. +61
    -0
      mallinkAdmin/src/main/java/com/iformall/utils/ShiroUtils.java
  94. +0
    -24
      mallinkAdmin/src/main/java/com/simple/UserApplication.java
  95. +0
    -52
      mallinkAdmin/src/main/java/com/simple/config/AwsProperty.java
  96. +0
    -22
      mallinkAdmin/src/main/java/com/simple/config/CorsConfig.java
  97. +0
    -32
      mallinkAdmin/src/main/java/com/simple/config/KaptchaConfig.java
  98. +0
    -24
      mallinkAdmin/src/main/java/com/simple/config/PayProperty.java
  99. +0
    -50
      mallinkAdmin/src/main/java/com/simple/config/RedisConfig.java
  100. +0
    -58
      mallinkAdmin/src/main/java/com/simple/config/RestFilter.java

+ 2
- 2
mallinkAdmin/pom.xml Просмотреть файл

@@ -6,7 +6,7 @@

<parent>
<artifactId>mallink</artifactId>
<groupId>com.simple</groupId>
<groupId>com.iformall</groupId>
<version>1.0</version>
</parent>

@@ -14,7 +14,7 @@

<dependencies>
<dependency>
<groupId>com.simple</groupId>
<groupId>com.iformall</groupId>
<artifactId>mallinkService</artifactId>
<version>1.0</version>
</dependency>


+ 24
- 0
mallinkAdmin/src/main/java/com/iformall/UserApplication.java Просмотреть файл

@@ -0,0 +1,24 @@
package com.iformall;

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* @author chenkx
* @date 2017-12-26
*/
@SpringBootApplication
@MapperScan(basePackages = {"com.iformall.mapper"})
@EnableSwagger2
@EnableEncryptableProperties

public class UserApplication {

public static void main(String[] args) {
SpringApplication.run(UserApplication.class, args);
}
}

+ 52
- 0
mallinkAdmin/src/main/java/com/iformall/config/AwsProperty.java Просмотреть файл

@@ -0,0 +1,52 @@
package com.iformall.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* @author Stormeye
*/
@Component
@ConfigurationProperties(prefix = "aws")
public class AwsProperty {
// AWS ACCESS KEY
private String access;

private String secret;

private String clientRegion;

private String bucketName;

public String getAccess() {
return access;
}

public void setAccess(String access) {
this.access = access;
}

public String getSecret() {
return secret;
}

public void setSecret(String secret) {
this.secret = secret;
}

public String getClientRegion() {
return clientRegion;
}

public void setClientRegion(String clientRegion) {
this.clientRegion = clientRegion;
}

public String getBucketName() {
return bucketName;
}

public void setBucketName(String bucketName) {
this.bucketName = bucketName;
}
}

+ 22
- 0
mallinkAdmin/src/main/java/com/iformall/config/CorsConfig.java Просмотреть файл

@@ -0,0 +1,22 @@
package com.iformall.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
* Created by Administrator on 2017/8/9.
*/
@Configuration
public class CorsConfig extends WebMvcConfigurerAdapter {

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowCredentials(true)
.allowedMethods("GET", "POST", "DELETE", "PUT")
.maxAge(3600);
}

}

+ 32
- 0
mallinkAdmin/src/main/java/com/iformall/config/KaptchaConfig.java Просмотреть файл

@@ -0,0 +1,32 @@
package com.iformall.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;


/**
* 生成验证码配置
*
* @author stormeye.wu
* @email wugq@mippoint.com
* @date 2017-04-20 19:22
*/
@Configuration
public class KaptchaConfig {

@Bean
public DefaultKaptcha producer() {
Properties properties = new Properties();
properties.put("kaptcha.border", "no");
properties.put("kaptcha.textproducer.font.color", "black");
properties.put("kaptcha.textproducer.char.space", "5");
Config config = new Config(properties);
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}

+ 24
- 0
mallinkAdmin/src/main/java/com/iformall/config/PayProperty.java Просмотреть файл

@@ -0,0 +1,24 @@
package com.iformall.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* @author Stormeye
*/
@Component
@ConfigurationProperties(prefix = "pay")
public class PayProperty {
/**
* 真实支付
*/
private boolean real;

public boolean isReal() {
return real;
}

public void setReal(boolean real) {
this.real = real;
}
}

+ 50
- 0
mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java Просмотреть файл

@@ -0,0 +1,50 @@
package com.iformall.config;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
* Created by yangqj on 2017/4/30.
*/
@Configuration
@EnableCaching
public class RedisConfig extends CachingConfigurerSupport {
@Value("${spring.redis.host}")
private String host;

@Value("${spring.redis.port}")
private int port;

@Value("${spring.redis.timeout}")
private int timeout;

@Value("${spring.redis.pool.max-idle}")
private int maxIdle;

@Value("${spring.redis.pool.max-wait}")
private long maxWaitMillis;
@Value("${spring.redis.password}")
private String password;

@Bean
public JedisPool redisPoolFactory() {
Logger.getLogger(getClass()).info("JedisPool注入成功!!");
Logger.getLogger(getClass()).info("redis地址:" + host + ":" + port);
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxIdle(maxIdle);
jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);

JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout,password);

return jedisPool;
}


}

+ 58
- 0
mallinkAdmin/src/main/java/com/iformall/config/RestFilter.java Просмотреть файл

@@ -0,0 +1,58 @@
package com.iformall.config;

import java.io.IOException;
import java.util.Optional;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 前后端分离RESTful接口过滤器
*
* @author xuguoqin
*
*/
public class RestFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = null;
if (request instanceof HttpServletRequest) {
req = (HttpServletRequest) request;
}
HttpServletResponse res = null;
if (response instanceof HttpServletResponse) {
res = (HttpServletResponse) response;
}
if (req != null && res != null) {
//设置允许传递的参数
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
//设置允许带上cookie
res.setHeader("Access-Control-Allow-Credentials", "true");
String origin = Optional.ofNullable(req.getHeader("Origin")).orElse(req.getHeader("Referer"));
//设置允许的请求来源
res.setHeader("Access-Control-Allow-Origin", origin);
//设置允许的请求方法
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS");
}
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}

+ 24
- 0
mallinkAdmin/src/main/java/com/iformall/config/RestTemplateConfig.java Просмотреть файл

@@ -0,0 +1,24 @@
package com.iformall.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
return new RestTemplate(factory);
}
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setReadTimeout(5000);//ms
factory.setConnectTimeout(10000);//ms
return factory;
}
}

+ 288
- 0
mallinkAdmin/src/main/java/com/iformall/config/ShiroConfig.java Просмотреть файл

@@ -0,0 +1,288 @@
package com.iformall.config;

import com.iformall.service.MallPermissionService;
import com.iformall.shiro.MyShiroRealm;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.servlet.SimpleCookie;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.crazycake.shiro.RedisCacheManager;
import org.crazycake.shiro.RedisManager;
import org.crazycake.shiro.RedisSessionDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.util.LinkedHashMap;
import java.util.Map;


/**
* Created by yangqj on 2017/4/23.
*/
@Configuration
public class ShiroConfig {
@Autowired(required = false)
private MallPermissionService resourcesService;

@Value("${spring.redis.host}")
private String host;

@Value("${spring.redis.port}")
private int port;

@Value("${spring.redis.timeout}")
private int timeout;
@Value("${spring.redis.expire}")
private int expire;
@Value("${spring.redis.password}")
private String password;

@Bean
public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
return new LifecycleBeanPostProcessor();
}

/**
* ShiroDialect,为了在thymeleaf里使用shiro的标签的bean
* @return
*/
// @Bean
// public ShiroDialect shiroDialect() {
// return new ShiroDialect();
// }
/**
* ShiroFilterFactoryBean 处理拦截资源文件问题。
* 注意:单独一个ShiroFilterFactoryBean配置是或报错的,因为在
* 初始化ShiroFilterFactoryBean的时候需要注入:SecurityManager
*
Filter Chain定义说明
1、一个URL可以配置多个Filter,使用逗号分隔
2、当设置多个过滤器时,全部验证通过,才视为通过
3、部分过滤器可指定参数,如perms,roles
*
*/
@Bean
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager){
System.out.println("ShiroConfiguration.shirFilter()");
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
// 必须设置 SecurityManager
shiroFilterFactoryBean.setSecurityManager(securityManager);
Map<String, Filter> filters = new LinkedHashMap<String, Filter>();
filters.put("token", new ShiroLoginFilter());
filters.put("corsFilter", new RestFilter());
shiroFilterFactoryBean.setFilters(filters);
// 如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面
// shiroFilterFactoryBean.setLoginUrl("/login");
// 登录成功后要跳转的链接
shiroFilterFactoryBean.setSuccessUrl("/usersPage");
//未授权界面;
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
//拦截器.
Map<String,String> filterChainDefinitionMap = new LinkedHashMap<String,String>();

//配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了
filterChainDefinitionMap.put("/logout", "anon");
filterChainDefinitionMap.put("/doLogin/**","anon");
filterChainDefinitionMap.put("/css/**","anon");
filterChainDefinitionMap.put("/js/**","anon");
filterChainDefinitionMap.put("/img/**","anon");
filterChainDefinitionMap.put("/font-awesome/**","anon");
//<!-- 过滤链定义,从上向下顺序执行,一般将 /**放在最为下边 -->:这是一个坑呢,一不小心代码就不好使了;
//<!-- authc:所有url都必须认证通过才可以访问; anon:所有url都都可以匿名访问-->
//自定义加载权限资源关系
// Map<String,Object> map = new HashMap<>();
// List<SysPermission> resourcesList = resourcesService.list(map);
// for(SysPermission resources:resourcesList){
//
// if (StringUtil.isNotEmpty(resources.getUrl())) {
// String permission = "perms[" + resources.getUrl()+ "]";
// filterChainDefinitionMap.put(resources.getUrl(),permission);
// }
// }
filterChainDefinitionMap.put("/swagger-ui.html","anon");
filterChainDefinitionMap.put("/wxPay/notify/**", "anon");
filterChainDefinitionMap.put("/v2/**","anon");
filterChainDefinitionMap.put("/swagger-resources/**","anon");
filterChainDefinitionMap.put("/webjars/**","anon");
filterChainDefinitionMap.put("/wxMsgCallback/**","anon");
filterChainDefinitionMap.put("/carCallback/**","anon");
filterChainDefinitionMap.put("/wxMallApply/add","anon");
filterChainDefinitionMap.put("/wxMallApply/sendvalidationcode","anon");
filterChainDefinitionMap.put("/captcha.jpg", "anon");
filterChainDefinitionMap.put("/version", "anon");
// filterChainDefinitionMap.put("/role/**", "corsFilter,token");
filterChainDefinitionMap.put("/**", "corsFilter,token,authc");
// filterChainDefinitionMap.put("/**", "anon");



shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}




public static boolean isAjax(ServletRequest request){
String header = ((HttpServletRequest) request).getHeader("X-Requested-With");
if("XMLHttpRequest".equalsIgnoreCase(header)){
System.out.println( "当前请求为Ajax请求");
return Boolean.TRUE;
}
System.out.println( "当前请求非Ajax请求");
return Boolean.FALSE;
}

@Bean
public SecurityManager securityManager(){
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//设置realm.
securityManager.setRealm(myShiroRealm());
// 自定义缓存实现 使用redis
//securityManager.setCacheManager(cacheManager());
// 自定义session管理 使用redis
securityManager.setSessionManager(sessionManager());
return securityManager;
}

@Bean
public MyShiroRealm myShiroRealm(){
MyShiroRealm myShiroRealm = new MyShiroRealm();
myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher());
return myShiroRealm;
}

/**
* 凭证匹配器
* (由于我们的密码校验交给Shiro的SimpleAuthenticationInfo进行处理了
* 所以我们需要修改下doGetAuthenticationInfo中的代码;
* )
* @return
*/
@Bean
public HashedCredentialsMatcher hashedCredentialsMatcher(){
HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher();

hashedCredentialsMatcher.setHashAlgorithmName("md5");//散列算法:这里使用MD5算法;
hashedCredentialsMatcher.setHashIterations(2);//散列的次数,比如散列两次,相当于 md5(md5(""));

return hashedCredentialsMatcher;
}


/**
* 开启shiro aop注解支持.
* 使用代理方式;所以需要开启代码支持;
* @param securityManager
* @return
*/
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager){
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
return authorizationAttributeSourceAdvisor;
}

/**
* 配置shiro redisManager
* 使用的是shiro-redis开源插件
* @return
*/
public RedisManager redisManager() {
RedisManager redisManager = new RedisManager();
redisManager.setHost(host);
redisManager.setPort(port);
redisManager.setExpire(expire);// 配置缓存过期时间
redisManager.setTimeout(timeout);
redisManager.setPassword(password);
return redisManager;
}

/**
* cacheManager 缓存 redis实现
* 使用的是shiro-redis开源插件
* @return
*/
public RedisCacheManager cacheManager() {
RedisCacheManager redisCacheManager = new RedisCacheManager();
redisCacheManager.setRedisManager(redisManager());
return redisCacheManager;
}


/**
* RedisSessionDAO shiro sessionDao层的实现 通过redis
* 使用的是shiro-redis开源插件
*/
@Bean
public RedisSessionDAO redisSessionDAO() {
RedisSessionDAO redisSessionDAO = new RedisSessionDAO();
redisSessionDAO.setRedisManager(redisManager());
return redisSessionDAO;
}

/**
* shiro session的管理
*/
@Bean
public DefaultWebSessionManager sessionManager() {
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionManager.setSessionDAO(redisSessionDAO());
sessionManager.setSessionIdCookie(simpleCookie());
return sessionManager;
}
@Bean
public SimpleCookie simpleCookie() {
SimpleCookie simpleCookie = new SimpleCookie("SSIDS");
simpleCookie.setDomain("");
return simpleCookie;
}
// @Bean
// public SimpleCookie rememberMeCookie(){
// //System.out.println("ShiroConfiguration.rememberMeCookie()");
// //这个参数是cookie的名称,对应前端的checkbox的name = rememberMe
// SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
// //<!-- 记住我cookie生效时间30天 ,单位秒;-->
// simpleCookie.setMaxAge(60*30);
// return simpleCookie;
// }
// @Bean
// public CookieRememberMeManager rememberMeManager(){
// //System.out.println("ShiroConfiguration.rememberMeManager()");
// CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
// cookieRememberMeManager.setCookie(rememberMeCookie());
// //rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位)
// cookieRememberMeManager.setCipherKey(Base64.decodeBytes("2AvVhdsgUs0FSA3SDFAdag=="));
// return cookieRememberMeManager;
// }
// @Bean(name = "securityManager")
// public DefaultWebSecurityManager defaultWebSecurityManager(MyShiroRealm realm){
// DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
// //设置realm
// securityManager.setRealm(realm);
// //用户授权/认证信息Cache, 采用EhCache缓存
// securityManager.setCacheManager(cacheManager());
// //注入记住我管理器
// securityManager.setRememberMeManager(rememberMeManager());
// return securityManager;
// }

}

+ 31
- 0
mallinkAdmin/src/main/java/com/iformall/config/ShiroLoginFilter.java Просмотреть файл

@@ -0,0 +1,31 @@
package com.iformall.config;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;

import com.alibaba.fastjson.JSON;
import com.iformall.common.ResultData;
public class ShiroLoginFilter extends FormAuthenticationFilter {

@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
ResultData resultData = new ResultData(ResultData.UNLOGIN,"用户未登录");
response.getWriter().write(JSON.toJSONString(resultData));
return false;
}
/**
* 判断ajax请求
* @param request
* @return
*/
boolean isAjax(HttpServletRequest request){
return (request.getHeader("X-Requested-With") != null && "XMLHttpRequest".equals( request.getHeader("X-Requested-With").toString()) ) ;
}
}

+ 34
- 0
mallinkAdmin/src/main/java/com/iformall/config/WebConfig.java Просмотреть файл

@@ -0,0 +1,34 @@
package com.iformall.config;

import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.math.BigInteger;
import java.util.List;

@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {


@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter fastConverter =
new FastJsonHttpMessageConverter();

FastJsonConfig fastJsonConfig = new FastJsonConfig();
SerializeConfig serializeConfig = SerializeConfig.globalInstance;
serializeConfig.put(BigInteger.class, ToStringSerializer.instance);
serializeConfig.put(Long.class, ToStringSerializer.instance);
serializeConfig.put(Long.TYPE, ToStringSerializer.instance);
fastJsonConfig.setSerializeConfig(serializeConfig);
fastConverter.setFastJsonConfig(fastJsonConfig);
converters.add(fastConverter);
}


}

+ 47
- 0
mallinkAdmin/src/main/java/com/iformall/controller/BaseController.java Просмотреть файл

@@ -0,0 +1,47 @@
package com.iformall.controller;

import java.beans.PropertyEditorSupport;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.iformall.domain.po.MallUserInfo;
import com.iformall.shiro.UserSession;
import org.apache.shiro.SecurityUtils;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BaseController {
@InitBinder
public void InitBinder(WebDataBinder dataBinder) {
dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
public void setAsText(String value) {
try {
setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
} catch(ParseException e) {
try {
setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value));
} catch (ParseException e1) {
setValue(null);
}
}
}

public String getAsText() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue());
}

});
}
public MallUserInfo getUser(){
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo);
return user;
}
public String getTenantId(){
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo);
return user.getTenantId();
}
}

+ 98
- 0
mallinkAdmin/src/main/java/com/iformall/controller/CouponInjectController.java Просмотреть файл

@@ -0,0 +1,98 @@
package com.iformall.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.CouponInject;
import com.iformall.enums.EnumCouponInjectSendType;
import com.iformall.service.CouponInjectService;
import com.iformall.service.WxCUserTagsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(description = "精准投放接口")
@RestController
@RequestMapping("couponInject")
public class CouponInjectController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private CouponInjectService couponInjectService;
@Autowired
private WxCUserTagsService wxCUserTagsService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute CouponInject couponInject, Integer pageNum, Integer pageSize) {
if (null == couponInject) couponInject = new CouponInject();
if (couponInject.getStatus() != null && couponInject.getStatus() == -1) {
couponInject.setStatus(null);
}
final PageInfo<CouponInject> page = couponInjectService.listAsPage(couponInject, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody CouponInject couponInject) {

couponInject.setTenantId(getUser().getTenantId());
couponInject.setMUserId(getUser().getId());
if (couponInject.getSendType() == EnumCouponInjectSendType.IMMEDIATE.getCode()) {
couponInject.setSendTime(new Date());
}
//Assert.notNull(couponInject.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
return couponInjectService.add(couponInject);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody CouponInject couponInject) {
String[] arys = couponInject.getTags().split(",");
List<Long> tagids = new ArrayList<>();
for (int i = 0; i < arys.length; i++) {
tagids.add(Long.parseLong(arys[i]));
}
couponInject.setTags(JSON.toJSONString(arys));
couponInjectService.saveOrUpdate(couponInject);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
couponInjectService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {

CouponInject couponInject = couponInjectService.getById(id);
if (couponInject != null) {
List<Long> tagids = JSON.parseArray(couponInject.getTags(), Long.class);
couponInject.setWxChooseTagVo(wxCUserTagsService.findChooseTag(tagids));
}
return new ResultData(Result.SUCCESS, "查询成功", couponInject);
}


}

+ 56
- 0
mallinkAdmin/src/main/java/com/iformall/controller/DataTowerController.java Просмотреть файл

@@ -0,0 +1,56 @@
package com.iformall.controller;

import com.iformall.common.ResultData;
import com.iformall.service.DataTowerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(description = "数据塔台")
@RestController
@RequestMapping("datatower")
public class DataTowerController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private DataTowerService dataTowerService;


@ApiOperation("查询运营")
@PostMapping("/queryRunning")
public ResultData queryRunning() {

Map<String, Object> data = dataTowerService.queryRunning(getTenantId());

return new ResultData(data);
}


@ApiOperation("查询车流")
@PostMapping("/queryCar")
public ResultData queryCar() {

Map<String, Object> data = dataTowerService.queryCar(getTenantId());

return new ResultData(data);
}

@ApiOperation("查询客流")
@PostMapping("/queryCustomer")
public ResultData queryCustomer() {

Map<String, Object> data = dataTowerService.queryCustomer(getTenantId());

return new ResultData(data);
}


}

+ 135
- 0
mallinkAdmin/src/main/java/com/iformall/controller/HomeController.java Просмотреть файл

@@ -0,0 +1,135 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.domain.po.MallRolePermission;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.MallUserRole;
import com.iformall.service.MallRolePermissionService;
import com.iformall.service.MallUserRoleService;
import com.iformall.shiro.UserSession;
import com.iformall.utils.ShiroUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.IOUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;


@RestController
@Api(description = "登录相关接口")
public class HomeController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Value("${version}")
private String version;

@Autowired
private Producer producer;

@Autowired
private MallUserRoleService mallUserRoleService;

@Autowired
private MallRolePermissionService mallRolePermissionService;

@GetMapping("/captcha.jpg")
public void captcha(HttpServletResponse response)throws ServletException, IOException {
response.setHeader("Cache-Control", "no-store, no-cache");
response.setContentType("image/jpeg");

//生成文字验证码
String text = producer.createText();
//生成图片验证码
BufferedImage image = producer.createImage(text);
//保存到shiro session
ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text);

ServletOutputStream out = response.getOutputStream();
ImageIO.write(image, "jpg", out);
IOUtils.closeQuietly(out);
}

@ApiOperation("登录")
@PostMapping("/doLogin")
public ResultData login(@RequestBody MallUserInfo user) {
String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY);
if(!user.getCaptcha().equalsIgnoreCase(kaptcha)){
return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL);
}

ResultData data = new ResultData();
if (StringUtils.isEmpty(user.getUsername()) || StringUtils.isEmpty(user.getPassword())) {
// throw new SystemException(ErrorCode.LOGIN_USER_OR_PWD_ERROR);
return new ResultData(ResultData.ERROR, "用户名或者密码错误");
}
try {
Subject subject = SecurityUtils.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword());
subject.login(token);
// List<MallRole> roleList = sysRoleService.findRoleByUserId(user.getId());
// if (null != roleList && roleList.size() > 0) {
// List<MallPermission> permissionList = sysPermissionService
// .findPermissionByRoleIds(roleList.stream().map(MallRole::getId).collect(Collectors.toList()));
// user.setRole(roleList);
// user.setPermission(permissionList);
// }
MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo);
info.setPassword("保密");
// System.out.println("id:"+ SecurityUtils.getSubject().getSession().getId());
MallUserRole ur = new MallUserRole();
ur.setUid(info.getId());
PageInfo<MallUserRole> page = mallUserRoleService.listAsPage(ur, 1, 1);
if (page.getSize() > 0) {
Long roleId = page.getList().get(0).getRoleId();
MallRolePermission p = new MallRolePermission();
p.setRoleId(roleId);
p.setTenantId(info.getTenantId());
PageInfo<MallRolePermission> listAsPage = mallRolePermissionService.listAsPage(p, 1, 100);
String menus = "";
for (MallRolePermission rp : listAsPage.getList()) {
menus += rp.getPermissionId() + ",";
}
if (menus.length() > 0) {
menus = menus.substring(0, menus.length() - 1);
}
info.setMenus(menus);
}
data.data = info;
} catch (Exception e) {
return new ResultData(ResultData.ERROR, "用户名或者密码错误");
}
return data;
}

@ApiOperation("登出")
@GetMapping("/logout")
public ResultData login() {
ResultData data = new ResultData();
SecurityUtils.getSubject().logout();
return data;
}

@ApiOperation("获取后端版本号")
@GetMapping("/version")
public ResultData version() {
return new ResultData(version);
}
}

+ 64
- 0
mallinkAdmin/src/main/java/com/iformall/controller/MallPermissionController.java Просмотреть файл

@@ -0,0 +1,64 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.MallPermission;
import com.iformall.service.MallPermissionService;
import org.apache.shiro.util.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @author chenkx
* @date 2018-01-05.
*/
@RestController
@RequestMapping("permission")
public class MallPermissionController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
MallPermissionService mallPermissionService;


@GetMapping("alllist")
public ResultData alllist(String ava) {
MallPermission record = new MallPermission();
record.setAvailable(ava);
PageInfo<MallPermission> permissions = mallPermissionService.listAsPage(record, 1, 10000);
return new ResultData(Result.SUCCESS, "查询成功", permissions.getList());
}

@PostMapping("add")
public ResultData createPermission(MallPermission mallPermission) {
Assert.notNull(mallPermission.getName(), "用户名不能为空");
mallPermissionService.saveOrUpdate(mallPermission);
return new ResultData(mallPermission.getId());
}

@PostMapping("update")
public ResultData updatePermission(MallPermission sysPermission) {
mallPermissionService.saveOrUpdate(sysPermission);
return new ResultData();
}

@GetMapping("/del")
public ResultData delete(Long id) {
mallPermissionService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("/findById")
public ResultData findById(Long id) {
mallPermissionService.getById(id);
return new ResultData(Result.SUCCESS, "成功", null);
}


}

+ 121
- 0
mallinkAdmin/src/main/java/com/iformall/controller/MallRoleController.java Просмотреть файл

@@ -0,0 +1,121 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.MallRole;
import com.iformall.domain.po.MallRolePermission;
import com.iformall.service.MallRolePermissionService;
import com.iformall.service.MallRoleService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;


@RestController
@RequestMapping("role")
@Api(description = "角色相关接口")
public class MallRoleController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private MallRoleService sysRoleService;

@Autowired
private MallRolePermissionService sysRolePermissionService;

@GetMapping("list")
public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) {
String tenantId = getTenantId();
sysRole.setTenantId(tenantId);
final PageInfo<MallRole> page = sysRoleService.listAsPage(sysRole, pageNum, pageSize);
for (MallRole r : page.getList()) {
MallRolePermission p = new MallRolePermission();
p.setRoleId(r.getId());
p.setTenantId(tenantId);
PageInfo<MallRolePermission> pers = sysRolePermissionService.listAsPage(p, 1, 1000);
String menus = "";
for (MallRolePermission rp : pers.getList()) {
menus += rp.getPermissionId() + ",";
}
if (menus.length() > 1) {
menus = menus.substring(0, menus.length() - 1);
}
r.setMenus(menus);
}
return new ResultData(page);
}


@PostMapping("saveOrUpdate")
public ResultData saveOrUpdate(@RequestBody MallRole sysRole) {
String tenantId = getTenantId();
int count = sysRoleService.countByName(sysRole.getName(), sysRole.getId());
if (count > 0) {
return new ResultData(ResultData.ERROR, "角色名已存在");
}
sysRole.setTenantId(tenantId);
sysRoleService.saveOrUpdate(sysRole);
// SysRolePermissionService.deleteById(id);
if (StringUtils.isNoneBlank(sysRole.getMenus())) {
List<Long> mIds = new ArrayList<>();
for (String mId : sysRole.getMenus().split(",")) {
mIds.add(Long.valueOf(mId));
}
sysRolePermissionService.savePermissions(tenantId, sysRole.getId(), mIds.toArray(new Long[]{}));
;
}
return new ResultData();
}


@PostMapping("add")
public ResultData add(MallRole sysRole) {
Assert.notNull(sysRole.getName(), "角色名不能为空");
Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
sysRoleService.saveOrUpdate(sysRole);
return new ResultData();
}

@PostMapping("update")
public ResultData update(MallRole sysRole) {
if (sysRole.getName() != null) {
System.out.println(checkUnique(sysRole.getName(), sysRole.getId()));
Assert.isTrue(!checkUnique(sysRole.getName(), sysRole.getId()), "角色名已存在");
}
sysRoleService.saveOrUpdate(sysRole);
// Assert.notNull(sysRole.getName(), "角色名不能为空");
return new ResultData();
}


@PostMapping("/del")
public ResultData delete(@RequestBody MallRole sysRole) {
sysRoleService.deleteById(sysRole.getId());
sysRolePermissionService.deleteByRoleId(sysRole.getId());
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("setPermission")
public ResultData setPermission(Long roleId, String perId) {
Assert.notNull(perId, "请选择权限");
/*String[] perIds = perId.split(",");
SysRolePermissionService.savePermissions(roleId, perIds);*/
//TODO
return new ResultData(Result.SUCCESS, "设置角色权限成功", null);

}

private boolean checkUnique(String name, Long id) {
return sysRoleService.countByName(name, id) > 0 ? true : false;
}

}

+ 236
- 0
mallinkAdmin/src/main/java/com/iformall/controller/MallUserInfoController.java Просмотреть файл

@@ -0,0 +1,236 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.domain.po.*;
import com.iformall.service.*;
import com.iformall.shiro.PasswordHelper;
import com.iformall.shiro.UserSession;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
* @author chenkx
* @date 2018-01-05.
*/
@Api(value = "API - UserInfoController", description = "用户接口")
@RestController
@RequestMapping("user")
public class MallUserInfoController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
MallUserInfoService userInfoService;

@Autowired
MallUserRoleService userRoleService;

@Autowired
MallRoleService mallRoleService;

@Autowired
MallUserRoleService mallUserRoleService;

@Autowired
MallPermissionService mallPermissionService;

@Autowired
MallRolePermissionService mallRolePermissionService;

@ApiOperation(value = "用户分页接口", response = String.class)
@GetMapping("lists")
public ResultData listAsPage(MallUserInfo userInfo, Integer pageNum, Integer pageSize) {
userInfo.setTenantId(getTenantId());
userInfo.setSortColumns(MallUserInfo.Field.Id_DESC);
final PageInfo<MallUserInfo> page = userInfoService.listAsPage(userInfo, pageNum, pageSize);
for (MallUserInfo u : page.getList()) {
MallUserRole r = new MallUserRole();
r.setUid(u.getId());
PageInfo<MallUserRole> ur = userRoleService.listAsPage(r, 1, 1);
if (ur.getSize() > 0) {
MallRole role = mallRoleService.getById(ur.getList().get(0).getRoleId());
if (role != null) {
u.setRoleName(role.getName());
u.setRoleId(role.getId());
}
}
u.setPassword(null);//不返回密码
}
return new ResultData(page);
}

@ApiOperation(value = "用户详情接口", response = String.class)
@GetMapping("detail")
public ResultData detail(Long id) {
final MallUserInfo user = userInfoService.getById(id);
return new ResultData(user);
}

@ApiOperation(value = "创建用户接口", response = String.class)
@PostMapping("add")
public ResultData createUser(@RequestBody MallUserInfo userInfo) {

if(checkUniqueName(userInfo.getUsername(), null)){
return new ResultData(ErrorCode.USER_NAME_IS_FOUND,"用户名已存在");
}
if(checkUniquePhone(userInfo.getPhone(), null)){
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND,"手机号已存在");
}
Assert.notNull(userInfo.getPassword(), "密码不能为空");
PasswordHelper passwordHelper = new PasswordHelper();
passwordHelper.encryptPassword(userInfo);
userInfo.setTenantId(getTenantId());
userInfoService.saveOrUpdate(userInfo);
if (userInfo.getRoleId() != null) {
MallUserRole r = new MallUserRole();
r.setRoleId(userInfo.getRoleId());
r.setUid(userInfo.getId());
userRoleService.saveOrUpdate(r);
}
return new ResultData();
}

@ApiOperation(value = "修改用户接口", response = String.class)
@PostMapping("update")
public ResultData updateUser(@RequestBody MallUserInfo userInfo) {
//Assert.notNull(userInfo.getUsername(), "用户名不能为空");
if(checkUniqueName(userInfo.getUsername(), userInfo.getId())){
return new ResultData(ErrorCode.USER_NAME_IS_FOUND,"用户名已存在");
}
if(checkUniquePhone(userInfo.getPhone(), userInfo.getId())){
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND,"手机号已存在");
}
// Assert.notNull(userInfo.getPassword(), "密码不能为空");
// PasswordHelper passwordHelper = new PasswordHelper();
// passwordHelper.encryptPassword(userInfo);
userInfo.setPassword(null);
userInfo.setTenantId(getTenantId());
userInfoService.saveOrUpdate(userInfo);
if (userInfo.getRoleId() != null) {
userRoleService.deleteByUserId(userInfo.getId());
MallUserRole r = new MallUserRole();
r.setRoleId(userInfo.getRoleId());
r.setUid(userInfo.getId());
userRoleService.saveOrUpdate(r);
}
return new ResultData();
}

@ApiOperation(value = "删除用户接口", response = String.class)
@PostMapping("/del")
public ResultData deleteUser(@RequestBody MallUserInfo userInfo) {
userInfoService.deleteById(userInfo.getId());

return new ResultData();
}

/**
* 启用,停用用户
*
* @param userId
* @param status
* @return
*/
@ApiOperation(value = "起停用户接口", response = String.class)
@GetMapping("status")
public ResultData modifyStatus(Long userId, Integer status) {
MallUserInfo userInfo = userInfoService.getById(userId);
userInfo.setStatus(status);
userInfo.setTenantId(getTenantId());
userInfoService.saveOrUpdate(userInfo);
return new ResultData(userInfo);
}

@ApiOperation(value = "用户添加角色接口", response = String.class)
@PostMapping("setRoles")
public ResultData setRoles(Long userId, String roleIds) {
/*String[] roIds = roleIds.split(",");
List<MallUserRole> u2rs = new ArrayList<>(roIds.length);
for (String roleId : roIds) {
MallUserRole userRole = new MallUserRole();
userRole.setRoleId(roleId);
userRole.setUid(userId);
u2rs.add(userRole);
}
userRoleService.batchInsert(u2rs);*/
return new ResultData();
}

private boolean checkUniqueName(String username, Long id) {
return userInfoService.cntByUserName(username,id);
}

private boolean checkUniquePhone(String phone, Long id) {
return userInfoService.cntByUserPhone(phone,id);
}


@GetMapping("hasButtonPermission")
public ResultData hasButtonPermission(String permissions) {
Map<String, Boolean> map = new HashMap<>();
for (String name : permissions.split(",")) {
Long userId = (Long)
SecurityUtils.getSubject().getSession().getAttribute(UserSession.userId);
boolean has = userInfoService.hasButtonPermission(userId, name);
map.put(name, has);
}
// StringBuffer buffer = new StringBuffer();
// for(Entry<String, Boolean> entrySet :map.entrySet()){
// buffer.append("var "+entrySet.getKey());
// buffer.append("="+entrySet.getValue());
// buffer.append(";");
// }
//return new ResultData(buffer.toString());
return new ResultData(map);
}

@GetMapping("getUser")
public ResultData getUserInfo() {
MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo);
info.setPassword("保密");
if (info.getIsAdmin() == 1) { // isAdmin
MallPermission q = new MallPermission();
PageInfo<MallPermission> list = mallPermissionService.listAsPage(q, 1, 100);
String menus = "";
for (MallPermission rp : list.getList()) {
menus += rp.getId() + ",";
}
if (menus.length() > 0) {
menus = menus.substring(0, menus.length() - 1);
}
info.setMenus(menus);
} else {
// System.out.println("id:"+ SecurityUtils.getSubject().getSession().getId());
MallUserRole ur = new MallUserRole();
ur.setUid(info.getId());
PageInfo<MallUserRole> page = mallUserRoleService.listAsPage(ur, 1, 1);
if (page.getSize() > 0) {
Long roleId = page.getList().get(0).getRoleId();
MallRolePermission p = new MallRolePermission();
p.setRoleId(roleId);
p.setTenantId(info.getTenantId());
PageInfo<MallRolePermission> listAsPage = mallRolePermissionService.listAsPage(p, 1, 100);
String menus = "";
for (MallRolePermission rp : listAsPage.getList()) {
menus += rp.getPermissionId() + ",";
}
if (menus.length() > 0) {
menus = menus.substring(0, menus.length() - 1);
}
info.setMenus(menus);
}
}
return new ResultData(info);
}
}

+ 65
- 0
mallinkAdmin/src/main/java/com/iformall/controller/MarkingDataReportController.java Просмотреть файл

@@ -0,0 +1,65 @@
package com.iformall.controller;

import com.iformall.common.ResultData;
import com.iformall.domain.dto.MarkingCouponDataReportDto;
import com.iformall.service.MarkingDataReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* Created by syf on 2018/8/29.
*/
@RestController
@RequestMapping("markingDataReport")
@Api(description = "营销报表接口")
public class MarkingDataReportController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private MarkingDataReportService markingDataReportService;

@ApiOperation("查询券数据")
@GetMapping("/couponData")
public ResultData findCouponData() {
return new ResultData(markingDataReportService.getCouponDate(getTenantId()));
}

@ApiOperation("查询券数据列表")
@GetMapping("/couponDataList")
public ResultData findCouponDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageNum, Integer pageSize) {
return new ResultData(markingDataReportService.getCouponDateList(getTenantId(), markingCouponDataReportDto, pageNum, pageSize));
}

@ApiOperation("查询场景投放券数据")
@GetMapping("/sceneData")
public ResultData findSceneData() {
return new ResultData(markingDataReportService.getSceneData(getTenantId()));
}

@ApiOperation("查询场景营销数据列表")
@GetMapping("/sceneDataList")
public ResultData findSceneDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageNum, Integer pageSize) {
return new ResultData(markingDataReportService.getSceneDataList(getTenantId(), markingCouponDataReportDto, pageNum, pageSize));
}

@ApiOperation("查询触达用户数数据")
@GetMapping("/touchUsersData")
public ResultData touchUsersData() {
return new ResultData(markingDataReportService.getTouchUsersReportData(getTenantId()));
}

@ApiOperation("查询触达用户数数据列表")
@GetMapping("/touchUsersDataList")
public ResultData touchUsersDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageNum, Integer pageSize) {
return new ResultData(markingDataReportService.getTouchUsersReportList(getTenantId(), markingCouponDataReportDto, pageNum, pageSize));
}


}

+ 59
- 0
mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java Просмотреть файл

@@ -0,0 +1,59 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.PushLimit;
import com.iformall.service.PushLimitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("pushLimit")
@Api(description = "疲劳度相关接口")
public class PushLimitController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private PushLimitService pushLimitService;

@ApiOperation("分页列表接口")
@GetMapping("list")
public ResultData list(@ModelAttribute PushLimit pushLimit) {
if (null == pushLimit) pushLimit = new PushLimit();
pushLimit.setTenantId(getTenantId());
final PageInfo<PushLimit> page = pushLimitService.listAsPage(pushLimit, 1, 10);
return new ResultData(page);
}


@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody PushLimit pushLimit) {
pushLimit.setMsgAmount(null);
pushLimitService.saveOrUpdate(pushLimit);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
pushLimitService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", pushLimitService.getById(id));
}


}

+ 190
- 0
mallinkAdmin/src/main/java/com/iformall/controller/UploadController.java Просмотреть файл

@@ -0,0 +1,190 @@
package com.iformall.controller;


import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.iformall.common.ResultData;
import com.iformall.config.AwsProperty;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping(value = "upload")
@Api(description = "文件上传接口")
public class UploadController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Value("${fileUpload.path}")
private String filePath;

@Value("${fileUpload.server}")
private String server;

@Autowired
private AwsProperty awsProperty;

/**
* 上传文件
*
* @param multiReq
* @return
* @throws Exception
*/
@PostMapping(value = "/fileUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data")
@ApiOperation("上传文件")
public ResultData fileUpload(@RequestParam("file") MultipartFile multiReq) {
ResultData data = new ResultData();
FileOutputStream fos = null;
BufferedInputStream fs = null;
try {
File targetFile = new File(filePath);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
String fileName = UUID.randomUUID().toString();
int dot = multiReq.getOriginalFilename().lastIndexOf('.');
fileName = fileName + multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length());
fos = new FileOutputStream(new File(filePath + File.separator + fileName));
fs = (BufferedInputStream) multiReq.getInputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fs.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
fos.close();
fs.close();
data.code = ResultData.SUCCESS;
Map<String, String> map = new HashMap<>();
map.put("url", server + "/" + fileName);
data.data = map;
} catch (Exception e) {
e.printStackTrace();
data.code = ResultData.ERROR;
data.message = "上传失败";
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
e.printStackTrace();
}
}


}
return data;
}

/**
* 上传文件
*
* @param multiReq
* @return
* @throws Exception
*/
@PostMapping(value = "/awsFileUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data")
@ApiOperation("上传文件")
public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) {
ResultData data = new ResultData();


ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentType(multiReq.getContentType());
metadata.setContentLength(multiReq.getSize());

FileOutputStream fos = null;
BufferedInputStream fs = null;
try {
AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withRegion(awsProperty.getClientRegion())
.withCredentials(new AWSCredentialsProvider() {
@Override
public AWSCredentials getCredentials() {
return new BasicAWSCredentials(awsProperty.getAccess(), awsProperty.getSecret());
}

@Override
public void refresh() {

}
})
.build();
String fileName = UUID.randomUUID().toString();
int dot = multiReq.getOriginalFilename().lastIndexOf('.');
fileName = getTenantId() + "/" + fileName + multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length());

s3.putObject(
new PutObjectRequest(awsProperty.getBucketName(), fileName, multiReq.getInputStream(), metadata)
.withCannedAcl(CannedAccessControlList.PublicRead));
URL url = s3.getUrl(awsProperty.getBucketName(), fileName);
logger.info(url.toString());

data.code = ResultData.SUCCESS;
Map<String, String> map = new HashMap<>();
map.put("url", url.toString());
data.data = map;
return data;
} catch (AmazonServiceException ase) {
data.code = ResultData.ERROR;
logger.warn("Caught an AmazonServiceException, which " +
"means your request made it " +
"to Amazon S3, but was rejected with an error response" +
" for some reason.");
logger.warn(ase.getMessage());
data.code = ResultData.ERROR;
data.message = "上传失败";
} catch (AmazonClientException ace) {
data.code = ResultData.ERROR;
logger.warn("Caught an AmazonClientException, which " +
"means the client encountered " +
"an internal error while trying to " +
"communicate with S3, " +
"such as not being able to access the network.");
logger.warn("Error Message: " + ace.getMessage());
data.code = ResultData.ERROR;
data.message = "上传失败";
} catch (IOException ioe) {
data.code = ResultData.ERROR;
logger.warn("Caught an IOException: " + ioe.getMessage());
data.code = ResultData.ERROR;
data.message = "上传失败";
}
return data;
}


}

+ 77
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxAdminLogController.java Просмотреть файл

@@ -0,0 +1,77 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxAdminLog;
import com.iformall.service.WxAdminLogService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxAdminLog")
public class WxAdminLogController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxAdminLogService wxAdminLogService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxAdminLog wxAdminLog, Integer pageNum, Integer pageSize) {
if (null == wxAdminLog) wxAdminLog = new WxAdminLog();
final PageInfo<WxAdminLog> page = wxAdminLogService.listAsPage(wxAdminLog, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxAdminLog wxAdminLog) {
//Assert.notNull(wxAdminLog.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxAdminLogService.saveOrUpdate(wxAdminLog);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxAdminLog wxAdminLog) {
String tenantId = getTenantId();
wxAdminLog.setTenantId(tenantId);
wxAdminLogService.saveOrUpdate(wxAdminLog);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxAdminLogService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxAdminLogService.getById(id));
}

@ApiOperation("PV计数")
@PostMapping("pvlog")
public ResultData pvLog(@RequestBody WxAdminLog wxAdminLog) {
String tenantId = getTenantId();
wxAdminLog.setTenantId(tenantId);
wxAdminLogService.saveLogCount(wxAdminLog);
return new ResultData();
}

}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxAppinfoController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.service.WxAppinfoService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxAppinfo")
public class WxAppinfoController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxAppinfoService wxAppinfoService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxAppinfo wxAppinfo, Integer pageNum, Integer pageSize) {
if (null == wxAppinfo) wxAppinfo = new WxAppinfo();
final PageInfo<WxAppinfo> page = wxAppinfoService.listAsPage(wxAppinfo, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxAppinfo wxAppinfo) {
//Assert.notNull(wxAppinfo.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxAppinfoService.saveOrUpdate(wxAppinfo);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxAppinfo wxAppinfo) {
wxAppinfoService.saveOrUpdate(wxAppinfo);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxAppinfoService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxAppinfoService.getById(id));
}


}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxBLogController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxBLog;
import com.iformall.service.WxBLogService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxBLog")
public class WxBLogController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxBLogService wxBLogService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxBLog wxBLog, Integer pageNum, Integer pageSize) {
if (null == wxBLog) wxBLog = new WxBLog();
final PageInfo<WxBLog> page = wxBLogService.listAsPage(wxBLog, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxBLog wxBLog) {
//Assert.notNull(wxBLog.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxBLogService.saveOrUpdate(wxBLog);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxBLog wxBLog) {
wxBLogService.saveOrUpdate(wxBLog);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxBLogService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxBLogService.getById(id));
}


}

+ 66
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxBillRentController.java Просмотреть файл

@@ -0,0 +1,66 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxBillRent;
import com.iformall.service.WxBillRentService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("wxBillRent")
public class WxBillRentController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxBillRentService wxBillRentService;

@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxBillRent wxBillRent, Integer pageNum, Integer pageSize) {
if (null == wxBillRent) wxBillRent = new WxBillRent();
wxBillRent.setTenantId(getTenantId());
wxBillRent.setSortColumns(WxBillRent.Field.Id_DESC);
final PageInfo<Map<String, Object>> page = wxBillRentService.listAsPage(wxBillRent, pageNum, pageSize);
return new ResultData(page);
}

@PostMapping("add")
public ResultData add(@RequestBody WxBillRent wxBillRent) {
//Assert.notNull(wxBillRent.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxBillRent.setTenantId(getTenantId());
wxBillRentService.saveOrUpdate(wxBillRent);
return new ResultData(ResultData.SUCCESS, "操作成功");
}

@PostMapping("update")
public ResultData update(@RequestBody WxBillRent wxBillRent) {
wxBillRentService.saveOrUpdate(wxBillRent);
return new ResultData(ResultData.SUCCESS, "操作成功");
}

@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxBillRentService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxBillRentService.getById(id));
}


}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxBusinessController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxBusiness;
import com.iformall.service.WxBusinessService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxBusiness")
public class WxBusinessController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxBusinessService wxBusinessService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxBusiness wxBusiness, Integer pageNum, Integer pageSize) {
if (null == wxBusiness) wxBusiness = new WxBusiness();
final PageInfo<WxBusiness> page = wxBusinessService.listAsPage(wxBusiness, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxBusiness wxBusiness) {
//Assert.notNull(wxBusiness.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxBusinessService.saveOrUpdate(wxBusiness);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxBusiness wxBusiness) {
wxBusinessService.saveOrUpdate(wxBusiness);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxBusinessService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxBusinessService.getById(id));
}


}

+ 70
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCLogController.java Просмотреть файл

@@ -0,0 +1,70 @@
package com.iformall.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;

import com.iformall.domain.po.WxCLog;
import com.iformall.service.WxCLogService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxCLog")
public class WxCLogController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCLogService wxCLogService;
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxCLog wxCLog,Integer pageNum, Integer pageSize) {
if (null == wxCLog) wxCLog = new WxCLog();
final PageInfo<WxCLog> page = wxCLogService.listAsPage(wxCLog, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCLog wxCLog) {
//Assert.notNull(wxCLog.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCLogService.saveOrUpdate(wxCLog);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCLog wxCLog) {
wxCLogService.saveOrUpdate(wxCLog);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxCLogService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxCLogService.getById(id));
}
}

+ 213
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java Просмотреть файл

@@ -0,0 +1,213 @@
package com.iformall.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.*;
import com.iformall.exception.MallinkException;
import com.iformall.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("wxCUserBasicInfo")
@Api(description = "会员管理相关接口")
public class WxCUserBasicInfoController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
private WxCUserTagsService wxCUserTagsService;

@Autowired
private WxTagsService wxTagsService;

@Autowired
private WxCUserService wxCUserService;

@Autowired
private WxCouponOrderService wxCouponOrderService;

@Autowired
private WxCouponService wxCouponService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCUserBasicInfo wxCUserBasicInfo, Integer pageNum, Integer pageSize) {
if (null == wxCUserBasicInfo) wxCUserBasicInfo = new WxCUserBasicInfo();
String tenantId = getTenantId();
wxCUserBasicInfo.setTenantId(tenantId);
PageInfo<WxCUserBasicInfo> page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageNum, pageSize);
return new ResultData(page);
}


private void createUserBasicInfo(WxCUser wxCUser) {
String phone = wxCUser.getPhone();
if (phone != null && phone.contains("*")) {
phone = wxCUser.getVerifyCodePhone();
}
if (StringUtils.isBlank(phone))
return;
WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo();
wxCUserBasicInfo.setId(wxCUser.getId());
wxCUserBasicInfo.setPhone(wxCUser.getPhone());
wxCUserBasicInfo.setTenantId(wxCUser.getTenantId());
wxCUserBasicInfo.setNickName(wxCUser.getNickName());
wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo);

}

// @ApiOperation("新增接口")
// @PostMapping("add")
// public ResultData add(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) {
// //Assert.notNull(wxCUserBasicInfo.getName(), "角色名不能为空");
// //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
// wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo);
// return new ResultData();
// }

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) {
WxCUserBasicInfo info = wxCUserBasicInfoService.getById(wxCUserBasicInfo.getId());
wxCUserBasicInfo.setTenantId(getTenantId());
if (StringUtils.isNotBlank(wxCUserBasicInfo.getTagIds())) {
WxCUserTags record = new WxCUserTags();
record.setUserId(info.getId());
record.setTenantId(getTenantId());
PageInfo<WxCUserTags> page = wxCUserTagsService.listAsPage(record, 1, 1);
if (page.getSize() > 0) {
WxCUserTags t = page.getList().get(0);
record.setId(t.getId());
}
String tags = wxCUserBasicInfo.getTagIds();
List<Long> tagIdList = new ArrayList<>();
for (String t : tags.split(",")) {
tagIdList.add(Long.valueOf(t));
}
record.setTags(JSON.toJSONString(tagIdList));
wxCUserTagsService.saveOrUpdate(record);
wxCUserBasicInfo.setTagId(record.getId());
}
wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCUserBasicInfoService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
WxCUserBasicInfo info = wxCUserBasicInfoService.getById(id);
if (info != null) {
if (info.getTagId() != null) {
WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId());
if (StringUtils.isNotBlank(uTag.getTags())) {
List<Long> ids = JSONObject.parseArray(uTag.getTags(), Long.class);
WxTags wxTags = new WxTags();
wxTags.setIds(ids);
PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, 1, 5000);
String tagNames = "";
String tagIds = "";
List<Long> tagIdList = new ArrayList<>();
for (WxTags wt : page.getList()) {
tagNames += wt.getName() + "/";
tagIds += wt.getId() + ",";
tagIdList.add(wt.getId());
}
if (StringUtils.isNotBlank(tagNames)) {
info.setTagNames(tagNames.substring(0, tagNames.length() - 1));
}
if (StringUtils.isNoneBlank(tagIds)) {
info.setTagIds(tagIds.substring(0, tagIds.length() - 1));
}
long count = wxCUserTagsService.findCountByTag(tagIdList);
info.setCount(count);
}
}
} else {
info = new WxCUserBasicInfo();
info.setId(id);
WxCUser user = wxCUserService.getById(id);
if (user != null) {
info.setTenantId(user.getTenantId());
info.setPhone(user.getPhone());
info.setSex(user.getGender());
}
}
return new ResultData(Result.SUCCESS, "查询成功", info);
}

@ApiOperation("根据userId查询交易记录接口")
@GetMapping("/findOrderCouponByUserId")
@ApiImplicitParam(name = "userId", value = "userId", dataType = "Long", paramType = "query", required = true)
public ResultData findOrderCouponByUserId(Long userId, Integer pageNum, Integer pageSize) {
WxCouponOrder corder = new WxCouponOrder();
corder.setCUserId(userId);
corder.setTenantId(getTenantId());
PageInfo<WxCouponOrder> page = wxCouponOrderService.listAsPage(corder, pageNum, pageSize);
if (page.getSize() > 0) {
List<WxCouponOrder> list = page.getList();
for (WxCouponOrder c : list) {
WxCoupon coupon = wxCouponService.getById(c.getCouponId());
c.setCouponName(coupon.getTitle());
c.setSalePrice(coupon.getPrice());
}
}
return new ResultData(Result.SUCCESS, "查询成功", page);
}

@RequestMapping("/exportData")
public void exportData(HttpServletRequest request, HttpServletResponse response){

wxCUserBasicInfoService.exportData(request,response,getTenantId());

}

@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletRequest request, HttpServletResponse response){

wxCUserBasicInfoService.exportTemplate(request,response,getTenantId());

}

@Transactional
@RequestMapping("/importTemplate")
public ResultData importTemplate(@RequestParam("file") MultipartFile file){
if (file.isEmpty()) {
throw new MallinkException(500,"上传文件不能为空");
}
return wxCUserBasicInfoService.importTemplate(file,getTenantId());
}


}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCUserCarController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCUserCar;
import com.iformall.service.WxCUserCarService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxCUserCar")
public class WxCUserCarController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCUserCarService wxCUserCarService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCUserCar wxCUserCar, Integer pageNum, Integer pageSize) {
if (null == wxCUserCar) wxCUserCar = new WxCUserCar();
final PageInfo<WxCUserCar> page = wxCUserCarService.listAsPage(wxCUserCar, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCUserCar wxCUserCar) {
//Assert.notNull(wxCUserCar.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCUserCarService.saveOrUpdate(wxCUserCar);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCUserCar wxCUserCar) {
wxCUserCarService.saveOrUpdate(wxCUserCar);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCUserCarService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCUserCarService.getById(id));
}


}

+ 70
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCUserController.java Просмотреть файл

@@ -0,0 +1,70 @@
package com.iformall.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;

import com.iformall.domain.po.WxCUser;
import com.iformall.service.WxCUserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxCUser")
public class WxCUserController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCUserService wxCUserService;
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxCUser wxCUser,Integer pageNum, Integer pageSize) {
if (null == wxCUser) wxCUser = new WxCUser();
final PageInfo<WxCUser> page = wxCUserService.listAsPage(wxCUser, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCUser wxCUser) {
//Assert.notNull(wxCUser.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCUserService.saveOrUpdate(wxCUser);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCUser wxCUser) {
wxCUserService.saveOrUpdate(wxCUser);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxCUserService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxCUserService.getById(id));
}
}

+ 302
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCUserDataController.java Просмотреть файл

@@ -0,0 +1,302 @@
package com.iformall.controller;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 com.iformall.common.ResultData;
import com.iformall.domain.dto.WxCUserBasicInfoDto;
import com.iformall.domain.vo.CUserDateAmountVo;
import com.iformall.domain.vo.TouchUsersReportVo;
import com.iformall.domain.vo.UserStructureVo;
import com.iformall.service.WxCUserService;
import com.iformall.service.WxCouponOrderService;
import com.iformall.service.WxUserVisitService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxCUserData")
@Api(description="会员首页报表数据")
public class WxCUserDataController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private WxCUserService wxCUserService;
@Autowired
private WxUserVisitService wxUserVisitService;
@Autowired
private WxCouponOrderService wxCouponOrderService;
@GetMapping("findUserCountData")
@ApiOperation("查询用户数量接口")
public ResultData findUserCountData() {
WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto();
long allCount = wxCUserService.findCount(dto);//总数
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE,0);
c.set(Calendar.SECOND,0);
Date today = c.getTime();
// dto.setStartTime(today);
// dto.setEndTime(null);
// long todayCount= wxCUserService.findCount( dto);//今天新增
// System.out.println(todayCount);
long todayCount=0;
long yesterdayCount =0;
long dayOfWeekCount=0;
List<UserStructureVo> newCountVos = new ArrayList<>();//每日新增会员数
int j=0;
for(int i=7;i>=0;i--) {
c.clear();
c.setTime(today);
c.add(Calendar.DAY_OF_YEAR, -i);
dto.setStartTime(c.getTime());
c.add(Calendar.DAY_OF_YEAR, 1);
dto.setEndTime(c.getTime());
long count= wxCUserService.findCount(dto);
UserStructureVo vo = new UserStructureVo();
vo.setSortNum(j);
j++;
vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime()));
vo.setCount(count);
if(i==1) {
yesterdayCount= count;
}
if(i==0) {
todayCount=count;
}
if(i==7) {
dayOfWeekCount=count;//上周同比
}else {
newCountVos.add(vo);
}
}
NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);
String dayPercentage ="";
if(yesterdayCount>0) {
Long count =todayCount-yesterdayCount;
dayPercentage=nf.format(count.doubleValue()/new Double(yesterdayCount).doubleValue());
}else {
dayPercentage= nf.format(new Double(todayCount).doubleValue());
}
String weekPercentage ="";
if(dayOfWeekCount>0) {
Long count =todayCount-dayOfWeekCount;
weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue());
}else {
weekPercentage= nf.format(new Double(todayCount).doubleValue());
}
Map<String,Object> map = new HashMap<>();
map.put("allCount", allCount);//会员总数
map.put("todayCount", todayCount);//今日新增会员数
map.put("newCountVos", newCountVos);//近一个月新增数列表
map.put("dayPercentage",dayPercentage);//日环比
map.put("weekPercentage",weekPercentage); //周同比
return new ResultData(map);
}
@ApiOperation("查询用户活跃量")
@GetMapping("findUserVisitData")
public ResultData findUserVisitData() {
HashMap<String, Object> params =new HashMap<>();
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_YEAR, -1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE,0);
c.set(Calendar.SECOND,0);
Date endTime = c.getTime();
c.add(Calendar.DAY_OF_YEAR, -30);
Date startTime = c.getTime();
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("tenantId", getTenantId());
List<TouchUsersReportVo> list = wxUserVisitService.touchUsersReportList(params);
Map<String,TouchUsersReportVo> dateMap = new HashMap<>();
for(TouchUsersReportVo vo :list) {
dateMap.put(vo.getxTime(), vo);
}
List<UserStructureVo> weekVos = new ArrayList<>();//每周uv
List<UserStructureVo> monthVos =new ArrayList<>();//每月uv
int j=1;
long yesterdayCount =0;//昨天活跃数
long beforeYesterdayCount=0;//前天活跃数
long thisMonthCount=0;//月总数
long dayOfWeekCount=0;//上周周x数
for(int i=6;i>=0;i--) {
c.clear();
c.setTime(endTime);
c.add(Calendar.DAY_OF_YEAR, -i);
String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
UserStructureVo vo = new UserStructureVo();
vo.setName(new SimpleDateFormat("MM-dd").format(c.getTime()));
vo.setSortNum(j);
j++;
if(dateMap.get(dayStr)!=null) {
TouchUsersReportVo rv = dateMap.get(dayStr);
Long l = new Long((long) rv.getUv());
vo.setCount(l);
}else {
vo.setCount(0);
}
weekVos.add(vo);
}
j=1;
for(int i=29;i>=0;i--) {
c.clear();
c.setTime(endTime);
c.add(Calendar.DAY_OF_YEAR, -i);
String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
UserStructureVo vo = new UserStructureVo();
vo.setName(new SimpleDateFormat("MM-dd").format(c.getTime()));
vo.setSortNum(j);
if(dateMap.get(dayStr)!=null) {
TouchUsersReportVo rv = dateMap.get(dayStr);
Long l = new Long((long) rv.getUv());
vo.setCount(l);
}else {
vo.setCount(0);
}
thisMonthCount+=vo.getCount();
if(i==0) {
yesterdayCount =vo.getCount();
}
if(i==1) {
beforeYesterdayCount =vo.getCount();
}
if(i==7) {
dayOfWeekCount=vo.getCount();
}
monthVos.add(vo);
j++;
}
NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);
String dayPercentage ="";
if(beforeYesterdayCount>0) {
Long count =yesterdayCount-beforeYesterdayCount;
dayPercentage=nf.format(count.doubleValue()/new Double(beforeYesterdayCount).doubleValue());
}else {
dayPercentage= nf.format(new Double(yesterdayCount).doubleValue());
}
String weekPercentage ="";
if(dayOfWeekCount>0) {
Long count =yesterdayCount-dayOfWeekCount;
weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue());
}else {
weekPercentage= nf.format(new Double(yesterdayCount).doubleValue());
}
Map<String,Object> mapVo =new HashMap<>();
mapVo.put("yesterdayCount", yesterdayCount);//昨日活跃数
mapVo.put("thisMonthCount", thisMonthCount);//近一个月活跃数
mapVo.put("weekVos", weekVos);//上周活跃数列表
mapVo.put("monthVos", monthVos);//上月活跃数列表
mapVo.put("dayPercentage",dayPercentage);//日环比
mapVo.put("weekPercentage",weekPercentage); //周同比
return new ResultData(mapVo);
}

@ApiOperation("查询用户消费金额")
@GetMapping("findUserAmountData")
private ResultData findUserAmountData() {
String tenantId = getTenantId();
Calendar c =Calendar.getInstance();
Date today = c.getTime();
c.add(Calendar.DAY_OF_YEAR, 1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE,0);
c.set(Calendar.SECOND,0);
Date endTime = c.getTime();//明天0点
c.add(Calendar.DAY_OF_YEAR, -30);//三十天前
Date startTime = c.getTime();
int thisMonthCount =wxCouponOrderService.queryPriceTotal(tenantId, startTime, endTime);//月消费金额
c.clear();
c.setTime(endTime);
Date eTime=c.getTime();
c.add(Calendar.DAY_OF_YEAR, -8);
Date sTime =c.getTime();
List<CUserDateAmountVo> datas = wxCouponOrderService.queryPriceTotalGroup(tenantId, sTime, eTime);
Map<String,Integer> dataMap = new HashMap<>();
for(CUserDateAmountVo v:datas) {
dataMap.put(v.getxTime(), v.getPrice());
}
Integer todayCount=0;//今日金额数
Integer yesterdayCount =0;//昨日金额数
Integer dayOfWeekCount=0;//上周x
int j=0;
List<UserStructureVo> weekCountVos = new ArrayList<>();//周消费金额
for(int i=7;i>=0;i--) {
c.clear();
c.setTime(today);
c.add(Calendar.DAY_OF_YEAR, -i);
String dateStr = new SimpleDateFormat("MM-dd").format(c.getTime());
UserStructureVo vo = new UserStructureVo();
vo.setName(new SimpleDateFormat("MM-dd").format(c.getTime()));
vo.setSortNum(j);
if(dataMap.get(dateStr)!=null) {
int price= dataMap.get(dateStr);
vo.setPrice(price);
}else {
vo.setPrice(0);
}
if(i==0) {
todayCount =vo.getPrice();
}
if(i==1) {
yesterdayCount =vo.getPrice();
}
if(i==7) {
dayOfWeekCount=vo.getPrice();
}else {
weekCountVos.add(vo);
}
j++;
}
NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);
String dayPercentage ="";
if(yesterdayCount>0) {
Integer count =todayCount-yesterdayCount;
dayPercentage=nf.format(count.doubleValue()/new Double(yesterdayCount).doubleValue());
}else {
dayPercentage= nf.format(new Double(todayCount).doubleValue());
}
String weekPercentage ="";
if(dayOfWeekCount>0) {
Integer count =todayCount-dayOfWeekCount;
weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue());
}else {
weekPercentage= nf.format(new Double(todayCount).doubleValue());
}
Map<String,Object> map =new HashMap<>();
DecimalFormat df=new DecimalFormat("0.00");
map.put("todayCount", df.format((float)todayCount/100));//今日消费金额
String thisMonthCountStr = df.format((float)thisMonthCount/100);
map.put("thisMonthCount", thisMonthCountStr);//近一个月消费金额数
map.put("dayPercentage",dayPercentage);//日环比
map.put("weekPercentage",weekPercentage); //周同比
map.put("weekCountVos", weekCountVos);//一周金额列表
return new ResultData(map);
}
}



+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCUserTagsController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCUserTags;
import com.iformall.service.WxCUserTagsService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxCUserTags")
public class WxCUserTagsController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCUserTagsService wxCUserTagsService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCUserTags wxCUserTags, Integer pageNum, Integer pageSize) {
if (null == wxCUserTags) wxCUserTags = new WxCUserTags();
final PageInfo<WxCUserTags> page = wxCUserTagsService.listAsPage(wxCUserTags, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCUserTags wxCUserTags) {
//Assert.notNull(wxCUserTags.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCUserTagsService.saveOrUpdate(wxCUserTags);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCUserTags wxCUserTags) {
wxCUserTagsService.saveOrUpdate(wxCUserTags);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCUserTagsService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCUserTagsService.getById(id));
}


}

+ 137
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCampaignController.java Просмотреть файл

@@ -0,0 +1,137 @@
package com.iformall.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCampaign;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.EnumCouponChannelType;
import com.iformall.service.WxCampaignService;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.iformall.domain.po.WxCampaign.Field.SortNum_ASC;

@RestController
@RequestMapping("wxCampaign")
@Api(description = "促销和banner接口")
public class WxCampaignController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCampaignService wxCampaignService;

@Autowired
private WxCouponService wxCouponService;

@Autowired
private WxCouponChannelService wxCouponChannelService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCampaign wxCampaign, Integer pageNum, Integer pageSize) {
if (null == wxCampaign) wxCampaign = new WxCampaign();
if (wxCampaign.getStatus() != null && wxCampaign.getStatus() == -1) {
wxCampaign.setStatus(null);
}
wxCampaign.setTenantId(getTenantId());
wxCampaign.setSortColumns(SortNum_ASC);
final PageInfo<WxCampaign> page = wxCampaignService.listAsPage(wxCampaign, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCampaign wxCampaign) {
//Assert.notNull(wxCampaign.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
// int sortNum = wxCampaignService.getMaxSortNum(getTenantId());
if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) {
String[] arys = wxCampaign.getCouponIds().split(",");
wxCampaign.setCouponIds(JSON.toJSONString(arys));
} else {
wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0]));
}
wxCampaign.setStatus(0);
wxCampaign.setTenantId(getTenantId());
// wxCampaign.setSortNum(sortNum+1);
wxCampaignService.saveOrUpdate(wxCampaign);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCampaign wxCampaign) {
if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) {
String[] arys = wxCampaign.getCouponIds().split(",");
wxCampaign.setCouponIds(JSON.toJSONString(arys));
} else {
wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0]));
}
wxCampaignService.saveOrUpdate(wxCampaign);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCampaignService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
WxCampaign wxCampaign = wxCampaignService.getById(id);
if (wxCampaign != null) {
WxCouponChannel wxCouponChannel = new WxCouponChannel();
wxCouponChannel.setTenantId(getTenantId());
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode());
wxCouponChannel.setSubTargetId(wxCampaign.getId());
wxCouponChannel.setStatus(0);
List<WxCouponChannelVo> couponList = wxCouponChannelService.listAPI(wxCouponChannel);
wxCampaign.setCoupons(couponList);
}
return new ResultData(Result.SUCCESS, "查询成功", wxCampaign);
}

@ApiOperation("调整顺序")
@GetMapping("/move")
@ApiImplicitParams({
@ApiImplicitParam(name = "sourceId", value = "", dataType = "Long", paramType = "query", required = true),
@ApiImplicitParam(name = "targetId", value = "", dataType = "Long", paramType = "query", required = true)})
public ResultData move(Long sourceId, Long targetId) {
WxCampaign source = wxCampaignService.getById(sourceId);
WxCampaign target = wxCampaignService.getById(targetId);
if (source == null || target == null) {
return new ResultData(Result.ERROR, "调整顺序失败", null);
}
int temp = source.getSortNum();
source.setSortNum(target.getSortNum());
target.setSortNum(temp);
wxCampaignService.saveOrUpdate(source);
wxCampaignService.saveOrUpdate(target);
return new ResultData(Result.SUCCESS, "调整顺序成功", null);
}


}

+ 352
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCarCallBackController.java Просмотреть файл

@@ -0,0 +1,352 @@
package com.iformall.controller;

import com.alibaba.fastjson.JSON;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.domain.po.WxCUserCar;
import com.iformall.domain.po.WxCarCmdLog;
import com.iformall.domain.po.WxPark;
import com.iformall.enums.EnumCarCmd;
import com.iformall.enums.EnumCarVendor;
import com.iformall.enums.EnumCouponSendSendType;
import com.iformall.enums.EnumETCPCode;
import com.iformall.service.*;
import com.iformall.utils.ETCPUtil;
import com.iformall.utils.TJDCarUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/carCallback")
public class WxCarCallBackController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

ETCPUtil etcp = new ETCPUtil();

TJDCarUtil tjd = new TJDCarUtil();

@Autowired
WxParkService wxParkService;

@Autowired
WxCUserCarService wxCUserCarService;

@Autowired
WxMerchantService wxMerchantService;

@Autowired
WxCarCmdLogService wxCarCmdLogService;

@Autowired
WxCouponSendService wxCouponSendService;

/**
* ETCP 车辆入场通知
* {
* "synId": "4ebd80ff-cfcf-462a-94cb-727e9fa9547c",
* "plateNumber": "渝 ATX061",
* "parkName": "ETCP 智慧停车场",
* "parkId": "1",
* "entranceTime": "2017-08-20 12:59:54",
* "userType": "76",
* "pushTime": "2017-08-20 12:59:57",
* "fixParkingId": "U7",
* "remainingDays": "11"
* }
*/
@PostMapping(value = "/etcpParkInCallback")
public Result etcpParkInCallback(@RequestBody Map<String, String> paramMap) {
logger.info("etcpParkInCallback: " + paramMap.toString());
Date currentDate = new Date();
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog();

wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode());
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode());
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap));
wxCarCmdLog.setCreateDate(currentDate);
wxCarCmdLog.setUpdateDate(currentDate);

String etcpParkId = paramMap.get("parkId");
String tenantId = "456";
WxPark parkQ = new WxPark();
parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode());
parkQ.setParkId(etcpParkId);
WxPark park = wxParkService.getByObj(parkQ);
if (park == null) {
logger.error("etcpParkInCallback: ETCP车场未找到" + etcpParkId);
//return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId);
} else {
tenantId = park.getTenantId();
wxCarCmdLog.setTenantId(park.getTenantId());
}

try {
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog);
} catch (Exception e) {
logger.error("etcpParkInCallback: 入库错误 " + paramMap.toString());
return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误" + paramMap.toString());
}

// 停车发券
String carNumber = paramMap.get("plateNumber");
if (!StringUtils.isBlank(carNumber)) {
// 根据车牌查找用户
WxCUserCar userCarQ = new WxCUserCar();
userCarQ.setTenantId(tenantId);
userCarQ.setCarNumber(carNumber);
userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode());
// TODO 可能多用户关联同一张车牌
List<WxCUserCar> userCarList = wxCUserCarService.getList(userCarQ);
for (WxCUserCar userCar : userCarList) {
wxCouponSendService.sendCouponToUser(tenantId, userCar.getCUserId(), EnumCouponSendSendType.CAR_STOP);
}
}


return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage());
}

/**
* ETCP 车辆出场通知
* {
* "synId": "fd92f645-880e-4c2a-9d7d-7081a2488181",
* "plateNumber": "渝 ATX061",
* "parkName": "ETCP 智慧停车场",
* "parkId": "1",
* "entranceTime": "2017-08-17 18:44:19",
* "userType": "76",
* "pushTime": "2017-08-20 11:57:51",
* "exitTime": "2017-08-19 12:07:19",
* "stayedTime": 148980,
* "receivableFee": 0,
* "paidServiceFee": 0,
* "fixParkingId": "U7",
* "remainingDays": "12"
* }
*/
@PostMapping(value = "/etcpParkOutCallback")
public Result etcpParkOutCallback(@RequestBody Map<String, String> paramMap) {
logger.info("etcpParkOutCallback: " + paramMap.toString());
Date currentDate = new Date();

WxCarCmdLog wxCarCmdLog = new WxCarCmdLog();
wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode());
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_OUT.getCode());
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap));
wxCarCmdLog.setCreateDate(currentDate);
wxCarCmdLog.setUpdateDate(currentDate);

String etcpParkId = paramMap.get("parkId");
WxPark parkQ = new WxPark();
parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode());
parkQ.setParkId(etcpParkId);
WxPark park = wxParkService.getByObj(parkQ);
if (park == null) {
logger.error("etcpParkOutCallback: ETCP车场未找到 " + etcpParkId);
//return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId);
} else {
wxCarCmdLog.setTenantId(park.getTenantId());
}

try {
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog);
} catch (Exception e) {
logger.error("etcpParkOutCallback: 入库错误 " + paramMap.toString());
return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误" + paramMap.toString());
}

// TODO 如果此车关联了停车优免券,自动把优免券设为已使用

return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage());
}

/**
* ETCP 车辆解绑通知
* {
* "plateNumber": "渝 ATX061",
* "time": "2017-08-20 11:57:51"
* }
*/
@PostMapping(value = "/etcpUnbindCarCallBack")
public Result etcpUnbindCarCallBack(@RequestBody Map<String, String> paramMap) {
logger.info("etcpUnbindCarCallBack: " + paramMap.toString());
String carNumber = paramMap.get("plateNumber");

// TODO how to get the parkId

Date currentDate = new Date();
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog();
wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode());
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_UNBIND.getCode());
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap));
wxCarCmdLog.setCreateDate(currentDate);
wxCarCmdLog.setUpdateDate(currentDate);
try {
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog);
} catch (Exception e) {
logger.error("etcpUnbindCarCallBack: 入库错误 " + paramMap.toString());
return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误" + paramMap.toString());
}

WxCUserCar userCarQ = new WxCUserCar();
userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode());
userCarQ.setCarNumber(carNumber);
// 数据库里删除,保持同步
try {
wxCUserCarService.deleteByObj(userCarQ);
} catch (Exception e) {
logger.error(e.getMessage());
}
// 营销 - 短信
return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage());
}

/**
* ETCP 主动支付结果通知
* {
* "plateNumber": "渝 ATX061",
* "orderId": "fd92f645-880e-4c2a-9d7d-7081a2488181",
* "fee": 7.65,
* "paidServiceFee": 0.07,
* "coupon": 0,
* "time": "2017-08-20 11:57:51"
* }
*/
@PostMapping(value = "/etcpPaidCallback")
public Result etcpPaidCallback(@RequestBody Map<String, String> paramMap) {
logger.info("etcpPaidCallback: " + paramMap.toString());
String carNumber = paramMap.get("plateNumber");

// TODO how to get the parkId

Date currentDate = new Date();
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog();
wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode());
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PAY_MANUAL.getCode());
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap));
wxCarCmdLog.setCreateDate(currentDate);
wxCarCmdLog.setUpdateDate(currentDate);
try {
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog);
} catch (Exception e) {
logger.error("etcpPaidCallback: 入库错误 " + paramMap.toString());
return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误" + paramMap.toString());
}

// 营销 - 短信
return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage());
}


/**
* TJD 车辆入场通知
* {
* "tradeId": "5836b8b52ada463ebc6199579f029565",
* "outCarId": "45454545454",
* "carNum": "京A45413",
* "carNumColor ": "blue",
* "inDt": "20170319202020",
* "parkName": "测试停车场",
* "parkId": "5836b8b52ada463ebc6199579f029561",
* "lon": "74.000272",
* "lat": "159.768703",
* "wLon": "123.523032",
* "wLat": "35.430735",
* "payUrl": "http://prep.tingjiandan.com/tcweixin/letter/prePay/payInPark.html?prePayType=16&channel=10001",
* "canFindCar": "0"
* }
*/
@RequestMapping(value = "/tjdParkInCallback")
public Map tjdParkInCallback(@RequestBody Map<String, String> paramMap) {
logger.info("tjdParkInCallback: " + paramMap.toString());
Map map = new HashMap();


String tjdParkId = paramMap.get("parkId");

WxPark parkQ = new WxPark();
parkQ.setVendorType(EnumCarVendor.CAR_TJD.getCode());
parkQ.setParkId(tjdParkId);
WxPark park = wxParkService.getByObj(parkQ);
if (park == null) {
logger.error("tjdParkInCallback: 停简单车场未找到" + tjdParkId);
map.put("isSuccess", "0");
map.put("errorMsg", "停简单车场未找到" + tjdParkId);
return map;
}

Date currentDate = new Date();
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog();
wxCarCmdLog.setTenantId(park.getTenantId());
wxCarCmdLog.setVendorType(EnumCarVendor.CAR_TJD.getCode());
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode());
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap));
wxCarCmdLog.setCreateDate(currentDate);
wxCarCmdLog.setUpdateDate(currentDate);
try {
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog);
} catch (Exception e) {
logger.error("tjdParkInCallback: 入库错误" + paramMap.toString());
map.put("isSuccess", "0");
map.put("errorMsg", "入库错误" + paramMap.toString());
return map;
}

map.put("isSuccess", "0");
map.put("errorMsg", "");
return map;
}

/**
* TJD 车辆出场通知
* {
* "tradeId": "5836b8b52ada463ebc6199579f029565",
* "outDt": "20170319232020",
* "lon": "74.000272",
* "lat": "159.768703",
* "wLon": "123.523032",
* "wLat": "35.430735",
* "parkAmount": "5.20"
* }
*/
@RequestMapping(value = "/tjdParkoutCallback")
public Map tjdParkOutCallback(@RequestBody Map<String, String> paramMap) {
logger.info("tjdParkoutCallback: " + paramMap.toString());
Map map = new HashMap();


String tradeId = paramMap.get("tradeId");

Date currentDate = new Date();
WxCarCmdLog wxCarCmdLog = new WxCarCmdLog();
wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode());
wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_OUT.getCode());
wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap));
wxCarCmdLog.setCreateDate(currentDate);
wxCarCmdLog.setUpdateDate(currentDate);
try {
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog);
} catch (Exception e) {
logger.error("tjdParkoutCallback: 入库错误" + paramMap.toString());
map.put("isSuccess", "0");
map.put("errorMsg", "入库错误" + paramMap.toString());
return map;
}

map.put("isSuccess", "0");
map.put("errorMsg", "");
return map;
}

}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCarCmdLogController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCarCmdLog;
import com.iformall.service.WxCarCmdLogService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxCarCmdLogs")
public class WxCarCmdLogController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCarCmdLogService wxCarCmdLogService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCarCmdLog wxCarCmdLogs, Integer pageNum, Integer pageSize) {
if (null == wxCarCmdLogs) wxCarCmdLogs = new WxCarCmdLog();
final PageInfo<WxCarCmdLog> page = wxCarCmdLogService.listAsPage(wxCarCmdLogs, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCarCmdLog wxCarCmdLog) {
//Assert.notNull(wxCarCmdLogs.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCarCmdLog wxCarCmdLog) {
wxCarCmdLogService.saveOrUpdate(wxCarCmdLog);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCarCmdLogService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCarCmdLogService.getById(id));
}


}

+ 326
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java Просмотреть файл

@@ -0,0 +1,326 @@
package com.iformall.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxCouponCarDto;
import com.iformall.domain.po.*;
import com.iformall.domain.vo.WxCouponCarVo;
import com.iformall.enums.EnumCarVendor;
import com.iformall.enums.EnumCouponStatus;
import com.iformall.service.*;
import com.iformall.utils.ETCPUtil;
import com.iformall.utils.TJDCarUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/car")
public class WxCarController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

ETCPUtil etcp = new ETCPUtil();

TJDCarUtil tjd = new TJDCarUtil();

@Autowired
WxParkService wxParkService;

@Autowired
WxCUserCarService wxCUserCarService;

@Autowired
WxMerchantService wxMerchantService;

@Autowired
WxCarCmdLogService wxCarCmdLogService;

@Autowired
WxCouponService wxCouponService;

@Autowired
WxCouponCarService wxCouponCarService;

private WxPark getCurrentPark(MallUserInfo user) {
WxPark parkQ = new WxPark();
parkQ.setTenantId(user.getTenantId());
WxPark wxPark = wxParkService.getByObj(parkQ);
// 1, get mall's park
// future use redis to optimize
return wxPark;
}

@ApiOperation(value = "获取车场支持的厂家", notes = "{}")
@GetMapping("/getVendor")
public ResultData getVendor() {
MallUserInfo user = getUser();
// 1, get mall's park
WxPark park = getCurrentPark(user);
Map map = new HashMap();
map.put("vendor", park.getVendorType());
return new ResultData(map);
}

// 优免券模板
/*
{
"id": 4974, //优免券模板 ID
"parkId": "fbqXUlfVvfc=", //车场标识
"businessId": "ZcWQ26TeJuQ=", //商家标识
title -- "businessName": "天洋广场", //商家名称
subtitle -- "name": "商家 1 小时优免券", //优免券名称
"category": "1", //优免券类型 1:小时优惠券,2:金额优惠券,3:折扣优惠券,4:免费券
price -- "categoryValue": "1.00", //优免券价值
total -- "amount": 100000, //优免券数量
valid_start_date -- "effectiveStart": "2018-02-01", //生效开始时间
valid_end_date -- "effectiveEnd": "2028-02-01",//生效结束时间
-"couponType": "0",//优惠券类型
number 库存 -- "avaliavleNum": 99993 //可用优惠券
},
*/
@ApiOperation(value = "优免券模板", notes = "{\"merchantId\":\"商户ID\"}\n输出\n" +
"{\n" +
"\"data\":{" +
"\"count\": 4," +
"\"couponPlatformModels\": [\n" +
" {\n" +
" \"id\": 4974, //优免券模板 ID\n" +
" \"parkId\": \"fbqXUlfVvfc=\", //车场标识" +
" \"businessId\": \"ZcWQ26TeJuQ=\", //商家标识" +
" \"businessName\": \"天洋广场\", //商家名称" +
" \"name\": \"商家 1 小时优免券\", //优免券名称" +
" \"category\": \"1\", //优免券类型\n 1:小时优惠券,2:金额优惠券,3:折扣优惠券,4:免费券" +
" \"categoryValue\": \"1.00\", //优免券价值\n" +
" \"amount\": 100000, //优免券数量\n" +
" \"effectiveStart\": \"2018-02-01\", //生效开始时间\n" +
" \"effectiveEnd\": \"2028-02-01\",//生效结束时间\n" +
" \"couponType\": \"0\",//优惠券类型\n" +
" \"avaliavleNum\": 99993 //可用优惠券\n" +
" },\n" +
" {...},\n" +
" {...}\n" +
" ]}}\n")
@GetMapping("/quanTemplate")
@ApiImplicitParams({
@ApiImplicitParam(name = "merchantId", value = "商户ID", dataType = "String", paramType = "query", required = true),
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData quanTemplate(String merchantId, Integer pageNum, Integer pageSize) {
logger.info("quanTemplate: " + merchantId);
MallUserInfo user = getUser();
/// 1, get mall's park
WxPark park = getCurrentPark(user);
String params = park.getVendorParams();
JSONObject objParams = JSON.parseObject(params);
String url = objParams.getString("url");
String merchantNo = objParams.getString("merchantNo");
String merchantKey = objParams.getString("merchantKey");
String version = objParams.getString("version");
String parkId = park.getParkId();

if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) {
if (StringUtils.isBlank(merchantId)) {
// 优先从从商户表里取
logger.error("quanTemplate failed, merchantId为空");
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户为空");
}
// bussinessId from 参数信息
String businessId = "";
// 优先从从商户表里取
businessId = getETCPBusinessID(merchantId);
if (StringUtils.isBlank(businessId)) {
// 1期只有一个虚拟商户,可以写在商场配置里
businessId = objParams.getString("businessId");
}
String ret = etcp.getBCouponList(url, merchantNo, merchantKey, version, parkId, businessId);
if (ret == null) {
logger.error("quanTemplate failed, 优免券模板未发现");
return new ResultData(ErrorCode.ETCP_CMD_FAIL.getCode(), "获取优免券模板异常");
}
JSONObject retObj = JSON.parseObject(ret);
if (retObj.getIntValue("code") == 0) {
return new ResultData(retObj.getJSONObject("data"));
} else {
logger.error("quanTemplate failed, 优免券模板未发现");
return new ResultData(ErrorCode.ETCP_QUAN_TEMP_FAIL.getCode(), "优免券模板未发现", retObj);
}
}
return new ResultData(ErrorCode.CAR_VENDOR_NOT_SUPPORT.getCode(), "优免券模板失败");
}

private String getETCPBusinessID(String merchantIdStr) {
String businessId;
Long merchantId = 0L;
try {
merchantId = Long.valueOf(merchantIdStr);
} catch (NumberFormatException e) {
logger.error(e.getMessage());
}
WxMerchant wxMerchant = wxMerchantService.getById(merchantId);
String carParams = wxMerchant.getCarParams();
JSONObject objParams1 = JSON.parseObject(carParams);
businessId = objParams1.getString("businessId");
return businessId;
}

@ApiOperation("新增停车券接口")
@PostMapping("save")
public ResultData save(@RequestBody WxCouponCarVo coupon) {
logger.info(coupon.toString());
//Assert.notNull(wxCoupon.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
// Save to wx_counpon
Date curDate = new Date();
MallUserInfo user = getUser();
// check 同一个模板的券分配额是否超了
if (StringUtils.isBlank(coupon.getVendorParams())) {
logger.error("请填充停车厂商优免券参数");
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "停车厂商参数为空");
}
JSONObject vendorParamsObj = JSON.parseObject(coupon.getVendorParams());
Long templateId = vendorParamsObj.getLong("id");
Integer amount = vendorParamsObj.getInteger("amount");
Integer avaliavleNum = vendorParamsObj.getInteger("avaliavleNum");
Integer amtCount = wxCouponCarService.getAmtCountByTemplateId(templateId);
Integer availCount = wxCouponCarService.getAvaibleCountByTemplateId(templateId);
if (amtCount >= amount) {
logger.error("已达到停车厂商优免券数量限制");
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已达到停车厂商优免券数量限制");
}
if (availCount >= avaliavleNum) {
logger.error("已达到停车厂商优免券数量限制");
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已达到停车厂商优免券数量限制");
}
// check End


WxCoupon wxCoupon = new WxCoupon();
wxCoupon.setTenantId(user.getTenantId());
wxCoupon.setMerchantId(coupon.getMerchantId());
if (StringUtils.isNotEmpty(coupon.getSalePriceStr())) {
wxCoupon.setSalePrice((int) (Double.parseDouble(coupon.getSalePriceStr()) * 100));
}
if (StringUtils.isNotEmpty(coupon.getUsePriceStr())) {
wxCoupon.setUsePrice((int) (Double.parseDouble(coupon.getUsePriceStr()) * 100));
}
if (StringUtils.isNotEmpty(coupon.getPriceStr())) {
wxCoupon.setPrice((int) (Double.parseDouble(coupon.getPriceStr()) * 100));
}
if (StringUtils.isNotBlank(coupon.getBusiness())) {
String[] arys = coupon.getBusiness().split(",");
wxCoupon.setBusiness(JSON.toJSONString(arys));
}
wxCoupon.setType(coupon.getType());
wxCoupon.setCoverImg(coupon.getCoverImg());
wxCoupon.setTitle(coupon.getTitle());
wxCoupon.setSubTitle(coupon.getSubTitle());
wxCoupon.setUseLimitQuantity(coupon.getUseLimitQuantity());
wxCoupon.setTargetAd(coupon.getTargetAd());
wxCoupon.setSendType(coupon.getSendType());
wxCoupon.setValidType(coupon.getValidType());
wxCoupon.setValidStartDate(coupon.getValidStartDate());
wxCoupon.setValidEndDate(coupon.getValidEndDate());
wxCoupon.setValidDays(coupon.getValidDays());
wxCoupon.setDetail(coupon.getDetail());
wxCoupon.setUnit(coupon.getUnit());
wxCoupon.setRemainInventory(coupon.getRemainInventory());
wxCoupon.setInventory(coupon.getInventory());
wxCoupon.setRemark(coupon.getRemark());
wxCoupon.setStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode());
wxCoupon.setCreateDate(curDate);
wxCoupon.setUpdateDate(curDate);
wxCoupon.setChannels("");
Long id = wxCouponService.saveOrUpdate(wxCoupon);

// Save to wx_coupon_car
WxCouponCar couponCar = new WxCouponCar();
couponCar.setId(id);
couponCar.setTenantId(user.getTenantId());
couponCar.setMerchantId(coupon.getMerchantId());

WxPark park = getCurrentPark(user);
couponCar.setParkId(park.getId());
couponCar.setVendorType(park.getVendorType());
couponCar.setVendorParams(coupon.getVendorParams());
couponCar.setCreateDate(curDate);
couponCar.setUpdateDate(curDate);
WxCouponCar newCouponCar = wxCouponCarService.getById(couponCar.getId());
if (newCouponCar == null) {
wxCouponCarService.save(couponCar);
} else {
wxCouponCarService.update(couponCar);
}


return new ResultData(id);
}


@ApiOperation("优免券模板已分配总数")
@GetMapping("/templateAmtCount")
@ApiImplicitParams({
@ApiImplicitParam(name = "templateId", value = "模板ID", dataType = "Long", paramType = "query", required = true)})
public ResultData getTemplateAmountSum(Long templateId) {
Map map = new HashMap();
Integer amountCount = 0;
try {
amountCount = wxCouponCarService.getAmtCountByTemplateId(templateId);
} catch (Exception e) {
logger.error(e.getMessage());
}
map.put("amountCount", amountCount);
return new ResultData(map);
}

@ApiOperation("优免券模板库存总数")
@GetMapping("/templateAvaiCount")
@ApiImplicitParams({
@ApiImplicitParam(name = "templateId", value = "模板ID", dataType = "Long", paramType = "query", required = true)})
public ResultData getTemplateAvailSum(Long templateId) {
Map map = new HashMap();
Integer availCount = 0;
try {
availCount = wxCouponCarService.getAvaibleCountByTemplateId(templateId);
} catch (Exception e) {
logger.error(e.getMessage());
}
map.put("availCount", availCount);
return new ResultData(map);
}

@ApiOperation("停车券detail")
@GetMapping("/detail")
public ResultData getCouponCarDetail(@ModelAttribute WxCoupon coupon) {
MallUserInfo user = getUser();
coupon.setTenantId(user.getTenantId());
try {
WxCouponCarVo couponCarVo = wxCouponCarService.getByCoupon(coupon);
if (couponCarVo != null) {
WxCouponCarDto dto = new WxCouponCarDto();
org.springframework.beans.BeanUtils.copyProperties(couponCarVo, dto);
WxMerchant merchant = wxMerchantService.getById(couponCarVo.getMerchantId());
dto.setWxMerchant(merchant);
return new ResultData(dto);
} else {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
} catch (Exception e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.DB_FAIL.getCode(), e.getMessage());
}

}


}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxChannelController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxChannel;
import com.iformall.service.WxChannelService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxChannel")
public class WxChannelController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxChannelService wxChannelService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxChannel wxChannel, Integer pageNum, Integer pageSize) {
if (null == wxChannel) wxChannel = new WxChannel();
final PageInfo<WxChannel> page = wxChannelService.listAsPage(wxChannel, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxChannel wxChannel) {
//Assert.notNull(wxChannel.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxChannelService.saveOrUpdate(wxChannel);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxChannel wxChannel) {
wxChannelService.saveOrUpdate(wxChannel);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxChannelService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxChannelService.getById(id));
}


}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponActionLogController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCouponActionLog;
import com.iformall.service.WxCouponActionLogService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxCouponActionLog")
public class WxCouponActionLogController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponActionLogService wxCouponActionLogService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCouponActionLog wxCouponActionLog, Integer pageNum, Integer pageSize) {
if (null == wxCouponActionLog) wxCouponActionLog = new WxCouponActionLog();
final PageInfo<WxCouponActionLog> page = wxCouponActionLogService.listAsPage(wxCouponActionLog, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCouponActionLog wxCouponActionLog) {
//Assert.notNull(wxCouponActionLog.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCouponActionLogService.saveOrUpdate(wxCouponActionLog);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCouponActionLog wxCouponActionLog) {
wxCouponActionLogService.saveOrUpdate(wxCouponActionLog);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCouponActionLogService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCouponActionLogService.getById(id));
}


}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponCarController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCouponCar;
import com.iformall.service.WxCouponCarService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxCouponCar")
public class WxCouponCarController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponCarService wxCouponCarService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCouponCar wxCouponCar, Integer pageNum, Integer pageSize) {
if (null == wxCouponCar) wxCouponCar = new WxCouponCar();
final PageInfo<WxCouponCar> page = wxCouponCarService.listAsPage(wxCouponCar, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCouponCar wxCouponCar) {
//Assert.notNull(wxCouponCar.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCouponCarService.save(wxCouponCar);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCouponCar wxCouponCar) {
wxCouponCarService.update(wxCouponCar);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCouponCarService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCouponCarService.getById(id));
}


}

+ 120
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponChannelController.java Просмотреть файл

@@ -0,0 +1,120 @@
package com.iformall.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxCouponChannelDto;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.service.WxCouponChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;


@RestController
@RequestMapping("wxCouponChannel")
@Api(description = "优惠券投放接口")
public class WxCouponChannelController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponChannelService wxCouponChannelService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCouponChannel wxCouponChannel, Integer pageNum, Integer pageSize) {
if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel();
if (wxCouponChannel.getStatus() != null && wxCouponChannel.getStatus() == -1) {
wxCouponChannel.setStatus(null);
}
wxCouponChannel.setTenantId(getUser().getTenantId());
wxCouponChannel.setSortColumns(WxCouponChannel.Field.Id_DESC);
final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize);
return new ResultData(page);
}


@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) {
wxCouponChannel.setTenantId(getUser().getTenantId());
if (wxCouponChannel.getCouponId() != null && wxCouponChannel.getStatus() != null) {
WxCouponChannel orignal = wxCouponChannelService.getById(wxCouponChannel.getId());
if (orignal.getStatus() == 1 && wxCouponChannel.getStatus() == 0) {
//查找是否该券 在该频道有其他上架
WxCouponChannel query = new WxCouponChannel();
query.setTenantId(orignal.getTenantId());
query.setCouponId(orignal.getCouponId());
query.setStatus(0);//已上架
query.setTargetAd(orignal.getTargetAd());
List<WxCouponChannel> list = wxCouponChannelService.listAsPage(query, 1, 1).getList();
if (list != null && list.size() > 0) {
//不能修改
return new ResultData(Result.ERROR, "不允许同一个券,多个投放");
}
}

}
wxCouponChannelService.saveOrUpdate(wxCouponChannel);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCouponChannelService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCouponChannelService.getById(id));
}

@ApiOperation("批量新增")
@PostMapping("/addbatch")
public ResultData addbatch(@RequestBody WxCouponChannelDto wxCouponChannelDto) {
String[] ids = wxCouponChannelDto.getCouponIds().split(",");
String[] channelId = wxCouponChannelDto.getChannelId().split(",");
MallUserInfo user = getUser();
return wxCouponChannelService.addBatch(ids, channelId, user.getTenantId(), wxCouponChannelDto.getBeginTime(), wxCouponChannelDto.getEndTime());
}

@ApiOperation("根据id查询接口")
@GetMapping("/findChannelByCouponId")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findChannelByCouponId(Long id) {
List<Integer> channellist = new ArrayList<>();
WxCouponChannel wxCouponChannel = new WxCouponChannel();
wxCouponChannel.setTenantId(getTenantId());
wxCouponChannel.setStatus(0);
wxCouponChannel.setCouponId(id);
List<WxCouponChannel> list = wxCouponChannelService.listAsPage(wxCouponChannel, 1, 5).getList();
if (list.isEmpty()) {
return new ResultData(Result.SUCCESS, "查询成功", "");
}
for (WxCouponChannel temp : list) {
channellist.add(temp.getTargetAd());
}
return new ResultData(Result.SUCCESS, "查询成功", JSON.toJSONString(channellist));
}


}

+ 170
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java Просмотреть файл

@@ -0,0 +1,170 @@
package com.iformall.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxCounponDto;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.WxMerchant;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import com.iformall.service.WxMerchantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping("wxCoupon")
@Api(description = "优惠券接口")
public class WxCouponController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponService wxCouponService;

@Autowired
private WxMerchantService wxMerchantService;
@Autowired
private WxCouponChannelService wxCouponChannelService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
if (null == wxCoupon) wxCoupon = new WxCoupon();
wxCoupon.setTenantId(getTenantId());
wxCoupon.setSortColumns(WxCoupon.Field.Id_DESC);
PageInfo<WxCoupon> page = null;
if (wxCoupon.getStatus() != null && wxCoupon.getStatus() == -1)
wxCoupon.setStatus(null);
page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize);

List<WxCoupon> wxCouponList = page.getList();

if (wxCouponList.isEmpty()) {
return new ResultData(page);
}

List<Long> ids = wxCouponList.stream().map(p -> p.getId()).collect(Collectors.toList());
WxCouponChannel wxCouponChannel = new WxCouponChannel();
wxCouponChannel.setTenantId(getTenantId());
wxCouponChannel.setCouponIds(ids);
wxCouponChannel.setStatus(0);
//上架状态
List<WxCouponChannel> list = wxCouponChannelService.listAsPage(wxCouponChannel, 1, 10000).getList();
if (!list.isEmpty()) {
Map<Long, List<WxCouponChannel>> groupBy = list.stream().collect(Collectors.groupingBy(WxCouponChannel::getCouponId));
for (WxCoupon temp : wxCouponList) {

if (groupBy.get(temp.getId()) != null) {
List<Integer> channels = new ArrayList<>();
for (WxCouponChannel tempchannel : groupBy.get(temp.getId())) {
if (!channels.contains(tempchannel.getTargetAd())) {
channels.add(tempchannel.getTargetAd());
}
}
String sss = JSON.toJSONString(channels);
temp.setChannels(sss);
} else {
temp.setChannels("");
}

}
} else {
for (WxCoupon temp : wxCouponList) {
temp.setChannels("");
}

}

return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCoupon wxCoupon) {
//Assert.notNull(wxCoupon.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
if (StringUtils.isNotEmpty(wxCoupon.getSalePriceStr())) {
wxCoupon.setSalePrice((int) (Double.parseDouble(wxCoupon.getSalePriceStr()) * 100));
}
if (StringUtils.isNotEmpty(wxCoupon.getUsePriceStr())) {
wxCoupon.setUsePrice((int) (Double.parseDouble(wxCoupon.getUsePriceStr()) * 100));
}
if (StringUtils.isNotEmpty(wxCoupon.getPriceStr())) {
wxCoupon.setPrice((int) (Double.parseDouble(wxCoupon.getPriceStr()) * 100));
}
if (StringUtils.isNotBlank(wxCoupon.getBusiness())) {
String[] arys = wxCoupon.getBusiness().split(",");
wxCoupon.setBusiness(JSON.toJSONString(arys));
}
wxCoupon.setTenantId(getUser().getTenantId());
wxCoupon.setChannels("");
Long id = wxCouponService.saveOrUpdate(wxCoupon);
return new ResultData(id);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCoupon wxCoupon) {
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
if (StringUtils.isNotBlank(wxCoupon.getBusiness())) {
String[] arys = wxCoupon.getBusiness().split(",");
wxCoupon.setBusiness(JSON.toJSONString(arys));
}
return wxCouponService.updateCoupon(wxCoupon);
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCouponService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
WxCoupon c = wxCouponService.getById(id);
WxCounponDto dto = new WxCounponDto();
org.springframework.beans.BeanUtils.copyProperties(c, dto);
WxMerchant merchant = wxMerchantService.getById(c.getMerchantId());
dto.setWxMerchant(merchant);
return new ResultData(Result.SUCCESS, "查询成功", dto);
}


@ApiOperation("分页列表接口")
@GetMapping("send/list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData sendList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
if (null == wxCoupon) wxCoupon = new WxCoupon();
wxCoupon.setTenantId(getTenantId());
wxCoupon.setStatus(0);

return new ResultData(wxCouponService.listAsPage(wxCoupon, pageNum, pageSize));
}


}

+ 107
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponOrderController.java Просмотреть файл

@@ -0,0 +1,107 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.config.PayProperty;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxCouponOrder;
import com.iformall.enums.EnumAppType;
import com.iformall.enums.EnumRefundWay;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxCouponOrderService;
import com.iformall.service.WxRefundOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping("wxCouponOrder")
@Api(description = "核销和用户卡券查询接口")
public class WxCouponOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponOrderService wxCouponOrderService;

@Autowired
private WxRefundOrderService wxRefundOrderService;

@Autowired
private WxAppinfoService wxAppinfoService;

@Autowired
private PayProperty payProperty;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCouponOrder wxCouponOrder, Integer pageNum, Integer pageSize) {
if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrder();
wxCouponOrder.setTenantId(getTenantId());
wxCouponOrder.setSortColumns(WxCouponOrder.Field.Id_DESC);
return wxCouponOrderService.listAdminAsPage(wxCouponOrder, pageNum, pageSize);
}

@RequestMapping("/exportData")
public void exportData(HttpServletRequest request, HttpServletResponse response) {

wxCouponOrderService.exportData(request, response, getTenantId());

}

@ApiOperation(value = "退券退款", notes = "{\"couponOrderId\":\"string\"}")
@PostMapping("/refund")
public ResultData create(@RequestBody Map<String, String> paramMap) {
//Assert.notNull(wxRefundOrder.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
logger.info(paramMap.toString());
String couponOrderIdStr = paramMap.get("couponOrderId");
if (StringUtils.isBlank(couponOrderIdStr)) {
logger.error("couponOrderId不能为空: " + paramMap.toString());
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
Long couponOrderId = 0L;
try {
couponOrderId = Long.valueOf(couponOrderIdStr);
} catch (NumberFormatException e) {
logger.error("couponOrderId参数不正确: " + paramMap.toString());
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

WxAppinfo appinfoQ = new WxAppinfo();
appinfoQ.setTenantId(getTenantId());
appinfoQ.setType(EnumAppType.B.getCode());
PageInfo<WxAppinfo> appinfoPageInfo = wxAppinfoService.listAsPage(appinfoQ, 1, 1);
if (appinfoPageInfo.getList().size() > 0) {
WxAppinfo appinfo = appinfoPageInfo.getList().get(0);
if (appinfo != null) {
try {
wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, couponOrderId, EnumRefundWay.ADMIN, null);
return new ResultData();
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.REFUND_ORDER_ERROR);
}
}
}
return new ResultData(ErrorCode.REFUND_ORDER_ERROR.getCode(), "AppInfo获取失败");
}

}

+ 102
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponSendController.java Просмотреть файл

@@ -0,0 +1,102 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponSend;
import com.iformall.enums.EnumCouponSendType;
import com.iformall.enums.EnumCouponStatus;
import com.iformall.service.WxCouponSendService;
import com.iformall.service.WxCouponService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("wxCouponSend")
public class WxCouponSendController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponSendService wxCouponSendService;
@Autowired
private WxCouponService wxCouponService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) {
if (null == wxCouponSend) wxCouponSend = new WxCouponSend();
wxCouponSend.setTenantId(getTenantId());
final PageInfo<WxCouponSend> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCouponSend wxCouponSend) {
if (null == wxCouponSend) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}
wxCouponSend.setTenantId(getTenantId());
wxCouponSend.setStatus(0);
List<WxCouponSend> wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend, 1, 1).getList();
if (wxCouponSendList != null && wxCouponSendList.size() > 0) {
return new ResultData(ErrorCode.COUPON_SEND_IS_EXISTED);
}
WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId());
if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()){
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF);
}

if (wxCoupon.getSendType() != EnumCouponSendType.PASSIVE.getCode()) {
return new ResultData(ErrorCode.COUPON_TYPE_IS_NOT_PASSIVE);
}


wxCouponSend.setMerchantId(wxCoupon.getMerchantId());
wxCouponSend.setType(wxCoupon.getType());
wxCouponSend.setTenantId(wxCoupon.getTenantId());
wxCouponSend.setTitle(wxCoupon.getTitle());

//Assert.notNull(wxCouponSend.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCouponSendService.saveOrUpdate(wxCouponSend);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCouponSend wxCouponSend) {
wxCouponSend.setTenantId(getTenantId());
wxCouponSendService.saveOrUpdate(wxCouponSend);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCouponSendService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCouponSendService.getById(id));
}


}

+ 90
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponSpreadController.java Просмотреть файл

@@ -0,0 +1,90 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCouponSpread;
import com.iformall.service.WxCouponSpreadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("wxCouponSpread")
@Api(description = "推广接口")
public class WxCouponSpreadController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponSpreadService wxCouponSpreadService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCouponSpread wxCouponSpread, Integer pageNum, Integer pageSize) {
if (null == wxCouponSpread) wxCouponSpread = new WxCouponSpread();
final PageInfo<WxCouponSpread> page = wxCouponSpreadService.listAsPage(wxCouponSpread, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCouponSpread wxCouponSpread) {
if (wxCouponSpread.getCouponId() == null) {
return new ResultData(Result.ERROR, "没有找到券id");
}
//Assert.notNull(wxCouponSpread.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCouponSpreadService.saveOrUpdate(wxCouponSpread);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCouponSpread wxCouponSpread) {
wxCouponSpreadService.saveOrUpdate(wxCouponSpread);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCouponSpreadService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCouponSpreadService.getById(id));
}

@ApiOperation("根据卡券id查询接口")
@GetMapping("/findByCouponId")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findByCouponId(Long id) {
WxCouponSpread result = null;
if (id != null) {
WxCouponSpread wxCouponSpread = new WxCouponSpread();
wxCouponSpread.setCouponId(id);
List<WxCouponSpread> list = wxCouponSpreadService.findList(wxCouponSpread);
if (!list.isEmpty()) {
result = list.get(0);
}
}
return new ResultData(Result.SUCCESS, "查询成功", result);
}


}

+ 69
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponTypeController.java Просмотреть файл

@@ -0,0 +1,69 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCouponType;
import com.iformall.service.WxCouponTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxCouponType")
@Api(description = "优惠券类型相关接口")
public class WxCouponTypeController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponTypeService wxCouponTypeService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCouponType wxCouponType, Integer pageNum, Integer pageSize) {
if (null == wxCouponType) wxCouponType = new WxCouponType();
final PageInfo<WxCouponType> page = wxCouponTypeService.listAsPage(wxCouponType, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCouponType wxCouponType) {
//Assert.notNull(wxCouponType.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCouponTypeService.saveOrUpdate(wxCouponType);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCouponType wxCouponType) {
wxCouponTypeService.saveOrUpdate(wxCouponType);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxCouponTypeService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCouponTypeService.getById(id));
}


}

+ 61
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxGroupController.java Просмотреть файл

@@ -0,0 +1,61 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxGroup;
import com.iformall.service.WxGroupService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxGroup")
public class WxGroupController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxGroupService wxGroupService;

@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxGroup wxGroup, Integer pageNum, Integer pageSize) {
if (null == wxGroup) wxGroup = new WxGroup();
final PageInfo<WxGroup> page = wxGroupService.listAsPage(wxGroup, pageNum, pageSize);
return new ResultData(page);
}

@PostMapping("add")
public ResultData add(@RequestBody WxGroup wxGroup) {
//Assert.notNull(wxGroup.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxGroupService.saveOrUpdate(wxGroup);
return new ResultData();
}

@PostMapping("update")
public ResultData update(@RequestBody WxGroup wxGroup) {
wxGroupService.saveOrUpdate(wxGroup);
return new ResultData();
}

@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
public ResultData delete(String id) {
wxGroupService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
public ResultData findById(String id) {
return new ResultData(Result.SUCCESS, "查询成功", wxGroupService.getById(id));
}


}

+ 91
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxLevelConfigController.java Просмотреть файл

@@ -0,0 +1,91 @@
package com.iformall.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
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 com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxLevelConfigDto;
import com.iformall.domain.po.WxLevelConfig;
import com.iformall.service.WxLevelConfigService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxLevelConfig")
@Api(description="等级权益相关接口")
public class WxLevelConfigController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxLevelConfigService wxLevelConfigService;
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxLevelConfig wxLevelConfig,Integer pageNum, Integer pageSize) {
if (null == wxLevelConfig) wxLevelConfig = new WxLevelConfig();
final PageInfo<WxLevelConfig> page = wxLevelConfigService.listAsPage(wxLevelConfig, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxLevelConfigDto dto) {
//Assert.notNull(wxLevelConfig.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
String[] points = dto.getPoints().split("&");
String[] level = dto.getLevel().split("&");
String[] descs =dto.getDescription().split("&");
String tenantId = getTenantId();
wxLevelConfigService.deleteAll();
for(int i=0;i<points.length;i++) {
WxLevelConfig wxLevelConfig = new WxLevelConfig();
wxLevelConfig.setTenantId(tenantId);
wxLevelConfig.setPoints(Integer.parseInt(points[i]));
wxLevelConfig.setLevel(level[i]);
wxLevelConfig.setDescription(descs[i]);
wxLevelConfigService.saveOrUpdate(wxLevelConfig);
}
return new ResultData();
}

// @ApiOperation("根据id更新接口")
// @PostMapping("update")
// public ResultData update(@RequestBody WxLevelConfig wxLevelConfig) {
// wxLevelConfig.setTenantId(getTenantId());
// wxLevelConfigService.saveOrUpdate(wxLevelConfig);
// return new ResultData();
// }

@ApiOperation("根据id删除接口")
@PostMapping("/del")
// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(@RequestBody WxLevelConfig wxLevelConfig) {
wxLevelConfigService.deleteById(wxLevelConfig.getId());
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxLevelConfigService.getById(id));
}
}

+ 74
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMallApplyController.java Просмотреть файл

@@ -0,0 +1,74 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMallApply;
import com.iformall.domain.po.WxMsgValidationcode;
import com.iformall.service.WxMallApplyService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMallApply")
public class WxMallApplyController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMallApplyService wxMallApplyService;

@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMallApply wxMallApply, Integer pageNum, Integer pageSize) {
if (null == wxMallApply) wxMallApply = new WxMallApply();
final PageInfo<WxMallApply> page = wxMallApplyService.listAsPage(wxMallApply, pageNum, pageSize);
return new ResultData(page);
}

@PostMapping("add")
public ResultData add(@RequestBody WxMallApply wxMallApply) {
//Assert.notNull(wxMallApply.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
return wxMallApplyService.saveOrUpdate(wxMallApply);

}

@PostMapping("update")
public ResultData update(@RequestBody WxMallApply wxMallApply) {
return wxMallApplyService.saveOrUpdate(wxMallApply);
}

@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
public ResultData delete(String id) {
wxMallApplyService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
public ResultData findById(String id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMallApplyService.getById(id));
}


@GetMapping("/sendvalidationcode")
@ApiImplicitParams({
@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true),
@ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true)})
public ResultData sendvalidationcode(String phone, Integer type) {
WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode();
wxMsgValidationcode.setTenantId("1");
wxMsgValidationcode.setPhone(phone);
wxMsgValidationcode.setType(type);
return wxMallApplyService.sendvalidationcode(wxMsgValidationcode);
}


}

+ 81
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMallBuildingController.java Просмотреть файл

@@ -0,0 +1,81 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMallBuilding;
import com.iformall.service.WxMallBuildingService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMallBuilding")
public class WxMallBuildingController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMallBuildingService wxMallBuildingService;
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxMallBuilding wxMallBuilding,Integer pageNum, Integer pageSize) {
if (null == wxMallBuilding) wxMallBuilding = new WxMallBuilding();
final PageInfo<WxMallBuilding> page = wxMallBuildingService.listAsPage(wxMallBuilding, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMallBuilding wxMallBuilding) {
//Assert.notNull(wxMallBuilding.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMallBuildingService.saveOrUpdate(wxMallBuilding);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMallBuilding wxMallBuilding) {
wxMallBuildingService.saveOrUpdate(wxMallBuilding);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxMallBuildingService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxMallBuildingService.getById(id));
}


@ApiOperation("获取所有数据")
@GetMapping("getbuildinglist")
public ResultData getbuildinglist() {
return wxMallBuildingService.getbuildinglist(getTenantId());
}

@ApiOperation("获取楼层楼座数据")
@GetMapping("getbuildingfloorlist")
public ResultData getbuildingfloorlist() {
return wxMallBuildingService.getbuildingfloorlist(getTenantId());
}



}

+ 116
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMallConfigController.java Просмотреть файл

@@ -0,0 +1,116 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMallConfig;
import com.iformall.service.WxMallConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMallConfig")
@Api(description = "停车发券和核销发劵接口")
public class WxMallConfigController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMallConfigService wxMallConfigService;

@ApiOperation("获取停车劵开关")
@GetMapping("getStopCarConpon")
public ResultData getStopCarConpon() {
WxMallConfig wxMallConfig = new WxMallConfig();
wxMallConfig.setKey("stopCarCouponSwitch");
wxMallConfig.setTenantId(getTenantId());
PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1);
if (page.getSize() > 0) {
WxMallConfig config = page.getList().get(0);
return new ResultData(config);
}
return new ResultData();
}

@ApiOperation("获取核销劵开关")
@GetMapping("getVerifyConpon")
public ResultData getVerifyConpon() {
WxMallConfig wxMallConfig = new WxMallConfig();
wxMallConfig.setKey("verifyConponSwitch");
wxMallConfig.setTenantId(getTenantId());
PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1);
if (page.getSize() > 0) {
WxMallConfig config = page.getList().get(0);
return new ResultData(config);
}
return new ResultData();
}

@PostMapping("updateStopCarConpon")
@ApiOperation("修改停车开关")
public ResultData updateStopCarConpon(@RequestBody WxMallConfig wxMallConfig) {
WxMallConfig temp = new WxMallConfig();
// temp.setKey("stopCarCouponSwitch");
temp.setValue(wxMallConfig.getValue());
temp.setId(wxMallConfig.getId());
wxMallConfigService.saveOrUpdate(temp);
return new ResultData();
}

@PostMapping("updateVerifyConpon")
@ApiOperation("修改核销开关")
public ResultData updateVerifyConpon(@RequestBody WxMallConfig wxMallConfig) {
WxMallConfig temp = new WxMallConfig();
// temp.setKey("verifyConponSwitch");
temp.setValue(wxMallConfig.getValue());
temp.setId(wxMallConfig.getId());
wxMallConfigService.saveOrUpdate(temp);
return new ResultData();
}

// @ApiOperation("分页列表接口")
// @GetMapping("list")
// @ApiImplicitParams({
// @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
// @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
// public ResultData list(@ModelAttribute WxMallConfig wxMallConfig,Integer pageNum, Integer pageSize) {
// if (null == wxMallConfig) wxMallConfig = new WxMallConfig();
// final PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, pageNum, pageSize);
// return new ResultData(page);
// }
//
// @ApiOperation("新增接口")
// @PostMapping("add")
// public ResultData add(@RequestBody WxMallConfig wxMallConfig) {
// //Assert.notNull(wxMallConfig.getName(), "角色名不能为空");
// //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
// wxMallConfigService.saveOrUpdate(wxMallConfig);
// return new ResultData();
// }
//
// @ApiOperation("根据id更新接口")
// @PostMapping("update")
// public ResultData update(@RequestBody WxMallConfig wxMallConfig) {
// wxMallConfigService.saveOrUpdate(wxMallConfig);
// return new ResultData();
// }
//
// @ApiOperation("根据id删除接口")
// @GetMapping("/del")
// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
// public ResultData delete(Long id) {
// wxMallConfigService.deleteById(id);
// return new ResultData(Result.SUCCESS, "删除成功", null);
// }
//
// @ApiOperation("根据id查询接口")
// @GetMapping("/findById")
// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
// public ResultData findById(Long id) {
// return new ResultData(Result.SUCCESS,"查询成功",wxMallConfigService.getById(id));
// }


}

+ 70
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMallController.java Просмотреть файл

@@ -0,0 +1,70 @@
package com.iformall.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;

import com.iformall.domain.po.WxMall;
import com.iformall.service.WxMallService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxMall")
public class WxMallController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMallService wxMallService;
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxMall wxMall,Integer pageNum, Integer pageSize) {
if (null == wxMall) wxMall = new WxMall();
final PageInfo<WxMall> page = wxMallService.listAsPage(wxMall, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMall wxMall) {
//Assert.notNull(wxMall.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMallService.saveOrUpdate(wxMall);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMall wxMall) {
wxMallService.saveOrUpdate(wxMall);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxMallService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxMallService.getById(id));
}
}

+ 77
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMallFloorController.java Просмотреть файл

@@ -0,0 +1,77 @@
package com.iformall.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;

import com.iformall.domain.po.WxMallFloor;
import com.iformall.service.WxMallFloorService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxMallFloor")
public class WxMallFloorController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMallFloorService wxMallFloorService;
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxMallFloor wxMallFloor,Integer pageNum, Integer pageSize) {
if (null == wxMallFloor) wxMallFloor = new WxMallFloor();
final PageInfo<WxMallFloor> page = wxMallFloorService.listAsPage(wxMallFloor, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMallFloor wxMallFloor) {
//Assert.notNull(wxMallFloor.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMallFloorService.saveOrUpdate(wxMallFloor);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMallFloor wxMallFloor) {
wxMallFloorService.saveOrUpdate(wxMallFloor);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxMallFloorService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxMallFloorService.getById(id));
}

@ApiOperation("获取所有数据")
@GetMapping("getfloorlist")
@ApiImplicitParams({
@ApiImplicitParam(name="buildingId",value="楼座ID",dataType="Long", paramType = "query",required=true)})
public ResultData getfloorlist(Long buildingId){
return wxMallFloorService.getfloorlist(getTenantId(),buildingId);
}


}

+ 75
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantBUserController.java Просмотреть файл

@@ -0,0 +1,75 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMerchantBUser;
import com.iformall.service.WxMerchantBUserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMerchantBUser")
public class WxMerchantBUserController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMerchantBUserService wxMerchantBUserService;
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxMerchantBUser wxMerchantBUser,Integer pageNum, Integer pageSize) {
if (null == wxMerchantBUser) wxMerchantBUser = new WxMerchantBUser();
final PageInfo<WxMerchantBUser> page = wxMerchantBUserService.listAsPage(wxMerchantBUser, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMerchantBUser wxMerchantBUser) {
//Assert.notNull(wxMerchantBUser.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMerchantBUser.setTenantId(getTenantId());
Long id = wxMerchantBUserService.saveOrUpdate(wxMerchantBUser);
return new ResultData(Result.SUCCESS,"添加成功",id);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMerchantBUser wxMerchantBUser) {
Long id = wxMerchantBUserService.saveOrUpdate(wxMerchantBUser);
return new ResultData(Result.SUCCESS,"更新成功",id);
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxMerchantBUserService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxMerchantBUserService.getById(id));
}

@ApiOperation("手机号是否存在")
@GetMapping("/hasphone")
@ApiImplicitParam(name="phone",value="phone",dataType="String", paramType = "query",required=true)
public ResultData hasphone(String phone) {
boolean has=wxMerchantBUserService.hasphone(phone);
return new ResultData(Result.SUCCESS,"查询成功",has);
}
}

+ 103
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantController.java Просмотреть файл

@@ -0,0 +1,103 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxProfitSharingReceiver;
import com.iformall.service.WxMerchantService;
import com.iformall.service.WxProfitSharingReceiverService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("wxMerchant")
public class WxMerchantController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMerchantService wxMerchantService;

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) {
if (null == wxMerchant) wxMerchant = new WxMerchant();
wxMerchant.setTenantId(getTenantId());
wxMerchant.setSortColumns(WxMerchant.Field.Id_DESC);
final PageInfo<WxMerchant> page = wxMerchantService.listAsPage(wxMerchant, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("ETCP商户列表")
@GetMapping("etcplist")
public ResultData etcpList(@ModelAttribute WxMerchant wxMerchant) {
if (null == wxMerchant) wxMerchant = new WxMerchant();
wxMerchant.setTenantId(getTenantId());
final List<WxMerchant> merchantList = wxMerchantService.etcpList(wxMerchant);
return new ResultData(merchantList);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMerchant wxMerchant) {
//Assert.notNull(wxMerchant.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMerchant.setTenantId(getTenantId());
wxMerchantService.saveOrUpdate(wxMerchant);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMerchant wxMerchant) {
wxMerchantService.saveOrUpdate(wxMerchant);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxMerchantService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
WxMerchant wxMerchant = new WxMerchant();
wxMerchant = wxMerchantService.getById(id);
if (wxMerchant != null) {
WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(wxMerchant);
if (receiver != null){
wxMerchant.setAccountId(receiver.getReceiverAccount());
wxMerchant.setAccountName(receiver.getTrueName());
wxMerchant.setAccountTypeValue(receiver.getReceiverType());
}
}
return new ResultData(wxMerchant);
}

@ApiOperation("停用")
@GetMapping("disable")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData disable(Long id) {
wxMerchantService.disable(id);
return new ResultData(Result.SUCCESS, "停用成功");
}

}

+ 80
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantShopController.java Просмотреть файл

@@ -0,0 +1,80 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMerchantShop;
import com.iformall.domain.po.WxShop;
import com.iformall.service.WxMerchantShopService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMerchantShop")
public class WxMerchantShopController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMerchantShopService wxMerchantShopService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMerchantShop wxMerchantShop, Integer pageNum, Integer pageSize) {
if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop();
final PageInfo<WxMerchantShop> page = wxMerchantShopService.listAsPage(wxMerchantShop, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("获取关联商铺信息")
@GetMapping("queryShopList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData queryShopList(@ModelAttribute WxMerchantShop wxMerchantShop, Integer pageNum, Integer pageSize) {
if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop();
final PageInfo<WxShop> page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize);
return new ResultData(page);
}


@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMerchantShop wxMerchantShop) {
//Assert.notNull(wxMerchantShop.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMerchantShopService.saveOrUpdate(wxMerchantShop);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMerchantShop wxMerchantShop) {
wxMerchantShopService.saveOrUpdate(wxMerchantShop);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxMerchantShopService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMerchantShopService.getById(id));
}


}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantTradeDailyController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMerchantTradeDaily;
import com.iformall.service.WxMerchantTradeDailyService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMerchantTradeDaily")
public class WxMerchantTradeDailyController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMerchantTradeDailyService wxMerchantTradeDailyService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMerchantTradeDaily wxMerchantTradeDaily, Integer pageNum, Integer pageSize) {
if (null == wxMerchantTradeDaily) wxMerchantTradeDaily = new WxMerchantTradeDaily();
final PageInfo<WxMerchantTradeDaily> page = wxMerchantTradeDailyService.listAsPage(wxMerchantTradeDaily, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMerchantTradeDaily wxMerchantTradeDaily) {
//Assert.notNull(wxMerchantTradeDaily.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMerchantTradeDailyService.saveOrUpdate(wxMerchantTradeDaily);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMerchantTradeDaily wxMerchantTradeDaily) {
wxMerchantTradeDailyService.saveOrUpdate(wxMerchantTradeDaily);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxMerchantTradeDailyService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMerchantTradeDailyService.getById(id));
}


}

+ 97
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMsgCallbackController.java Просмотреть файл

@@ -0,0 +1,97 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMsgCallback;
import com.iformall.service.WxMsgCallbackService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("wxMsgCallback")
public class WxMsgCallbackController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMsgCallbackService wxMsgCallbackService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMsgCallback wxMsgCallback, Integer pageNum, Integer pageSize) {
if (null == wxMsgCallback) wxMsgCallback = new WxMsgCallback();
wxMsgCallback.setTenantId(getTenantId());
final PageInfo<WxMsgCallback> page = wxMsgCallbackService.listAsPage(wxMsgCallback, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMsgCallback wxMsgCallback) {
//Assert.notNull(wxMsgCallback.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMsgCallback.setTenantId(getTenantId());
wxMsgCallbackService.saveOrUpdate(wxMsgCallback);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMsgCallback wxMsgCallback) {
wxMsgCallbackService.saveOrUpdate(wxMsgCallback);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxMsgCallbackService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMsgCallbackService.getById(id));
}


@PostMapping(value = "/receivemsg/{tenantId}")
public void receivemsg(@PathVariable String tenantId, @RequestParam Map<String, String> param) {
logger.info(param.toString());
//解析param数据插入数据库中
String item = param.get("item");
String sign = param.get("sign");
wxMsgCallbackService.saveOrUpdate(tenantId, item, sign);

}

@RequestMapping(value = "/receivemodel/{tenantId}")
public void receivemodel(@PathVariable String tenantId, @RequestParam Map<String, String> param) {
logger.info(param.toString());
//解析param数据插入数据库中
wxMsgCallbackService.receivemodel(tenantId, param);

}

@RequestMapping(value = "/receiveverifymodel/{tenantId}")
public void receiveverifymodel(@PathVariable String tenantId, @RequestParam Map<String, String> param) {
logger.info(param.toString());
//解析param数据插入数据库中
wxMsgCallbackService.receiveverifymodel(tenantId, param);

}

}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMsgConfigController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMsgConfig;
import com.iformall.service.WxMsgConfigService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMsgConfig")
public class WxMsgConfigController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMsgConfigService wxMsgConfigService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMsgConfig wxMsgConfig, Integer pageNum, Integer pageSize) {
if (null == wxMsgConfig) wxMsgConfig = new WxMsgConfig();
final PageInfo<WxMsgConfig> page = wxMsgConfigService.listAsPage(wxMsgConfig, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMsgConfig wxMsgConfig) {
//Assert.notNull(wxMsgConfig.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMsgConfigService.saveOrUpdate(wxMsgConfig);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMsgConfig wxMsgConfig) {
wxMsgConfigService.saveOrUpdate(wxMsgConfig);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxMsgConfigService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMsgConfigService.getById(id));
}


}

+ 99
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMsgController.java Просмотреть файл

@@ -0,0 +1,99 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMsg;
import com.iformall.service.WxMsgService;
import com.iformall.utils.Constant;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileOutputStream;
import java.util.UUID;

@RestController
@RequestMapping("wxMsg")
public class WxMsgController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMsgService wxMsgService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMsg wxMsg, Integer pageNum, Integer pageSize) {
if (null == wxMsg) wxMsg = new WxMsg();
wxMsg.setTenantId(getTenantId());
final PageInfo<WxMsg> page = wxMsgService.listAsPage(wxMsg, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMsg wxMsg) {
//Assert.notNull(wxMsg.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMsg.setTenantId(getTenantId());
wxMsgService.saveOrUpdate(wxMsg);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMsg wxMsg) {
wxMsgService.saveOrUpdate(wxMsg);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxMsgService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMsgService.getById(id));
}


@RequestMapping("/excleupload")
public ResultData excleupload(@RequestParam("file") MultipartFile file) {
if (file.isEmpty()) {
return new ResultData(Result.SUCCESS, "上传文件不能为空");
}

String filename = UUID.randomUUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
File path = new File(Constant.fileDirectory);
if (!path.exists()) {
path.mkdirs();
}
String filepath = Constant.fileDirectory + File.separator + filename;
try {
FileOutputStream out = new FileOutputStream(new File(filepath));
IOUtils.write(file.getBytes(), out);
IOUtils.closeQuietly(out);
} catch (Exception e) {
return new ResultData(Result.ERROR, "上传失败");
}

return new ResultData(Result.SUCCESS, "上传成功", filepath);
}

}

+ 74
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMsgModelController.java Просмотреть файл

@@ -0,0 +1,74 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMsgModel;
import com.iformall.service.WxMsgModelService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMsgModel")
public class WxMsgModelController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMsgModelService wxMsgModelService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMsgModel wxMsgModel, Integer pageNum, Integer pageSize) {
if (null == wxMsgModel) wxMsgModel = new WxMsgModel();
wxMsgModel.setTenantId(getTenantId());
final PageInfo<WxMsgModel> page = wxMsgModelService.listAsPage(wxMsgModel, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMsgModel wxMsgModel) {
//Assert.notNull(wxMsgModel.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMsgModel.setTenantId(getTenantId());
return wxMsgModelService.saveOrUpdate(wxMsgModel);

}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMsgModel wxMsgModel) {
return wxMsgModelService.saveOrUpdate(wxMsgModel);
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxMsgModelService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMsgModelService.getById(id));
}

@ApiOperation("获取所有数据")
@GetMapping("getmodellist")
public ResultData getmodellist() {
return wxMsgModelService.getmodellist(getTenantId());
}


}

+ 74
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMsgSignatureController.java Просмотреть файл

@@ -0,0 +1,74 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMsgSignature;
import com.iformall.service.WxMsgSignatureService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMsgSignature")
public class WxMsgSignatureController extends BaseController {
@Autowired
private WxMsgSignatureService wxMsgSignatureService;

private Logger logger = Logger.getLogger(WxMsgSignatureController.class);

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMsgSignature wxMsgSignature, Integer pageNum, Integer pageSize) {
if (null == wxMsgSignature) wxMsgSignature = new WxMsgSignature();
wxMsgSignature.setTenantId(getTenantId());
final PageInfo<WxMsgSignature> page = wxMsgSignatureService.listAsPage(wxMsgSignature, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMsgSignature wxMsgSignature) {
//Assert.notNull(wxMsgSignature.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMsgSignature.setTenantId(getTenantId());
wxMsgSignatureService.saveOrUpdate(wxMsgSignature);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxMsgSignature wxMsgSignature) {
wxMsgSignatureService.saveOrUpdate(wxMsgSignature);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxMsgSignatureService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMsgSignatureService.getById(id));
}

@ApiOperation("获取所有数据")
@GetMapping("getsignaturelist")
public ResultData getmodellist() {
return wxMsgSignatureService.getsignaturelist(getTenantId());
}


}

+ 95
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java Просмотреть файл

@@ -0,0 +1,95 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMsgValidationcode;
import com.iformall.service.WxMsgValidationcodeService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMsgValidationcode")
public class WxMsgValidationcodeController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMsgValidationcodeService wxMsgValidationcodeService;

@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxMsgValidationcode wxMsgValidationcode,Integer pageNum, Integer pageSize) {
if (null == wxMsgValidationcode) wxMsgValidationcode = new WxMsgValidationcode();
final PageInfo<WxMsgValidationcode> page = wxMsgValidationcodeService.listAsPage(wxMsgValidationcode, pageNum, pageSize);
return new ResultData(page);
}

@PostMapping("add")
public ResultData add(@RequestBody WxMsgValidationcode wxMsgValidationcode) {
//Assert.notNull(wxMsgValidationcode.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMsgValidationcodeService.saveOrUpdate(wxMsgValidationcode);
return new ResultData();
}

@PostMapping("update")
public ResultData update(@RequestBody WxMsgValidationcode wxMsgValidationcode) {
wxMsgValidationcodeService.saveOrUpdate(wxMsgValidationcode);
return new ResultData();
}

@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxMsgValidationcodeService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxMsgValidationcodeService.getById(id));
}



@GetMapping("sendvalidationcode")
@ApiImplicitParams({
@ApiImplicitParam(name="tenantId",value="租户ID",dataType="String", paramType = "query"),
@ApiImplicitParam(name="phone",value="手机号",dataType="String", paramType = "query",required=true),
@ApiImplicitParam(name="type",value="场景",dataType="Integer", paramType = "query",required=true),
@ApiImplicitParam(name="appid",value="appid",dataType="String", paramType = "query",required=true)})
public ResultData sendvalidationcode(String tenantId,String phone,Integer type,String appid) {
WxMsgValidationcode wxMsgValidationcode =new WxMsgValidationcode();
wxMsgValidationcode.setTenantId(tenantId);
wxMsgValidationcode.setPhone(phone);
wxMsgValidationcode.setType(type);
wxMsgValidationcode.setAppid(appid);
return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode);
}

@GetMapping("hasvalidationcode")
@ApiImplicitParams({
@ApiImplicitParam(name="tenantId",value="租户ID",dataType="String", paramType = "query"),
@ApiImplicitParam(name="phone",value="手机号",dataType="String", paramType = "query",required=true),
@ApiImplicitParam(name="type",value="场景",dataType="Integer", paramType = "query",required=true),
@ApiImplicitParam(name="code",value="验证码",dataType="String", paramType = "query",required=true),
@ApiImplicitParam(name="appid",value="appid",dataType="String", paramType = "query",required=true)})
public ResultData hasvalidationcode(String tenantId,String phone,Integer type,String code,String appid) {
WxMsgValidationcode wxMsgValidationcode =new WxMsgValidationcode();
wxMsgValidationcode.setTenantId(tenantId);
wxMsgValidationcode.setPhone(phone);
wxMsgValidationcode.setType(type);
wxMsgValidationcode.setCode(code);
wxMsgValidationcode.setAppid(appid);
return wxMsgValidationcodeService.hasvalidationcode(wxMsgValidationcode);
}

}

+ 61
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxMsgValidationcodeModelController.java Просмотреть файл

@@ -0,0 +1,61 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMsgValidationcodeModel;
import com.iformall.service.WxMsgValidationcodeModelService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMsgValidationcodeModel")
public class WxMsgValidationcodeModelController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMsgValidationcodeModelService wxMsgValidationcodeModelService;

@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxMsgValidationcodeModel wxMsgValidationcodeModel, Integer pageNum, Integer pageSize) {
if (null == wxMsgValidationcodeModel) wxMsgValidationcodeModel = new WxMsgValidationcodeModel();
final PageInfo<WxMsgValidationcodeModel> page = wxMsgValidationcodeModelService.listAsPage(wxMsgValidationcodeModel, pageNum, pageSize);
return new ResultData(page);
}

@PostMapping("add")
public ResultData add(@RequestBody WxMsgValidationcodeModel wxMsgValidationcodeModel) {
//Assert.notNull(wxMsgValidationcodeModel.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");

return wxMsgValidationcodeModelService.saveOrUpdate(wxMsgValidationcodeModel);
}

@PostMapping("update")
public ResultData update(@RequestBody WxMsgValidationcodeModel wxMsgValidationcodeModel) {
wxMsgValidationcodeModelService.saveOrUpdate(wxMsgValidationcodeModel);
return new ResultData();
}

@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
public ResultData delete(String id) {
wxMsgValidationcodeModelService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
public ResultData findById(String id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMsgValidationcodeModelService.getById(id));
}


}

+ 74
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxOrderController.java Просмотреть файл

@@ -0,0 +1,74 @@
package com.iformall.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;

import com.iformall.domain.po.WxOrder;
import com.iformall.service.WxOrderService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxOrder")
public class WxOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxOrderService wxOrderService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "status", value = "订单状态:-1全部;0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款);3-未退款/待退款;4-已退款;5-退款失败", defaultValue = "0", required = false, dataType = "Integer")
})
public ResultData list(@ModelAttribute WxOrder wxOrder, Integer pageNum, Integer pageSize) {
if (null == wxOrder) wxOrder = new WxOrder();
wxOrder.setTenantId(getTenantId());
wxOrder.setSortColumns(WxOrder.Field.Id_DESC);
final PageInfo<WxOrder> page = wxOrderService.listAsPage(wxOrder, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxOrder wxOrder) {
//Assert.notNull(wxOrder.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxOrderService.saveOrUpdate(wxOrder);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxOrder wxOrder) {
wxOrderService.saveOrUpdate(wxOrder);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxOrderService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxOrderService.getById(id));
}
}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxParkController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxPark;
import com.iformall.service.WxParkService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxPark")
public class WxParkController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxParkService wxParkService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxPark wxPark, Integer pageNum, Integer pageSize) {
if (null == wxPark) wxPark = new WxPark();
final PageInfo<WxPark> page = wxParkService.listAsPage(wxPark, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxPark wxPark) {
//Assert.notNull(wxPark.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxParkService.saveOrUpdate(wxPark);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxPark wxPark) {
wxParkService.saveOrUpdate(wxPark);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxParkService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxParkService.getById(id));
}


}

+ 70
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxPayAccountController.java Просмотреть файл

@@ -0,0 +1,70 @@
package com.iformall.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;

import com.iformall.domain.po.WxPayAccount;
import com.iformall.service.WxPayAccountService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxPayAccount")
public class WxPayAccountController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxPayAccountService wxPayAccountService;
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxPayAccount wxPayAccount,Integer pageNum, Integer pageSize) {
if (null == wxPayAccount) wxPayAccount = new WxPayAccount();
final PageInfo<WxPayAccount> page = wxPayAccountService.listAsPage(wxPayAccount, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxPayAccount wxPayAccount) {
//Assert.notNull(wxPayAccount.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxPayAccountService.saveOrUpdate(wxPayAccount);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxPayAccount wxPayAccount) {
wxPayAccountService.saveOrUpdate(wxPayAccount);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxPayAccountService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxPayAccountService.getById(id));
}
}

+ 183
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxPayController.java Просмотреть файл

@@ -0,0 +1,183 @@
package com.iformall.controller;

import com.iformall.enums.EnumPayWay;
import com.iformall.exception.BizMessageException;
import com.iformall.exception.MallinkException;
import com.iformall.pay.WxPayment;
import com.iformall.service.WxPayOrderService;
import com.iformall.service.WxProfitSharingOrderService;
import com.iformall.service.WxRefundOrderService;
import com.iformall.utils.XmlUtil;
import org.apache.commons.io.IOUtils;
import org.jdom.JDOMException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

@RestController
@RequestMapping("/wxPay/notify")
public class WxPayController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxPayOrderService wxPayOrderService;

@Autowired
private WxRefundOrderService wxRefundOrderService;

@Autowired
private WxProfitSharingOrderService wxProfitSharingOrderService;

/**
*
* @return 接收微信异步通知
* @throws Exception 可能产生的任何异常
*/
@RequestMapping(value = "/pay", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public String _payNotify(HttpServletRequest request) throws IOException, JDOMException {
logger.info("微信支付回调");
InputStream inStream = request.getInputStream();
ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = inStream.read(buffer)) != -1) {
outSteam.write(buffer, 0, len);
}
String resultxml = new String(outSteam.toByteArray(), Charset.forName("UTF-8"));
logger.info(resultxml);

outSteam.close();
inStream.close();

Map<String, String> paramMap = null;

try {
paramMap = WxPayment.xmlToMap(resultxml);
logger.info("微信支付回调, notify, param: " + paramMap.toString() );
String response = wxPayOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP);
logger.info("微信支付回调, notify success, req : " + resultxml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
if (paramMap == null) {
logger.error("微信支付回调, order create error, e: " + e.getMessage());
} else {
logger.error("微信支付回调, order create error, req: " + resultxml + ", e: " + e.getMessage());
}
SortedMap resultMap = new TreeMap<>();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.getRequestXml(resultMap);
} catch (MallinkException e) {
if (paramMap == null) {
logger.error("微信支付回调, order create error, e: " + e.getMessage());
} else {
logger.error("微信支付回调, order create error, req: " + resultxml + ", e: " + e.getMessage());
}
SortedMap resultMap = new TreeMap<>();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.getRequestXml(resultMap);
} catch (Exception e) {
if (paramMap == null) {
logger.error("微信支付回调, order create error, e: " + e.getMessage());
} else {
logger.error("微信支付回调, order create error, req: " + resultxml + ", e: " + e.getMessage());
}
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.getRequestXml(resultMap);
}
}


/**
*
* @return 接收微信退款异步通知
* @throws Exception 可能产生的任何异常
*/
@RequestMapping(value = "/refund")
public String __refundNotify(HttpServletRequest request) throws Exception {
Map<String, String> paramMap = null;
String response = "";
String xml = "";
try {
xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8"));
logger.info(xml);
paramMap = WxPayment.xmlToMap(xml);
response = wxRefundOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP);
logger.info("refund wxpay, notify success, req : " + xml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
logger.error("refund wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.getRequestXml(resultMap);
} catch (MallinkException e) {
logger.error("refund wxpay, notify error, req: " + xml + ", e:" +e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.getRequestXml(resultMap);
} catch (Exception e) {
logger.error("refund wxpay, order create error, req: " + xml + ", e: " + e.getMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.getRequestXml(resultMap);
}
}

/**
*
* @return 接收微信分账异步通知
* @throws Exception 可能产生的任何异常
*/
@RequestMapping(value = "/sharing")
public String __shareNotify(HttpServletRequest request) throws Exception {
Map<String, String> paramMap = null;
String response = "";
String xml = "";
try {
xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8"));
paramMap = WxPayment.xmlToMap(xml);
logger.info("share wxpay, notify, param: " + xml );
response = wxPayOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP);
logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
logger.error("share wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.getRequestXml(resultMap);
} catch (MallinkException e) {
logger.error("refund wxpay, notify error, req: " + xml + ", e:" +e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.getRequestXml(resultMap);
} catch (Exception e) {
logger.error("refund wxpay, order create error, req: " + xml + ", e: " + e.getMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
resultMap.put("return_msg", e.getMessage());
return XmlUtil.getRequestXml(resultMap);
}
}
}

+ 78
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxPayOrderController.java Просмотреть файл

@@ -0,0 +1,78 @@
package com.iformall.controller;

import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxProfitSharingOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;

import com.iformall.domain.po.WxPayOrder;
import com.iformall.service.WxPayOrderService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxPayOrder")
public class WxPayOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxPayOrderService wxPayOrderService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxPayOrder wxPayOrder,Integer pageNum, Integer pageSize) {
if (null == wxPayOrder) wxPayOrder = new WxPayOrder();
final PageInfo<WxPayOrder> page = wxPayOrderService.listAsPage(wxPayOrder, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxPayOrder wxPayOrder) {
//Assert.notNull(wxPayOrder.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxPayOrderService.saveOrUpdate(wxPayOrder);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxPayOrder wxPayOrder) {
wxPayOrderService.saveOrUpdate(wxPayOrder);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxPayOrderService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxPayOrderService.getById(id));
}



@Autowired
private WxProfitSharingOrderService xProfitSharingOrderService;

@Autowired
private WxAppinfoService wxAppinfoService;
}

+ 85
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxProfitSharingReceiverController.java Просмотреть файл

@@ -0,0 +1,85 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxProfitSharingReceiver;
import com.iformall.service.WxMerchantService;
import com.iformall.service.WxProfitSharingReceiverService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxProfitSharingReceiver")
public class WxProfitSharingReceiverController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;
@Autowired
private WxMerchantService wxMerchantService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxProfitSharingReceiver receiver, Integer pageNum, Integer pageSize) {
if (null == receiver) receiver = new WxProfitSharingReceiver();
final PageInfo<WxProfitSharingReceiver> page = wxProfitSharingReceiverService.listAsPage(receiver, pageNum, pageSize);
return new ResultData(page);
}


@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@ModelAttribute WxProfitSharingReceiver receiver) {

if (receiver == null)
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
if (receiver.getMerchantId() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
if (receiver.getReceiverType() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
if (receiver.getReceiverComments() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
if (receiver.getReceiverAccount() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
if (receiver.getTrueName() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);

WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId());
if (merchant == null)
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND);

return wxProfitSharingReceiverService.addReceiver(merchant, receiver);
}


@ApiOperation("根据id删除接口")
@GetMapping("del")
public ResultData delete(@ModelAttribute WxProfitSharingReceiver receiver) {
if (receiver == null)
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
if (receiver.getMerchantId() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
if (receiver.getReceiverType() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
if (receiver.getReceiverAccount() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);

WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId());
if (merchant == null)
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND);

return wxProfitSharingReceiverService.delReceiver(merchant);
}


}

+ 70
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxRefundOrderController.java Просмотреть файл

@@ -0,0 +1,70 @@
package com.iformall.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;

import com.iformall.domain.po.WxRefundOrder;
import com.iformall.service.WxRefundOrderService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/api/refund")
public class WxRefundOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxRefundOrderService wxRefundOrderService;


@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxRefundOrder wxRefundOrder, Integer pageNum, Integer pageSize) {
if (null == wxRefundOrder) wxRefundOrder = new WxRefundOrder();
final PageInfo<WxRefundOrder> page = wxRefundOrderService.listAsPage(wxRefundOrder, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxRefundOrder wxRefundOrder) {
//Assert.notNull(wxRefundOrder.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxRefundOrderService.saveOrUpdate(wxRefundOrder);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxRefundOrder wxRefundOrder) {
wxRefundOrderService.saveOrUpdate(wxRefundOrder);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxRefundOrderService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxRefundOrderService.getById(id));
}


}

+ 62
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxRentContractController.java Просмотреть файл

@@ -0,0 +1,62 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxRentContract;
import com.iformall.service.WxRentContractService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxRentContract")
public class WxRentContractController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxRentContractService wxRentContractService;

@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxRentContract wxRentContract,Integer pageNum, Integer pageSize) {
if (null == wxRentContract) wxRentContract = new WxRentContract();
final PageInfo<WxRentContract> page = wxRentContractService.listAsPage(wxRentContract, pageNum, pageSize);
return new ResultData(page);
}

@PostMapping("add")
public ResultData add(@RequestBody WxRentContract wxRentContract) {
//Assert.notNull(wxRentContract.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxRentContractService.saveOrUpdate(wxRentContract);
return new ResultData();
}

@PostMapping("update")
public ResultData update(@RequestBody WxRentContract wxRentContract) {
wxRentContractService.saveOrUpdate(wxRentContract);
return new ResultData();
}

@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true)
public ResultData delete(String id) {
wxRentContractService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true)
public ResultData findById(String id) {
return new ResultData(Result.SUCCESS,"查询成功",wxRentContractService.getById(id));
}
}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxScoreHistoryController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxScoreHistory;
import com.iformall.service.WxScoreHistoryService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxScoreHistory")
public class WxScoreHistoryController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxScoreHistoryService wxScoreHistoryService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxScoreHistory wxScoreHistory, Integer pageNum, Integer pageSize) {
if (null == wxScoreHistory) wxScoreHistory = new WxScoreHistory();
final PageInfo<WxScoreHistory> page = wxScoreHistoryService.listAsPage(wxScoreHistory, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxScoreHistory wxScoreHistory) {
//Assert.notNull(wxScoreHistory.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxScoreHistoryService.saveOrUpdate(wxScoreHistory);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxScoreHistory wxScoreHistory) {
wxScoreHistoryService.saveOrUpdate(wxScoreHistory);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxScoreHistoryService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxScoreHistoryService.getById(id));
}


}

+ 70
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxScoreRulesController.java Просмотреть файл

@@ -0,0 +1,70 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.service.WxScoreRulesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxScoreRules")
@Api(description = "成长值规则相关接口")
public class WxScoreRulesController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxScoreRulesService wxScoreRulesService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxScoreRules wxScoreRules, Integer pageNum, Integer pageSize) {
if (null == wxScoreRules) wxScoreRules = new WxScoreRules();
final PageInfo<WxScoreRules> page = wxScoreRulesService.listAsPage(wxScoreRules, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxScoreRules wxScoreRules) {
//Assert.notNull(wxScoreRules.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxScoreRules.setTenantId(getTenantId());
wxScoreRulesService.saveOrUpdate(wxScoreRules);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxScoreRules wxScoreRules) {
wxScoreRulesService.saveOrUpdate(wxScoreRules);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxScoreRulesService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxScoreRulesService.getById(id));
}


}

+ 67
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxScoreValidityPeriodController.java Просмотреть файл

@@ -0,0 +1,67 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxScoreValidityPeriod;
import com.iformall.service.WxScoreValidityPeriodService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxScoreValidityPeriod")
public class WxScoreValidityPeriodController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxScoreValidityPeriodService wxScoreValidityPeriodService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxScoreValidityPeriod wxScoreValidityPeriod, Integer pageNum, Integer pageSize) {
if (null == wxScoreValidityPeriod) wxScoreValidityPeriod = new WxScoreValidityPeriod();
final PageInfo<WxScoreValidityPeriod> page = wxScoreValidityPeriodService.listAsPage(wxScoreValidityPeriod, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxScoreValidityPeriod wxScoreValidityPeriod) {
//Assert.notNull(wxScoreValidityPeriod.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxScoreValidityPeriodService.saveOrUpdate(wxScoreValidityPeriod);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxScoreValidityPeriod wxScoreValidityPeriod) {
wxScoreValidityPeriodService.saveOrUpdate(wxScoreValidityPeriod);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxScoreValidityPeriodService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxScoreValidityPeriodService.getById(id));
}


}

+ 98
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java Просмотреть файл

@@ -0,0 +1,98 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxShop;
import com.iformall.service.WxShopService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("wxShop")
public class WxShopController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxShopService wxShopService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) {
if (null == wxShop) wxShop = new WxShop();
wxShop.setTenantId(getTenantId());
wxShop.setSortColumns(WxShop.Field.Id_DESC);

final PageInfo<Map<String, Object>> page = wxShopService.listMapAsPage(wxShop, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxShop wxShop) {
//Assert.notNull(wxShop.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxShop.setTenantId(getTenantId());
wxShopService.saveOrUpdate(wxShop);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxShop wxShop) {
wxShopService.saveOrUpdate(wxShop);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxShopService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxShopService.getById(id));
}

@ApiOperation("获取商铺数据")
@GetMapping("getShopListByShopNumber")
@ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true)
public ResultData getbshoplist(String shopNumber) {
return wxShopService.getbshoplist(getTenantId(), shopNumber);
}

@ApiOperation("获取商户商铺数据")
@GetMapping("getMerchantShopByShopId")
@ApiImplicitParam(name = "shopId", value = "shopId", dataType = "String", paramType = "query", required = true)
public ResultData getMerchantShopByShopId(String shopId) {
return wxShopService.getMerchantShopByShopId(getTenantId(), shopId);
}

@ApiOperation("查询商铺号是否存在")
@GetMapping("hasShopNumber")

@ApiImplicitParams({
@ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true),
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query")})
public ResultData hasShopNumber(String shopNumber,Long id) {
return wxShopService.hasShopNumber(getTenantId(), shopNumber,id);
}



}

+ 164
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxTagsController.java Просмотреть файл

@@ -0,0 +1,164 @@
package com.iformall.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxTags;
import com.iformall.domain.vo.WxTagsVo;
import com.iformall.service.WxCUserTagsService;
import com.iformall.service.WxTagsService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxTags")
@Api(description="标签弹窗接口")
public class WxTagsController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxTagsService wxTagsService;
@Autowired
private WxCUserTagsService wxCUserTagsService;

@GetMapping("getAllList")
@ApiOperation("标签弹窗接口")
public ResultData getAllList() {
List<WxTagsVo> type1List = new ArrayList<>();
List<WxTags> tags = wxTagsService.findType1Value();
for(WxTags t:tags) {
WxTagsVo vo =new WxTagsVo();
vo.setValue(t.getType1());
List<WxTagsVo> type2List =new ArrayList<>();
List<WxTags> type2s = wxTagsService.findType2Value(t.getType1());
for(WxTags wt:type2s) {
WxTagsVo v = new WxTagsVo();
v.setValue(wt.getType2());
List<WxTagsVo> list = new ArrayList<>();
WxTags tag = new WxTags();
tag.setType2(wt.getType2());
PageInfo<WxTags> page = wxTagsService.listAsPage(tag, 1, 1000);
for(WxTags wxT : page.getList()) {
WxTagsVo wxVo = new WxTagsVo();
wxVo.setId(wxT.getId());
wxVo.setValue(wxT.getName());
list.add(wxVo);
}
v.setSubTags(list);
type2List.add(v);
vo.setSubTags(type2List);
}
type1List.add(vo);
}
return new ResultData(Result.SUCCESS,"查询成功",type1List);
}
@GetMapping("getPeopleTagList")
@ApiOperation("用户人群tag接口")
public ResultData getPeopleTagList() {
List<WxTagsVo> type2List =new ArrayList<>();
List<WxTags> type2s = wxTagsService.findType2Value(null);
for(WxTags wt:type2s) {
WxTagsVo v = new WxTagsVo();
v.setValue(wt.getType2());
List<WxTagsVo> list = new ArrayList<>();
WxTags tag = new WxTags();
tag.setType2(wt.getType2());
PageInfo<WxTags> page = wxTagsService.listAsPage(tag, 1, 1000);
for(WxTags wxT : page.getList()) {
WxTagsVo wxVo = new WxTagsVo();
wxVo.setValue(wxT.getName());
wxVo.setId(wxT.getId());
list.add(wxVo);
}
v.setSubTags(list);
type2List.add(v);
}
return new ResultData(Result.SUCCESS,"查询成功",type2List);
}
@ApiOperation("查询用户人群")
@GetMapping("findUserByTag")
public Result findUserByTag(Long[] tagIds) {
// WxTags wxTags = new WxTags();
// List<Long> ids = new ArrayList<>();
// for(Long id :tagIds) {
// ids.add(id);
// }
// wxTags.setIds(ids);
// PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, 1, 5000);
// List<WxTags> list = page.getList();
// StringBuffer names= new StringBuffer();
// for(WxTags t:list) {
// names.append(t.getName()+"/");
// }
// Map<String,Object> map = new HashMap<>();
// String endName="";
// if(names.length()>0) {
// endName = names.toString().substring(0,names.length()-1);
// }
// map.put("names",endName );
// map.put("tagIds", ids);
long count = wxCUserTagsService.findCountByTag(Arrays.asList(tagIds));
return new ResultData(Result.SUCCESS,"查询成功",count);
}
// @ApiOperation("分页列表接口")
// @GetMapping("list")
// @ApiImplicitParams({
// @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
// @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
// public ResultData list(@ModelAttribute WxTags wxTags,Integer pageNum, Integer pageSize) {
// if (null == wxTags) wxTags = new WxTags();
// final PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, pageNum, pageSize);
// return new ResultData(page);
// }
//
// @ApiOperation("新增接口")
// @PostMapping("add")
// public ResultData add(@RequestBody WxTags wxTags) {
// //Assert.notNull(wxTags.getName(), "角色名不能为空");
// //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
// wxTagsService.saveOrUpdate(wxTags);
// return new ResultData();
// }
//
// @ApiOperation("根据id更新接口")
// @PostMapping("update")
// public ResultData update(@RequestBody WxTags wxTags) {
// wxTagsService.saveOrUpdate(wxTags);
// return new ResultData();
// }
//
// @ApiOperation("根据id删除接口")
// @GetMapping("/del")
// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
// public ResultData delete(Long id) {
// wxTagsService.deleteById(id);
// return new ResultData(Result.SUCCESS, "删除成功", null);
// }
//
// @ApiOperation("根据id查询接口")
// @GetMapping("/findById")
// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
// public ResultData findById(Long id) {
// return new ResultData(Result.SUCCESS,"查询成功",wxTagsService.getById(id));
// }
}

+ 66
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxUserChannelController.java Просмотреть файл

@@ -0,0 +1,66 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxUserChannel;
import com.iformall.service.WxUserChannelService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxUserChannel")
public class WxUserChannelController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private WxUserChannelService wxUserChannelService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxUserChannel wxUserChannel, Integer pageNum, Integer pageSize) {
if (null == wxUserChannel) wxUserChannel = new WxUserChannel();
final PageInfo<WxUserChannel> page = wxUserChannelService.listAsPage(wxUserChannel, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxUserChannel wxUserChannel) {
//Assert.notNull(wxUserChannel.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxUserChannelService.saveOrUpdate(wxUserChannel);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxUserChannel wxUserChannel) {
wxUserChannelService.saveOrUpdate(wxUserChannel);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
wxUserChannelService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxUserChannelService.getById(id));
}


}

+ 39
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxUserCouponController.java Просмотреть файл

@@ -0,0 +1,39 @@
package com.iformall.controller;

import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxUserCouponDto;
import com.iformall.service.WxUserCouponService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
* Created by syf on 2018/8/10.
*/
@RestController
@RequestMapping("wxUserCoupon")
public class WxUserCouponController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());


@Autowired
private WxUserCouponService wxUserCouponService;


@ApiOperation("查询用户卡券接口")
@PostMapping("findByStatus")
public ResultData findByStatus(@RequestBody WxUserCouponDto wxUserCoupon) {
//根据用户id,用户卡券状态查找
if(wxUserCoupon==null||wxUserCoupon.getcUserId()==null||wxUserCoupon.getCouponStatus()==null){
return new ResultData(Result.ERROR,"查询失败");
}
return new ResultData(Result.SUCCESS,"查询成功",wxUserCouponService.findList(wxUserCoupon.getcUserId(),wxUserCoupon.getCouponStatus()));
}

}

+ 309
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java Просмотреть файл

@@ -0,0 +1,309 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxCUserBasicInfoDto;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxUserChannel;
import com.iformall.domain.vo.UserStructureVo;
import com.iformall.enums.EnumAgeInfo;
import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxCUserService;
import com.iformall.service.WxUserChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.*;

@RestController
@Api(description = "会员洞察")
@RequestMapping("userAnalysis")
public class WxUserStructureController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
private WxCUserService wxCUserService;
@Autowired
private WxUserChannelService wxUserChannelService;

@ApiOperation("查询会员性别结构")
@GetMapping("/findUserSexStructure")
public ResultData findUserSexStructure(Date startTime, Date endTime) {
WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto();
dto.setTenantId(getTenantId());
dto.setStartTime(startTime);
if (endTime != null) {
Calendar c = Calendar.getInstance();
c.setTime(endTime);
c.add(Calendar.DAY_OF_YEAR, 1);
endTime = c.getTime();
}
//保密
dto.setSex(0);
long secrecy = getCount(dto);
dto.setSex(1);
long boy = getCount(dto);
dto.setSex(2);
long girl = getCount(dto);
Long all = secrecy + boy + girl;
List<UserStructureVo> vos = new ArrayList<>();
vos.add(getVo(boy, all, "男", 1));
vos.add(getVo(girl, all, "女", 2));
vos.add(getVo(secrecy, all, "保密", 3));
return new ResultData(vos);
}

@ApiOperation("查询会员年龄结构")
@GetMapping("/findUserAgeStructure")
public ResultData findUserAgeStructure(Date startTime, Date endTime) {
WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto();
dto.setTenantId(getTenantId());
dto.setStartTime(startTime);
if (endTime != null) {
Calendar c = Calendar.getInstance();
c.setTime(endTime);
c.add(Calendar.DAY_OF_YEAR, 1);
endTime = c.getTime();
}
dto.setEndTime(endTime);
long all = wxCUserBasicInfoService.findCountByAge(dto);
List<UserStructureVo> vos = new ArrayList<>();
Calendar c = Calendar.getInstance();
for (EnumAgeInfo a : EnumAgeInfo.values()) {
c.clear();
c.setTime(new Date());
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
long count = getCountByAge(a, c, dto);
vos.add(getVo(count, all, a.getDesc(), a.getSortNum()));
}
return new ResultData(vos);
}

@ApiOperation("查询会员数量")
@GetMapping("/findUserDataCount")
public ResultData findUserCount(Date startTime, Date endTime) {
WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto();
dto.setTenantId(getTenantId());
dto.setStartTime(startTime);
dto.setEndTime(endTime);
if (endTime != null) {
Calendar c = Calendar.getInstance();
c.setTime(endTime);
c.add(Calendar.DAY_OF_YEAR, 1);
endTime = c.getTime();
}
//微信用户数据
long wxallCount = wxCUserService.findCount(dto);//总量
//会员数据
Map<String,Object> member=getMemberData(dto);

Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
Date today = c.getTime();
dto.setStartTime(today);
dto.setEndTime(null);
long wxtodayCount = wxCUserService.findCount(dto);//今天新增
List<UserStructureVo> wxnewCountVos = new ArrayList<>();//每日新增会员数
int j = 1;
for (int i = 29; i >= 0; i--) {
c.clear();
c.setTime(today);
c.add(Calendar.DAY_OF_YEAR, -i);
dto.setStartTime(c.getTime());
c.add(Calendar.DAY_OF_YEAR, 1);
dto.setEndTime(c.getTime());
long count = wxCUserService.findCount(dto);
UserStructureVo vo = new UserStructureVo();
vo.setSortNum(j);
j++;
vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime()));
vo.setCount(count);
wxnewCountVos.add(vo);
}
List<UserStructureVo> wxallCountVos = new ArrayList<>();//累计会员数
c.clear();
c.setTime(today);
c.add(Calendar.DAY_OF_YEAR, -30);
dto.setEndTime(c.getTime());
dto.setStartTime(null);
long firstDay = wxCUserService.findCount(dto);//统计的第一天总数
int i = 0;
long sumCount = 0;
for (UserStructureVo v : wxnewCountVos) {
UserStructureVo vo = new UserStructureVo();
sumCount += v.getCount();
vo.setCount(firstDay + sumCount);
vo.setName(v.getName());
vo.setSortNum(i + 1);
wxallCountVos.add(vo);
i++;
}


Map<String, Object> map = new HashMap<>();
map.put("wxallCount", wxallCount);//累计会员总数
map.put("wxtodayCount", wxtodayCount);//今日新增会员数
map.put("wxallCountVos", wxallCountVos);//累计会员列表( 日期和数量list)
map.put("wxnewCountVos", wxnewCountVos);//新增会员列表(日期和数量list)
map.putAll(member);
return new ResultData(map);
}

private Map<String,Object> getMemberData(WxCUserBasicInfoDto dto) {

long allCount = wxCUserBasicInfoService.findCount(dto);//总量

Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
Date today = c.getTime();
dto.setStartTime(today);
dto.setEndTime(null);
long todayCount = wxCUserBasicInfoService.findCount(dto);//今天新增
List<UserStructureVo> newCountVos = new ArrayList<>();//每日新增会员数
int j = 1;
for (int i = 29; i >= 0; i--) {
c.clear();
c.setTime(today);
c.add(Calendar.DAY_OF_YEAR, -i);
dto.setStartTime(c.getTime());
c.add(Calendar.DAY_OF_YEAR, 1);
dto.setEndTime(c.getTime());
long count = wxCUserBasicInfoService.findCount(dto);
UserStructureVo vo = new UserStructureVo();
vo.setSortNum(j);
j++;
vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime()));
vo.setCount(count);
newCountVos.add(vo);
}
List<UserStructureVo> allCountVos = new ArrayList<>();//累计会员数
c.clear();
c.setTime(today);
c.add(Calendar.DAY_OF_YEAR, -30);
dto.setEndTime(c.getTime());
dto.setStartTime(null);
long firstDay = wxCUserBasicInfoService.findCount(dto);//统计的第一天总数
int i = 0;
long sumCount = 0;
for (UserStructureVo v : newCountVos) {
UserStructureVo vo = new UserStructureVo();
sumCount += v.getCount();
vo.setCount(firstDay + sumCount);
vo.setName(v.getName());
vo.setSortNum(i + 1);
allCountVos.add(vo);
i++;
}

Map<String, Object> map = new HashMap<>();
map.put("allCount", allCount);//累计会员总数
map.put("todayCount", todayCount);//今日新增会员数
map.put("allCountVos", allCountVos);//累计会员列表( 日期和数量list)
map.put("newCountVos", newCountVos);//新增会员列表(日期和数量list)

return map;

}

@ApiOperation("拓客分析")
@GetMapping("/findUserByChannel")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData findUserByChannel(String channelName, Integer pageNum, Integer pageSize) {
List<String> sceneList = null;
if (StringUtils.isNotBlank(channelName)) {
WxUserChannel c = new WxUserChannel();
c.setChannelName(channelName);
PageInfo<WxUserChannel> page = wxUserChannelService.listAsPage(c, 1, 100);
if (page.getSize() > 0) {
sceneList = new ArrayList<>();
for (WxUserChannel wuc : page.getList()) {
sceneList.add(wuc.getSceneAddress());
}
}
}
PageInfo<WxCUser> page = wxCUserService.listByChannel(sceneList, pageNum, pageSize);
for (WxCUser u : page.getList()) {
WxUserChannel c = new WxUserChannel();
c.setSceneAddress(u.getSceneAddress());
PageInfo<WxUserChannel> uc = wxUserChannelService.listAsPage(c, 1, 1);
if (uc.getSize() > 0) {
u.setChannelName(uc.getList().get(0).getChannelName());
} else {
u.setChannelName("其他来源");
}
}

return new ResultData(page);
}

@ApiOperation("获取用户所有渠道")
@GetMapping("/findAllUserChannel")
public ResultData findAllUserChannel() {
List<WxUserChannel> channels = wxUserChannelService.findDistinctChannel();
List<String> vos = new ArrayList<>();
for (WxUserChannel w : channels) {
vos.add(w.getChannelName());
}
return new ResultData(vos);
}


private long getCountByAge(EnumAgeInfo a, Calendar c, WxCUserBasicInfoDto dto) {
c.add(Calendar.YEAR, -a.getEnd());
Date startTime = c.getTime();
c.clear();
c.setTime(startTime);
c.add(Calendar.YEAR, a.getEnd() - a.getStart());
Date endTime = c.getTime();
dto.setBirthStartTime(startTime);
dto.setBirthEndTime(endTime);
return wxCUserBasicInfoService.findCountByAge(dto);
}


//通过性别获取数量
private long getCount(WxCUserBasicInfoDto dto) {
// wxCUserBasicInfoService.findCountBySex(dto) basic表与cuser表示对应的,先有cuser 才有basic
//所有这里不需要再去查basic
return wxCUserService.findCount(dto);
}

private UserStructureVo getVo(long count, long all, String name, Integer num) {
UserStructureVo vo = new UserStructureVo();
vo.setSortNum(num);
vo.setName(name);
vo.setCount(count);
NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点
if (all > 0) {
vo.setPercentage(nf.format(new Long(count).doubleValue() / new Long(all).doubleValue()));
} else {
vo.setPercentage("0.00%");
}
return vo;
}


}

+ 39
- 0
mallinkAdmin/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java Просмотреть файл

@@ -0,0 +1,39 @@
package com.iformall.schedule;

import com.iformall.mapper.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Component
public class CouponExpiringSchedule {

private final Logger logger = Logger.getLogger(CouponExpiringSchedule.class);


@Autowired
private WxCouponChannelMapper wxCouponChannelMapper;



@Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public void couponExpiringSchedule() {



}

@Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
public void couponChannelExpiringSchedule() {

wxCouponChannelMapper.offExpiriedCouponChannelByEndTime();
wxCouponChannelMapper.offExpiriedCouponChannelByValidDate();
wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus();
}
}

+ 69
- 0
mallinkAdmin/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java Просмотреть файл

@@ -0,0 +1,69 @@
package com.iformall.schedule;

import com.iformall.config.PayProperty;
import com.iformall.domain.po.*;
import com.iformall.enums.EnumAppType;
import com.iformall.enums.EnumRefundWay;
import com.iformall.mapper.*;
import com.iformall.service.WxPayOrderService;
import com.iformall.service.WxRefundOrderService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Component
public class CouponOrderExpiringSchedule {

private final Logger logger = Logger.getLogger(CouponOrderExpiringSchedule.class);


@Autowired
private WxCouponOrderMapper wxCouponOrderMapper;

@Autowired
private PayProperty payProperty;

@Autowired
private WxRefundOrderService wxRefundOrderService;

@Autowired
private WxPayOrderService wxPayOrderService;

@Autowired
private WxAppinfoMapper wxAppinfoMapper;

@Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public void couponOrderExpiringSchedule() {
wxCouponOrderMapper.offExpiredCouponOrderByValidDate();
}

@Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
public void couponOrderRefundSchedule() {

List<WxCouponOrder> list = wxCouponOrderMapper.findExpiredCouponOrderByValidDate();


for(WxCouponOrder co:list) {

WxAppinfo appinfo = new WxAppinfo();
appinfo.setTenantId(co.getOrderId().toString());
appinfo.setType(EnumAppType.B.getCode());
appinfo = wxAppinfoMapper.findList(appinfo).get(0);

try {
wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, co.getId(), EnumRefundWay.AUTO, null);
} catch (Exception e) {
logger.error("退款失败:"+e.getMessage()+"couponOrderId="+co.getId());
continue;
}
}
}
}

+ 141
- 0
mallinkAdmin/src/main/java/com/iformall/schedule/DaliyAmountSchedule.java Просмотреть файл

@@ -0,0 +1,141 @@
package com.iformall.schedule;

import com.iformall.common.IdWorker;
import com.iformall.domain.po.WxCouponOrder;
import com.iformall.domain.po.WxDateAmountRecord;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxMerchant;
import com.iformall.enums.EnumDateAmtType;
import com.iformall.mapper.*;
import com.iformall.service.WxDateAmountRecordService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Component
public class DaliyAmountSchedule {

private final Logger logger = Logger.getLogger(DaliyAmountSchedule.class);


@Autowired
private WxMallMapper wxMallMapper;

@Autowired
private WxMerchantMapper wxMerchantMapper;


@Autowired
private WxCouponOrderMapper wxCouponOrderMapper;


@Autowired
private WxDateAmountRecordService wxDateAmountRecordService;




@Scheduled(cron = "0 0 23 * * ?") // 每天晚上11点盘点
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public void daliyAmountSchedule() {


List<WxMall> mallList = wxMallMapper.findList(new WxMall());

if (mallList.size()==0) {
logger.info("No Mall info found");
return;
}

for (int i=0; i < mallList.size(); i++) {

WxMerchant merchant = new WxMerchant();
merchant.setTenantId(mallList.get(i).getTenantId());
List<WxMerchant> merchantList = wxMerchantMapper.findList(merchant);

if (merchantList.size()==0) {
logger.info("No merchant info found in mall" + mallList.get(i).getName());
continue;
}

for (int j=0; j < merchantList.size(); j++) {
merchant = merchantList.get(j);

Map dateMap = new HashMap();
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
String dateString = fmt.format(new Date());
Date startDate = null;
try {
startDate = fmt.parse(dateString);
} catch (ParseException e) {
logger.error("Parse date string failed");
continue;
}
dateMap.put("startDate", startDate);
dateMap.put("endDate", new Date());
dateMap.put("merchantID",merchant.getId());

List<WxCouponOrder> list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap);
logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date());
int total_price = 0;
for(WxCouponOrder couponOrder : list) {
total_price = total_price + couponOrder.getCouponPrice();
}
logger.info("\nFound " + list.size() + " coupon orders \n" +
"for " + merchant.getId() + "\n" +
"from " + startDate + " to " + new Date() +"\n" +
"TOTAL ORDER=" + total_price);


Date now = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(now); // 将时分秒,毫秒域清零
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
now = cal.getTime();

WxDateAmountRecord dateAmountRecord = new WxDateAmountRecord();
dateAmountRecord.setId(IdWorker.get().nextId());
dateAmountRecord.setCreateDate(new Date());
dateAmountRecord.setUpdateDate(new Date());
dateAmountRecord.setPayPrice(total_price);
dateAmountRecord.setMerchantId(merchant.getId());
dateAmountRecord.setTenantId(merchant.getTenantId());
dateAmountRecord.setType(EnumDateAmtType.PAY_RECORD.getCode());
dateAmountRecord.setDate(now);
dateAmountRecord.setDayOfWeek(cal.get(Calendar.DAY_OF_WEEK));
dateAmountRecord.setMonth(cal.get(Calendar.MONTH));
dateAmountRecord.setWeekOfYear(cal.get(Calendar.WEEK_OF_YEAR));

wxDateAmountRecordService.saveDaliyAmount(dateAmountRecord);

list= wxCouponOrderMapper.findListOfVerifiedByDate(dateMap);
logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date());
total_price = 0;
for(WxCouponOrder couponOrder : list) {
total_price = total_price + couponOrder.getCouponPrice();
}
logger.info("\nFound " + list.size() + " coupon orders \n" +
"for " + merchant.getId() + "\n" +
"from " + startDate + " to " + new Date() +"\n" +
"TOTAL VERIFIED=" + total_price);

dateAmountRecord.setId(IdWorker.get().nextId());
dateAmountRecord.setPayPrice(total_price);
dateAmountRecord.setType(EnumDateAmtType.VERIFY_RECORD.getCode());
wxDateAmountRecordService.saveDaliyAmount(dateAmountRecord);

}
}
}
}

+ 110
- 0
mallinkAdmin/src/main/java/com/iformall/schedule/MsgSendingSchedule.java Просмотреть файл

@@ -0,0 +1,110 @@
package com.iformall.schedule;

import com.alibaba.fastjson.JSONObject;
import com.iformall.domain.po.WxMsg;
import com.iformall.domain.po.WxMsgConfig;
import com.iformall.mapper.WxMsgConfigMapper;
import com.iformall.mapper.WxMsgMapper;
import com.iformall.utils.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.*;

@Component
public class MsgSendingSchedule {

private final Logger logger = Logger.getLogger(MsgSendingSchedule.class);

@Autowired
private WxMsgMapper wxMsgMapper;

@Autowired
private WxMsgConfigMapper wxMsgConfigMapper;


@Scheduled(cron = "0 1 * * * ?") // 每小时第一分钟执行
public void sendmsgschedule() {

logger.info("sendmsg定时任务启动");

String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:00:00");
WxMsg wxMsg = new WxMsg();
wxMsg.setIsright(0);
wxMsg.setSendtime(systemTime);
List<WxMsg> list = wxMsgMapper.findList(wxMsg);

for(WxMsg msg:list){
sendmsg(msg);
}

logger.info("sendmsg定时任务结束");
}

public void sendmsg(WxMsg wxMsg){
//从短信配置中查询密钥 bid 等信息
WxMsgConfig wxMsgConfig = new WxMsgConfig();
wxMsgConfig.setTenantId(wxMsg.getTenantId());
List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig);
if (wxMsgConfigs.size() == 0) return;
wxMsgConfig = wxMsgConfigs.get(0);

String secret = wxMsgConfig.getSecret();
String bid = wxMsgConfig.getBid();
String publickey = wxMsgConfig.getPublickey();

String phone = wxMsg.getPhones();
String signature = wxMsg.getSignature();
String msg = wxMsg.getMsg();
String notifyUrl = wxMsgConfig.getNotifyurl();
TreeMap<String, String> message = new TreeMap<>();
message.put("bid", bid);
message.put("phone", phone);
message.put("signature", signature);
message.put("msg", msg);
message.put("notify_url", notifyUrl);

StringBuilder sb = new StringBuilder();
Set<Map.Entry<String, String>> entries = message.entrySet();
for (Map.Entry<String, String> entry : entries) {
sb.append(entry.getKey()).append("=").append(entry.getValue());
}
sb.append("&secret=").append(secret);
String sign = HMACSHA256.sha256_HMAC(sb.toString(), secret);
message.put("sign", sign.toUpperCase());

String str32 = HMACSHA256.STR2;
String iv = HMACSHA256.IV;

Map<String, String> params = new HashMap<>();
params.put("iv", iv);
params.put("bid", bid);

try {
String data = AesUtil.AESEncode(str32, JSONObject.toJSONString(message), iv);
String sc = RsaUtil.RSAEncode(str32.getBytes(), publickey);
params.put("data", data);
params.put("sc", sc);
} catch (Exception e) {
e.printStackTrace();
}

String requestUrl = "https://webapp.wiwide.com/apisms/send";
String result = HttpUtil.doPost(requestUrl, params);
JSONObject jsonObjectResult = JSONObject.parseObject(result);
String ret = jsonObjectResult.get("ret").toString();

if (ret.equals("1")) {
wxMsg.setSendstatus(1);
} else {
wxMsg.setSendstatus(0);
}

wxMsg.setStatus(1);
wxMsgMapper.updateByPrimaryKeySelective(wxMsg);

}

}

+ 62
- 0
mallinkAdmin/src/main/java/com/iformall/schedule/OrderExpiringSchedule.java Просмотреть файл

@@ -0,0 +1,62 @@
package com.iformall.schedule;

import com.iformall.domain.po.WxOrder;
import com.iformall.enums.EnumOrderStatus;
import com.iformall.mapper.WxOrderMapper;
import com.iformall.service.WxOrderService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class OrderExpiringSchedule {

private final Logger logger = Logger.getLogger(OrderExpiringSchedule.class);

private final int TIME_OUT_VALUE = 15 * 60 * 1000; //15分钟

@Autowired
WxOrderMapper wxOrderMapper;

@Autowired
WxOrderService wxOrderService;


@Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
public void orderExpireSchedule() {

Map dateMap = new HashMap();
Date curDate = new Date();

//dateMap.put("startDate",new Date(curDate.getTime() - 2*TIME_OUT_VALUE));
dateMap.put("endDate", new Date(curDate.getTime() - TIME_OUT_VALUE ));
List<WxOrder> wxOrderList = wxOrderMapper.findListOfUnpaidOrderByDate(dateMap);

for(WxOrder wxOrder: wxOrderList){
orderExpired(wxOrder);
}
}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public void orderExpired(WxOrder order) {
order.setUpdateDate(new Date());
order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode());
wxOrderMapper.updateByPrimaryKeySelective(order);

// 微信 关单
wxOrderService.orderClose(order);

logger.info("\nFound " + order.getId() + "\n"
+ " create at " + order.getCreateDate() +"\n"
+ " expired at " + new Date());
}
}

+ 21
- 0
mallinkAdmin/src/main/java/com/iformall/schedule/SchedulingConfig.java Просмотреть файл

@@ -0,0 +1,21 @@
package com.iformall.schedule;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

@Configuration
@EnableScheduling
public class SchedulingConfig implements SchedulingConfigurer {

@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(10);
scheduler.initialize();
taskRegistrar.setTaskScheduler(scheduler);
}

}

+ 132
- 0
mallinkAdmin/src/main/java/com/iformall/schedule/WxAppVisitSchedule.java Просмотреть файл

@@ -0,0 +1,132 @@
package com.iformall.schedule;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxUserVisit;
import com.iformall.enums.EnumAppType;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxUserVisitService;

@Component
public class WxAppVisitSchedule {
private Logger logger = Logger.getLogger(WxAppVisitSchedule.class);
private static String visit = "https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token=";

@Autowired
private RestTemplate restTemplate;
@Autowired
private WxUserVisitService wxUserVisitService;
@Autowired
private WxAppinfoService WxAppinfoService;
// @Scheduled(cron = "0 */1 * * * *?")
@Scheduled(cron = "0 0 9 * * ? ")
public void start() {
try {
Calendar c =Calendar.getInstance();
c.add(Calendar.DAY_OF_YEAR, -1);
Date time = c.getTime();
String yesterday = new SimpleDateFormat("yyyyMMdd").format(time);
// "wx8eb8275b78db4ede", "76c43df01296998d8ce12383f213ac10";
WxAppinfo appInfo = new WxAppinfo();
appInfo.setType(EnumAppType.C.getCode());
PageInfo<WxAppinfo> page = WxAppinfoService.listAsPage(appInfo, 1, 10000);
for(WxAppinfo w :page.getList()) {
if(StringUtils.isBlank(w.getAppId())||StringUtils.isBlank(w.getSecret())) {
continue;
}
getData(yesterday,w.getAppId(),w.getSecret(),w.getTenantId());
}
// TODO hardcode appId
// String appId = "wx8eb8275b78db4ede";
// String key ="76c43df01296998d8ce12383f213ac10";
// String talentId ="456";
// getData(yesterday,appId,key,talentId);
}catch(Exception e) {
logger.error("获取微信访问数据失败",e);
}
}
private void getData(String yesterday,String appId,String key,String talentId) throws Exception {
String accessToken = getAccessToken(appId, key);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Map<String, String> map = new HashMap<String, String>();
map.put("begin_date", yesterday);
map.put("end_date",yesterday);
RestTemplate restTemplate = new RestTemplate();
HttpEntity<Map<String,String>> entity = new HttpEntity<Map<String,String>>(map, headers);
String reqUrl =visit+accessToken;
ResponseEntity<String> responseEntity = restTemplate.postForEntity(reqUrl, entity, String.class);
logger.info("获取wx访问数据:"+JSON.toJSONString(responseEntity));
if(responseEntity.hasBody()) {
String body = responseEntity.getBody();
Map<String,Object> maps = (Map<String,Object>)JSON.parse(body);
JSONArray jSONArray = (JSONArray)maps.get("list");
if(jSONArray==null || jSONArray.isEmpty()) {
logger.info("获取失败");
return;
}
JSONObject jsonObject = jSONArray.getJSONObject(0);
Map<String, Object> itemMap = JSONObject.toJavaObject(jsonObject, Map.class);
//{"visit_uv":6,"stay_time_uv":1178.3333,"stay_time_session":115.9016,"ref_date":"20180828",
// "visit_depth":3.1311,"session_cnt":61,"visit_pv":645,"visit_uv_new":3}
logger.info(JSON.toJSONString(itemMap));
WxUserVisit v = new WxUserVisit();
// TODO hardcode appId
// v.setAppId("wx8eb8275b78db4ede");
v.setAppId(appId);
String time = itemMap.get("ref_date")+"";
Date date = new SimpleDateFormat("yyyyMMdd").parse(time);
v.setDayDate(date);
v.setRefDate(time);
v.setSessionCnt(Integer.valueOf(itemMap.get("session_cnt")+""));
v.setVisitPv(Integer.valueOf(itemMap.get("visit_pv")+""));
v.setVisitUv(Integer.valueOf(itemMap.get("visit_uv")+""));
v.setVisitUvNew(Integer.valueOf(itemMap.get("visit_uv_new")+""));
v.setStayTimeSession(itemMap.get("stay_time_session")+"");
v.setVisitDepth(itemMap.get("visit_depth")+"");
v.setStayTimeUv(itemMap.get("stay_time_uv")+"");
v.setTenantId(talentId);
wxUserVisitService.saveOrUpdate(v);
}
}
private String getAccessToken(String appId,String appSecret) {
// return "13_rBo3ajS3jjd8OXZ2MLd4HfLrmt78gvaCeRtu-Xme0iC0fhs_lNS47aLPEwI8kfZQIMKnWYshY5wpaf2IoSI7tgVBm7WwVrm_Bg96J31VPKi8pEp8yB6JiTpDcWkpwv5GngiH2vDkwz7VHOsPLBYcAGAZPM";
String token="https://api.weixin.qq.com/cgi-bin/token?"+
"grant_type=client_credential&appid=APPID&secret=APPSECRET";
String url = token.replace("APPID", appId).
replace("APPSECRET", appSecret);
Map<String,Object> map = restTemplate.getForObject(url,Map.class);
logger.info("获取access_token返回:"+JSON.toJSONString(map));
return (String)map.get("access_token");
}
}

+ 85
- 0
mallinkAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java Просмотреть файл

@@ -0,0 +1,85 @@
package com.iformall.shiro;

import javax.annotation.Resource;

import com.iformall.service.MallUserInfoService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;

import com.iformall.domain.po.MallUserInfo;
import com.iformall.service.MallPermissionService;

/**
* Created by yangqj on 2017/4/21.
*/
public class MyShiroRealm extends AuthorizingRealm {

@Resource
private MallUserInfoService userService;

@Resource
private MallPermissionService resourcesService;

//授权
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
MallUserInfo user= (MallUserInfo) SecurityUtils.getSubject().getPrincipal();//User{id=1, username='admin', password='3ef7164d1f6167cb9f2658c07d3c2f0a', enable=1}
// Map<String,Object> map = new HashMap<String,Object>();
// map.put("userid",user.getId());
// List<SysPermission> resourcesList = resourcesService.list(map);
// 权限信息对象info,用来存放查出的用户的所有的角色(role)及权限(permission)
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
// for(SysPermission resources: resourcesList){
// info.addStringPermission(resources.getUrl());
// }
return info;
}

//认证
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
//获取用户的输入的账号.
String username = (String)token.getPrincipal();
MallUserInfo user = userService.getByUsername(username);
if(user==null) throw new UnknownAccountException("用户名不存在");
// if (0==user.getEnable()) {
// throw new LockedAccountException(); // 帐号锁定
// }
if(user.getStatus()==null || 1!=user.getStatus()) {//用户被禁用
throw new UnknownAccountException("用户被禁用");
}
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
user, //用户
user.getPassword(), //密码
ByteSource.Util.bytes(username),
getName() //realm name
);
// 当验证都通过后,把用户信息放在session里
Session session = SecurityUtils.getSubject().getSession();
session.setAttribute(UserSession.userInfo, user);
session.setAttribute(UserSession.userId, user.getId());
return authenticationInfo;
}


/**
* 指定principalCollection 清除
*/
/* public void clearCachedAuthorizationInfo(PrincipalCollection principalCollection) {

SimplePrincipalCollection principals = new SimplePrincipalCollection(
principalCollection, getName());
super.clearCachedAuthorizationInfo(principals);
}
*/
}

+ 33
- 0
mallinkAdmin/src/main/java/com/iformall/shiro/PasswordHelper.java Просмотреть файл

@@ -0,0 +1,33 @@
package com.iformall.shiro;


import com.iformall.domain.po.MallUserInfo;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;



public class PasswordHelper {
//private RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
private String algorithmName = "md5";
private int hashIterations = 2;

public void encryptPassword(MallUserInfo user) {
//String salt=randomNumberGenerator.nextBytes().toHex();
String newPassword = new SimpleHash(algorithmName, user.getPassword(), ByteSource.Util.bytes(user.getUsername()), hashIterations).toHex();
//String newPassword = new SimpleHash(algorithmName, user.getPassword()).toHex();
user.setPassword(newPassword);

}

public static void main(String[] args) {
MallUserInfo user = new MallUserInfo();
user.setUsername("sadmin");
user.setPassword("sadmin123");
PasswordHelper passwordHelper = new PasswordHelper();
passwordHelper.encryptPassword(user);
System.out.println(user);
System.out.println(user.getPassword());
}
}

+ 127
- 0
mallinkAdmin/src/main/java/com/iformall/shiro/ShiroService.java Просмотреть файл

@@ -0,0 +1,127 @@
package com.iformall.shiro;

import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager;
import org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver;
import org.apache.shiro.web.servlet.AbstractShiroFilter;
import org.crazycake.shiro.RedisSessionDAO;
import org.springframework.beans.factory.annotation.Autowired;

import com.iformall.service.MallPermissionService;

/**
* Created by yangqj on 2017/4/30.
*/
//@Service
public class ShiroService {
@Autowired
private ShiroFilterFactoryBean shiroFilterFactoryBean;
@Autowired
private MallPermissionService resourcesService;
@Autowired
private RedisSessionDAO redisSessionDAO;
/**
* 初始化权限
*/
public Map<String, String> loadFilterChainDefinitions() {
// 权限控制map.从数据库获取
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
filterChainDefinitionMap.put("/logout", "logout");
filterChainDefinitionMap.put("/css/**","anon");
filterChainDefinitionMap.put("/js/**","anon");
filterChainDefinitionMap.put("/img/**","anon");
filterChainDefinitionMap.put("/user/**","anon");
filterChainDefinitionMap.put("/font-awesome/**","anon");
// Map<String,Object> map = new HashMap<>();
// List<SysPermission> resourcesList = resourcesService.list(map);
// for(SysPermission resources:resourcesList){
//
// if (StringUtil.isNotEmpty(resources.getUrl())) {
// String permission = "perms[" + resources.getUrl()+ "]";
// filterChainDefinitionMap.put(resources.getUrl(),permission);
// }
// }
filterChainDefinitionMap.put("/**", "authc");
return filterChainDefinitionMap;
}

/**
* 重新加载权限
*/
public void updatePermission() {

synchronized (shiroFilterFactoryBean) {

AbstractShiroFilter shiroFilter = null;
try {
shiroFilter = (AbstractShiroFilter) shiroFilterFactoryBean
.getObject();
} catch (Exception e) {
throw new RuntimeException(
"get ShiroFilter from shiroFilterFactoryBean error!");
}

PathMatchingFilterChainResolver filterChainResolver = (PathMatchingFilterChainResolver) shiroFilter
.getFilterChainResolver();
DefaultFilterChainManager manager = (DefaultFilterChainManager) filterChainResolver
.getFilterChainManager();

// 清空老的权限控制
manager.getFilterChains().clear();

shiroFilterFactoryBean.getFilterChainDefinitionMap().clear();
shiroFilterFactoryBean
.setFilterChainDefinitionMap(loadFilterChainDefinitions());
// 重新构建生成
Map<String, String> chains = shiroFilterFactoryBean
.getFilterChainDefinitionMap();
for (Map.Entry<String, String> entry : chains.entrySet()) {
String url = entry.getKey();
String chainDefinition = entry.getValue().trim()
.replace(" ", "");
manager.createChain(url, chainDefinition);
}

System.out.println("更新权限成功!!");
}
}

/**
* 根据userId 清除当前session存在的用户的权限缓存
* @param userIds 已经修改了权限的userId
*/
/* public void clearUserAuthByUserId(List<Integer> userIds){
if(null == userIds || userIds.size() == 0) return ;
//获取所有session
Collection<Session> sessions = redisSessionDAO.getActiveSessions();
//定义返回
List<SimplePrincipalCollection> list = new ArrayList<SimplePrincipalCollection>();
for (Session session:sessions){
//获取session登录信息。
Object obj = session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
if(null != obj && obj instanceof SimplePrincipalCollection){
//强转
SimplePrincipalCollection spc = (SimplePrincipalCollection)obj;
//判断用户,匹配用户ID。
obj = spc.getPrimaryPrincipal();
if(null != obj && obj instanceof User){
User user = (User) obj;
System.out.println("user:"+user);
//比较用户ID,符合即加入集合
if(null != user && userIds.contains(user.getId())){
list.add(spc);
}
}
}
}
RealmSecurityManager securityManager =
(RealmSecurityManager) SecurityUtils.getSecurityManager();
MyShiroRealm realm = (MyShiroRealm)securityManager.getRealms().iterator().next();
for (SimplePrincipalCollection simplePrincipalCollection : list) {
realm.clearCachedAuthorizationInfo(simplePrincipalCollection);
}
}*/
}

+ 9
- 0
mallinkAdmin/src/main/java/com/iformall/shiro/UserSession.java Просмотреть файл

@@ -0,0 +1,9 @@
package com.iformall.shiro;

public class UserSession {
public static String userInfo="userSession";
public static String userId ="userSessionId";

}

+ 6
- 0
mallinkAdmin/src/main/java/com/iformall/utils/Constant.java Просмотреть файл

@@ -0,0 +1,6 @@
package com.iformall.utils;

public class Constant {

public static final String fileDirectory="./uploads";
}

+ 61
- 0
mallinkAdmin/src/main/java/com/iformall/utils/ShiroUtils.java Просмотреть файл

@@ -0,0 +1,61 @@
package com.iformall.utils;

import com.iformall.common.ErrorCode;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.exception.MallinkException;
import com.iformall.shiro.UserSession;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

/**
* Shiro工具类
*
* @author stormeye.wu
* @email wugq@mippoint.com
* @date 2016年11月12日 上午9:49:19
*/
public class ShiroUtils {

public static Session getSession() {
return SecurityUtils.getSubject().getSession();
}

public static Subject getSubject() {
return SecurityUtils.getSubject();
}

public static MallUserInfo getUserInfo() {
return (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo);
}

public static Long getUserId() {
return getUserInfo().getId();
}

public static void setSessionAttribute(Object key, Object value) {
getSession().setAttribute(key, value);
}

public static Object getSessionAttribute(Object key) {
return getSession().getAttribute(key);
}

public static boolean isLogin() {
return SecurityUtils.getSubject().getPrincipal() != null;
}

public static void logout() {
SecurityUtils.getSubject().logout();
}

public static String getKaptcha(String key) {
Object kaptcha = getSessionAttribute(key);
if (kaptcha == null) {
throw new MallinkException(ErrorCode.KAPCHA_NOT_VALID);
}
getSession().removeAttribute(key);
return kaptcha.toString();
}

}

+ 0
- 24
mallinkAdmin/src/main/java/com/simple/UserApplication.java Просмотреть файл

@@ -1,24 +0,0 @@
package com.simple;

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* @author chenkx
* @date 2017-12-26
*/
@SpringBootApplication
@MapperScan(basePackages = {"com.simple.mapper"})
@EnableSwagger2
@EnableEncryptableProperties

public class UserApplication {

public static void main(String[] args) {
SpringApplication.run(UserApplication.class, args);
}
}

+ 0
- 52
mallinkAdmin/src/main/java/com/simple/config/AwsProperty.java Просмотреть файл

@@ -1,52 +0,0 @@
package com.simple.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* @author Stormeye
*/
@Component
@ConfigurationProperties(prefix = "aws")
public class AwsProperty {
// AWS ACCESS KEY
private String access;

private String secret;

private String clientRegion;

private String bucketName;

public String getAccess() {
return access;
}

public void setAccess(String access) {
this.access = access;
}

public String getSecret() {
return secret;
}

public void setSecret(String secret) {
this.secret = secret;
}

public String getClientRegion() {
return clientRegion;
}

public void setClientRegion(String clientRegion) {
this.clientRegion = clientRegion;
}

public String getBucketName() {
return bucketName;
}

public void setBucketName(String bucketName) {
this.bucketName = bucketName;
}
}

+ 0
- 22
mallinkAdmin/src/main/java/com/simple/config/CorsConfig.java Просмотреть файл

@@ -1,22 +0,0 @@
package com.simple.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
* Created by Administrator on 2017/8/9.
*/
@Configuration
public class CorsConfig extends WebMvcConfigurerAdapter {

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowCredentials(true)
.allowedMethods("GET", "POST", "DELETE", "PUT")
.maxAge(3600);
}

}

+ 0
- 32
mallinkAdmin/src/main/java/com/simple/config/KaptchaConfig.java Просмотреть файл

@@ -1,32 +0,0 @@
package com.simple.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;


/**
* 生成验证码配置
*
* @author stormeye.wu
* @email wugq@mippoint.com
* @date 2017-04-20 19:22
*/
@Configuration
public class KaptchaConfig {

@Bean
public DefaultKaptcha producer() {
Properties properties = new Properties();
properties.put("kaptcha.border", "no");
properties.put("kaptcha.textproducer.font.color", "black");
properties.put("kaptcha.textproducer.char.space", "5");
Config config = new Config(properties);
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}

+ 0
- 24
mallinkAdmin/src/main/java/com/simple/config/PayProperty.java Просмотреть файл

@@ -1,24 +0,0 @@
package com.simple.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* @author Stormeye
*/
@Component
@ConfigurationProperties(prefix = "pay")
public class PayProperty {
/**
* 真实支付
*/
private boolean real;

public boolean isReal() {
return real;
}

public void setReal(boolean real) {
this.real = real;
}
}

+ 0
- 50
mallinkAdmin/src/main/java/com/simple/config/RedisConfig.java Просмотреть файл

@@ -1,50 +0,0 @@
package com.simple.config;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
* Created by yangqj on 2017/4/30.
*/
@Configuration
@EnableCaching
public class RedisConfig extends CachingConfigurerSupport {
@Value("${spring.redis.host}")
private String host;

@Value("${spring.redis.port}")
private int port;

@Value("${spring.redis.timeout}")
private int timeout;

@Value("${spring.redis.pool.max-idle}")
private int maxIdle;

@Value("${spring.redis.pool.max-wait}")
private long maxWaitMillis;
@Value("${spring.redis.password}")
private String password;

@Bean
public JedisPool redisPoolFactory() {
Logger.getLogger(getClass()).info("JedisPool注入成功!!");
Logger.getLogger(getClass()).info("redis地址:" + host + ":" + port);
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxIdle(maxIdle);
jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);

JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout,password);

return jedisPool;
}


}

+ 0
- 58
mallinkAdmin/src/main/java/com/simple/config/RestFilter.java Просмотреть файл

@@ -1,58 +0,0 @@
package com.simple.config;
import java.io.IOException;
import java.util.Optional;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 前后端分离RESTful接口过滤器
*
* @author xuguoqin
*
*/
public class RestFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = null;
if (request instanceof HttpServletRequest) {
req = (HttpServletRequest) request;
}
HttpServletResponse res = null;
if (response instanceof HttpServletResponse) {
res = (HttpServletResponse) response;
}
if (req != null && res != null) {
//设置允许传递的参数
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
//设置允许带上cookie
res.setHeader("Access-Control-Allow-Credentials", "true");
String origin = Optional.ofNullable(req.getHeader("Origin")).orElse(req.getHeader("Referer"));
//设置允许的请求来源
res.setHeader("Access-Control-Allow-Origin", origin);
//设置允许的请求方法
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS");
}
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}

Некоторые файлы не были показаны из-за большого количества измененных файлов

Загрузка…
Отмена
Сохранить