Browse Source

init

private_deployment
xhxu 2 years ago
parent
commit
db9b8fc8ff
100 changed files with 14477 additions and 2 deletions
  1. +2
    -2
      .idea/compiler.xml
  2. +424
    -0
      pom.xml
  3. +78
    -0
      suimang-mybatis/pom.xml
  4. +69
    -0
      suimang-mybatis/src/main/java/com/iformall/plugin/MyBatisItercepters.java
  5. +18
    -0
      suimang-mybatis/src/main/java/com/iformall/plugin/MyBatisPlus.java
  6. +199
    -0
      suimangAdmin/pom.xml
  7. +79
    -0
      suimangAdmin/src/main/java/com/iformall/AdminApplication.java
  8. +10
    -0
      suimangAdmin/src/main/java/com/iformall/annotation/SystemControllerLog.java
  9. +10
    -0
      suimangAdmin/src/main/java/com/iformall/annotation/SystemServiceLog.java
  10. +16
    -0
      suimangAdmin/src/main/java/com/iformall/annotation/TenantIgnore.java
  11. +14
    -0
      suimangAdmin/src/main/java/com/iformall/annotation/UserDataRuleAnnotation.java
  12. +52
    -0
      suimangAdmin/src/main/java/com/iformall/config/AwsProperty.java
  13. +32
    -0
      suimangAdmin/src/main/java/com/iformall/config/KaptchaConfig.java
  14. +31
    -0
      suimangAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java
  15. +26
    -0
      suimangAdmin/src/main/java/com/iformall/config/MyExecutorConfig.java
  16. +347
    -0
      suimangAdmin/src/main/java/com/iformall/config/RedisConfig.java
  17. +58
    -0
      suimangAdmin/src/main/java/com/iformall/config/RestFilter.java
  18. +24
    -0
      suimangAdmin/src/main/java/com/iformall/config/RestTemplateConfig.java
  19. +318
    -0
      suimangAdmin/src/main/java/com/iformall/config/ShiroConfig.java
  20. +31
    -0
      suimangAdmin/src/main/java/com/iformall/config/ShiroLoginFilter.java
  21. +61
    -0
      suimangAdmin/src/main/java/com/iformall/config/Swagger2Config.java
  22. +164
    -0
      suimangAdmin/src/main/java/com/iformall/config/WebConfig.java
  23. +32
    -0
      suimangAdmin/src/main/java/com/iformall/config/WechatMpConfig.java
  24. +59
    -0
      suimangAdmin/src/main/java/com/iformall/config/WechatWebProperties.java
  25. +89
    -0
      suimangAdmin/src/main/java/com/iformall/controller/base/BaseController.java
  26. +56
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/EnumController.java
  27. +40
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/MallSaleTypeController.java
  28. +72
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java
  29. +321
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java
  30. +317
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java
  31. +135
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxBrandController.java
  32. +239
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxCustomizeModuleController.java
  33. +73
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxGroupController.java
  34. +88
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxMallBuildingController.java
  35. +100
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxMallController.java
  36. +210
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxMapController.java
  37. +52
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxMerchantBUserController.java
  38. +445
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java
  39. +40
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxMerchantShopController.java
  40. +168
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxMiniappThemeController.java
  41. +130
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxProfitSharingReceiverApplyController.java
  42. +889
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxProjectConfigController.java
  43. +209
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxShopController.java
  44. +52
    -0
      suimangAdmin/src/main/java/com/iformall/controller/basic/WxTagsController.java
  45. +113
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/AliBusinessCircleOrderController.java
  46. +46
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/FengNiaoMapController.java
  47. +124
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/MarkingDataReportController.java
  48. +42
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/PushLimitController.java
  49. +189
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java
  50. +27
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/UeditorController.java
  51. +132
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxActivityController.java
  52. +114
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxActivityJoinController.java
  53. +109
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxBusinessCircleOrderController.java
  54. +216
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCampaignController.java
  55. +243
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCardPayController.java
  56. +104
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCashOutController.java
  57. +81
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponActionLogController.java
  58. +71
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponCarController.java
  59. +275
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java
  60. +739
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java
  61. +103
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponInjectController.java
  62. +164
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponOrderController.java
  63. +83
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponPasswordController.java
  64. +145
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponPresentController.java
  65. +74
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponSendConfigController.java
  66. +175
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java
  67. +92
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java
  68. +113
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxGameController.java
  69. +93
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxGameTemplateController.java
  70. +73
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxMerchantMicroPayController.java
  71. +85
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxMerchantPowerBillConfigController.java
  72. +152
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxMerchantSubsidyController.java
  73. +75
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxOpinionController.java
  74. +282
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxOrderController.java
  75. +70
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxOrderGroupController.java
  76. +123
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxPayOrderController.java
  77. +67
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxPowerBillAutoConfigController.java
  78. +91
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxPrepaymentController.java
  79. +280
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxPressBatchController.java
  80. +128
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxProfitSharingOrderController.java
  81. +87
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxQuestionController.java
  82. +176
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxQuestionOneselfController.java
  83. +84
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxRefundOrderController.java
  84. +110
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxSubsidyController.java
  85. +126
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxThirdPartyOrdersController.java
  86. +107
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxTopicController.java
  87. +48
    -0
      suimangAdmin/src/main/java/com/iformall/controller/market/WxUserCouponController.java
  88. +198
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/AsyncTask.java
  89. +169
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/BillDailyAsyncTask.java
  90. +342
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/ImportTemplateTask.java
  91. +192
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/MemCouponController.java
  92. +111
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/UserBasicInfoAddressController.java
  93. +675
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java
  94. +82
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserCarController.java
  95. +81
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserController.java
  96. +444
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserDataController.java
  97. +79
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserFromController.java
  98. +80
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserTagsController.java
  99. +200
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java
  100. +114
    -0
      suimangAdmin/src/main/java/com/iformall/controller/mem/WxLevelConfigController.java

+ 2
- 2
.idea/compiler.xml View File

@@ -6,6 +6,7 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="suimangVideo" />
<module name="suimangOcr" />
<module name="suimangSchedule" />
<module name="suimangService" />
@@ -15,10 +16,9 @@
<module name="suimangCApi" />
<module name="suimangAdmin" />
<module name="suimangMQConsumer" />
<module name="suimangCallback" />
<module name="suimangVideo" />
<module name="mallinkCApi" />
<module name="suimang-mybatis" />
<module name="suimangCallback" />
</profile>
</annotationProcessing>
</component>


+ 424
- 0
pom.xml View File

@@ -0,0 +1,424 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


<modelVersion>4.0.0</modelVersion>
<groupId>com.iformall</groupId>
<artifactId>suimang</artifactId>
<packaging>pom</packaging>
<version>1.0</version>

<modules>
<module>suimangOcr</module>
<module>suimang-mybatis</module>
<module>suimangService</module>
<module>suimangVideo</module>
<module>suimangCallback</module>
<module>suimangAdmin</module>
<module>suimangCApi</module>
<module>suimangSchedule</module>
<module>suimangMQConsumer</module>
</modules>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath/>
</parent>

<properties>
<weixin-java-common.version>3.7.0.B</weixin-java-common.version>
<weixin-java-mp.version>3.7.0.B</weixin-java-mp.version>
<weixin-java-miniapp.version>3.7.0.B</weixin-java-miniapp.version>
<weixin-java-pay.version>3.7.0.B</weixin-java-pay.version>
<weixin-java-open.version>3.7.0.B</weixin-java-open.version>
<quartz.version>2.3.0</quartz.version>
<log4j2.version>2.15.0</log4j2.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>

<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-process</artifactId>
<version>6.4.0</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>

<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.22</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- rocketmq -->
<dependency>
<groupId>org.rocketmq.spring.boot</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>26.0-jre</version>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.68</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>${quartz.version}</version>
<exclusions>
<exclusion>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
</exclusion>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java6</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-web</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.10.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.3</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
<!-- </dependencyManagement> -->
<!-- <dependencies> -->
<!-- <dependency> -->
<!-- <groupId>com.iformall</groupId> -->
<!-- <artifactId>base</artifactId> -->
<!-- <version>1.0</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>com.iformall</groupId> -->
<!-- <artifactId>freemarker</artifactId> -->
<!-- <version>1.0</version> -->
<!-- </dependency> -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.4.0</version>
</dependency>

<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>3.1.0</version>
</dependency>

<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>2.0.6</version>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.60</version>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.60</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>net.coobird</groupId> -->
<!-- <artifactId>thumbnailator</artifactId> -->
<!-- <version>0.4.8</version> -->
<!-- </dependency> -->

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>

<!--easypoi-->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>4.1.3.A</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.10</version>
</dependency>

<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-common</artifactId>
<version>${weixin-java-common.version}</version>
</dependency>

<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
<version>${weixin-java-miniapp.version}</version>
</dependency>

<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId>
<version>${weixin-java-mp.version}</version>
</dependency>

<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-pay</artifactId>
<version>${weixin-java-pay.version}</version>
</dependency>

<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-open</artifactId>
<version>${weixin-java-open.version}</version>
</dependency>

<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot</artifactId>
<version>2.1.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.belerweb/pinyin4j -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>

<!--阿里云的短信服务SDK-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>2.1.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.aliyun.oss/aliyun-sdk-oss -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-jpeg -->
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-jpeg</artifactId>
<version>3.6</version>
</dependency>

<!-- <dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency> -->


</dependencies>

<!--
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
-->
</project>

+ 78
- 0
suimang-mybatis/pom.xml View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.iformall</groupId>
<artifactId>suimang-mybatis</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<version>3.2.0</version>
</dependency>
<!--测试期间依赖-->
<dependency>
<scope>test</scope>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.22</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>utf-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<!--跳过单元测试-->
<skip>false</skip>
<!--单元测试乱码-->
<forkMode>once</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>

</plugins>
</build>
</project>

+ 69
- 0
suimang-mybatis/src/main/java/com/iformall/plugin/MyBatisItercepters.java View File

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

import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.session.ResultHandler;

import com.iformall.plugin.entity.ChainValue;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*共享数据库的多租户系统实现
* Created by Stormeye on 2018/10/22.
*/
@Intercepts({
//@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
//@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})
@Signature( method = "prepare", type = StatementHandler.class,args = {Connection.class, Integer.class}),
@Signature(method = "query", type = StatementHandler.class, args = {java.sql.Statement.class, ResultHandler.class})
})
public class MyBatisItercepters implements Interceptor {

private List<MyBatisPlus> plugins;

public MyBatisItercepters(){
}

public void setPlugins(List<MyBatisPlus> plugins) {
this.plugins = plugins;
}

public Object intercept(Invocation invocation) throws Throwable {
if (null != plugins && plugins.size() > 0 ) {
// 能从cookie或者session获取到tenantId
Map<String,ChainValue> chainValues = new HashMap<String,ChainValue>();
for (int i = 0 ; i < plugins.size() ; i++) {
MyBatisPlus plug = plugins.get(i);
invokeIntercept(plug, invocation, chainValues);
}
}
return invocation.proceed();
}
private void invokeIntercept(MyBatisPlus plug,Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable {
Map<String,ChainValue> resultMap = plug.intercept(invocation, chainMap);
if (null != resultMap) {
chainMap.putAll(resultMap);
}
}

/**
* 生成代理对象
*
* @param target
* @return
*/
@Override
public Object plugin(Object target) {
if (target instanceof StatementHandler) {
return Plugin.wrap(target, this);
} else {
return target;
}
}
}

+ 18
- 0
suimang-mybatis/src/main/java/com/iformall/plugin/MyBatisPlus.java View File

@@ -0,0 +1,18 @@
package com.iformall.plugin;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.plugin.Invocation;

import com.iformall.plugin.entity.ChainValue;

public interface MyBatisPlus {

/**
* @param invocation
* @return Map<coloumn,value>
* @throws Throwable
*/
public Map<String,ChainValue> intercept(Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable;
}

+ 199
- 0
suimangAdmin/pom.xml View File

@@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>suimang</artifactId>
<groupId>com.iformall</groupId>
<version>1.0</version>
</parent>

<artifactId>suimangAdmin</artifactId>

<properties>
<weixin-java-mp.version>3.7.0.B</weixin-java-mp.version>
<weixin-java-open.version>3.7.0.B</weixin-java-open.version>
</properties>

<dependencies>
<dependency>
<groupId>com.iformall</groupId>
<artifactId>suimangService</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.iformall</groupId>
<artifactId>suimangVideo</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>

<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.3</version>
</dependency>

<dependency>
<groupId>com.github.axet</groupId>
<artifactId>kaptcha</artifactId>
<version>0.0.9</version>
</dependency>

<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>5.2.4</version>
</dependency>

<!-- ocr -->
<dependency>
<groupId>com.iformall</groupId>
<artifactId>suimangOcr</artifactId>
<version>1.0</version>
</dependency>


</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<layout>ZIP</layout>
<excludeGroupIds>
antlr,
ch.qos.logback,
com.alibaba,
com.amazonaws,
com.baomidou,
com.mchange,
com.fasterxml.jackson.core,
com.fasterxml.jackson.dataformat,
com.fasterxml.jackson.datatype,
com.fasterxml.jackson.module,
com.fasterxml.uuid,
com.fasterxml,
com.github.axet,
com.github.jsqlparser,
com.github.pagehelper,
com.github.ulisesbocchio,
com.github.virtuald,
com.google.code.findbugs,
com.google.code.gson,
com.google.errorprone,
com.google.guava,
com.google.protobuf,
com.google.zxing,
com.jayway.jsonpath,
com.jhlabs,
com.puppycrawl.tools,
com.rabbitmq,
com.squareup.okhttp3,
com.squareup.okio,
com.sun,
com.sun.mail,
com.thoughtworks.xstream,
com.zaxxer,
commons-beanutils,
commons-cli,
commons-codec,
commons-collections,
commons-fileupload,
commons-io,
commons-logging,
io.lettuce,
io.netty,
io.projectreactor,
io.springfox,
io.swagger,
io.undertow,
javax.activation,
javax.annotation,
javax.mail,
javax.persistence,
javax.servlet,
javax.validation,
javax.xml.bind,
javax.xml.soap,
javax.xml.ws,
joda-time,
junit,
mysql,
net.bytebuddy,
net.minidev,
net.sf.dozer,
net.sf.saxon,
ognl,
org.antlr,
org.apache.commons,
org.apache.httpcomponents,
org.apache.logging.log4j,
org.apache.poi,
org.apache.poi.wso2,
org.apache.rocketmq,
org.apache.shiro,
org.apache.tomcat.embed,
org.apache.xmlbeans,
org.aspectj,
org.assertj,
org.bouncycastle,
org.checkerframework,
org.codehaus.mojo,
org.crazycake,
org.dom4j,
org.flowable,
org.flywaydb,
org.glassfish,
org.hibernate.validator,
org.jasypt,
org.javassist,
org.jboss.logging,
org.jboss.spec.javax.annotation,
org.jboss.spec.javax.websocket,
org.jboss.xnio,
org.jdom,
org.jodd,
org.jvnet.mimepull,
org.jvnet.staxex,
org.mapstruct,
org.mockito,
org.mybatis,
org.mybatis.generator,
org.mybatis.spring.boot,
org.ow2.asm,
org.projectlombok,
org.quartz-scheduler,
org.reactivestreams,
org.reflections,
org.rocketmq.spring.boot,
org.slf4j,
org.springframework,
org.springframework.amqp,
org.springframework.boot,
org.springframework.data,
org.springframework.retry,
org.springframework.ws,
org.yaml,
redis.clients,
software.amazon.ion,
tk.mybatis,
xmlpull,
xpp3
</excludeGroupIds>
</configuration>
</plugin>
</plugins>
</build>

</project>

+ 79
- 0
suimangAdmin/src/main/java/com/iformall/AdminApplication.java View File

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

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.rocketmq.starter.annotation.EnableRocketMQ;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* @author chenkx
* @date 2017-12-26
*/
@SpringBootApplication
@MapperScan(basePackages = {"com.iformall.mapper"})
@EnableSwagger2
@EnableEncryptableProperties
@EnableAsync
@EnableRocketMQ
@EnableAspectJAutoProxy(exposeProxy = true)
public class AdminApplication {

@Value("${fm.exception}")
private boolean fmException;

@Value("${fm.exception_emails}")
private String fmExceptionEmails;

@Value("${fm.open}")
private boolean fmOpen;

@Value("${fm.upload_dir}")
private String uploadDir;

@Value("${fm.ocr_data}")
private String ocrData;
@Value("${fm.videoType}")
private String videoType;
@Bean
public boolean isFmException() {
return fmException;
}

@Bean
public String fmExceptionEmails() {
return fmExceptionEmails;
}

@Bean
public boolean isFmOpen() {
return fmOpen;
}

@Bean
public String fmUploadDir() {
return uploadDir;
}
@Bean
public String ocrData() {
return ocrData;
}
@Bean
public String videoType() {
return videoType;
}

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

+ 10
- 0
suimangAdmin/src/main/java/com/iformall/annotation/SystemControllerLog.java View File

@@ -0,0 +1,10 @@
package com.iformall.annotation;

import java.lang.annotation.*;

@Target({ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface SystemControllerLog {
String description() default "";
}

+ 10
- 0
suimangAdmin/src/main/java/com/iformall/annotation/SystemServiceLog.java View File

@@ -0,0 +1,10 @@
package com.iformall.annotation;

import java.lang.annotation.*;

@Target({ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface SystemServiceLog {
String description() default "";
}

+ 16
- 0
suimangAdmin/src/main/java/com/iformall/annotation/TenantIgnore.java View File

@@ -0,0 +1,16 @@
package com.iformall.annotation;

import java.lang.annotation.*;

/**
* api接口,忽略Token验证
* @author stormeye.wu
* @email wuguoqiang@iformall.com
* @date 2017-03-23 15:44
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface TenantIgnore {

}

+ 14
- 0
suimangAdmin/src/main/java/com/iformall/annotation/UserDataRuleAnnotation.java View File

@@ -0,0 +1,14 @@
package com.iformall.annotation;

import java.lang.annotation.*;

/**
* @author gongbiao
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface UserDataRuleAnnotation {

String value() default "";
}

+ 52
- 0
suimangAdmin/src/main/java/com/iformall/config/AwsProperty.java View File

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

+ 32
- 0
suimangAdmin/src/main/java/com/iformall/config/KaptchaConfig.java View File

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

+ 31
- 0
suimangAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java View File

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

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.iformall.plugin.MyBatisItercepters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@EnableTransactionManagement
@Configuration
public class MyBatisConfiguration extends BaseMyBatisConfiguration{


@Bean
public MyBatisItercepters intercepters() {
return allIntercepters();
}

@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor page = new PaginationInterceptor();
page.setDialectType("mysql");
return page;
}

@Bean
public OptimisticLockerInterceptor optimisticLockerInterceptor() {
return new OptimisticLockerInterceptor();
}
}

+ 26
- 0
suimangAdmin/src/main/java/com/iformall/config/MyExecutorConfig.java View File

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

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.ThreadPoolExecutor;

@Configuration
public class MyExecutorConfig {
/**
* 自定义异步线程池
*
* @return
*/
@Bean
public AsyncTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("Anno-Executor");
executor.setMaxPoolSize(100);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
return executor;
}
}


+ 347
- 0
suimangAdmin/src/main/java/com/iformall/config/RedisConfig.java View File

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

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseCUserEntity;
import com.iformall.domain.vo.WxCouponCVo;
import com.iformall.domain.vo.WxCouponChannelVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
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 org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import java.time.Duration;
import java.util.*;

/**
* Created by Stormeye on 2018/10/1.
*/
@Configuration
@EnableCaching
public class RedisConfig extends CachingConfigurerSupport {

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

//缓存管理器
@Bean
public CacheManager cacheManager(RedisConnectionFactory connectionFactory) {
/*
//user信息缓存配置
RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)).disableCachingNullValues().prefixKeysWith("user");
Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>();
redisCacheConfigurationMap.put("user", userCacheConfiguration);
//初始化一个RedisCacheWriter
RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory);
// 设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现
// ClassLoader loader = this.getClass().getClassLoader();
// JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader);
// RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer);
// RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair);
RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig();
//设置默认超过期时间是30秒
defaultCacheConfig.entryTtl(Duration.ofSeconds(30));
//初始化RedisCacheManager
RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap);
return cacheManager;
*/
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); // 生成一个默认配置,通过config对象即可对缓存进行自定义配置
config = config.entryTtl(Duration.ofMinutes(1)) // 设置缓存的默认过期时间,也是使用Duration设置
.disableCachingNullValues(); // 不缓存空值

// 设置一个初始化的缓存空间set集合
Set<String> cacheNames = new HashSet<>();
cacheNames.add("my-redis-cache1");
cacheNames.add("my-redis-cache2");

// 对每个缓存空间应用不同的配置
Map<String, RedisCacheConfiguration> configMap = new HashMap<>();
configMap.put("my-redis-cache1", config);
configMap.put("my-redis-cache2", config.entryTtl(Duration.ofSeconds(120)));

RedisCacheManager cacheManager = RedisCacheManager.builder(connectionFactory) // 使用自定义的缓存配置初始化一个cacheManager
.initialCacheNames(cacheNames) // 注意这两句的调用顺序,一定要先调用该方法设置初始化的缓存名,再初始化相关的配置
.withInitialCacheConfigurations(configMap)
.build();
return cacheManager;
}

@Bean("pushLimitRedisTemplate")
public RedisTemplate<String, PushLimit> getPushLimitRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PushLimit> template = new RedisTemplate<String, PushLimit>();

Jackson2JsonRedisSerializer<PushLimit> j = new Jackson2JsonRedisSerializer<PushLimit>(PushLimit.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("scoreRuleRedisTemplate")
public RedisTemplate<String, WxScoreRules> getScoreRuleRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, WxScoreRules> template = new RedisTemplate<String, WxScoreRules>();

Jackson2JsonRedisSerializer<WxScoreRules> j = new Jackson2JsonRedisSerializer<WxScoreRules>(WxScoreRules.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("openRedisTemplate")
public RedisTemplate<String, String> getWeChatOpen(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, String> template = new RedisTemplate<String, String>();

// value值的序列化
template.setValueSerializer(new StringRedisSerializer());

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("cuserTokenRedisTemplate")
public RedisTemplate<String, WxCUser> getCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, WxCUser> template = new RedisTemplate<String, WxCUser>();

Jackson2JsonRedisSerializer<WxCUser> j = new Jackson2JsonRedisSerializer<WxCUser>(WxCUser.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("baseCUserTokenRedisTemplate")
public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>();

Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("mallRedisTemplate")
public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>();

Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("subMallListRedisTemplate")
public RedisTemplate<String, List<WxMall>> getSubMallListRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, List<WxMall>> template = new RedisTemplate<String, List<WxMall>>();

Jackson2JsonRedisSerializer<List> j = new Jackson2JsonRedisSerializer<List>(List.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("couponChannelRedisTemplate")
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>();

Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);

// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("buserTokenRedisTemplate")
public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, WxBuser> template = new RedisTemplate();

Jackson2JsonRedisSerializer<WxBuser> j = new Jackson2JsonRedisSerializer(WxBuser.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);

// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("couponDetailRedisTemplate")
public RedisTemplate<String, WxCouponCVo> getCouponDetailRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, WxCouponCVo> template = new RedisTemplate<String, WxCouponCVo>();

Jackson2JsonRedisSerializer<WxCouponCVo> j = new Jackson2JsonRedisSerializer<WxCouponCVo>(WxCouponCVo.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}

@Bean("cUserBasicInfoRedisTemplate")
public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>();

Jackson2JsonRedisSerializer<WxCUserBasicInfo> j = new Jackson2JsonRedisSerializer<WxCUserBasicInfo>(WxCUserBasicInfo.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);
// value值的序列化
template.setValueSerializer(j);
template.setHashKeySerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());

template.setConnectionFactory(connectionFactory);
return template;
}
@Bean("objectCommonRedisTemplate")
public RedisTemplate<String, Object> getObjectValueOperations(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
Jackson2JsonRedisSerializer<Object> j = new Jackson2JsonRedisSerializer<Object>(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
j.setObjectMapper(om);

// value值的序列化
template.setValueSerializer(j);
template.setHashValueSerializer(j);

// key的序列化
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.afterPropertiesSet();
return template;
}

}

+ 58
- 0
suimangAdmin/src/main/java/com/iformall/config/RestFilter.java View File

@@ -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
suimangAdmin/src/main/java/com/iformall/config/RestTemplateConfig.java View File

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

+ 318
- 0
suimangAdmin/src/main/java/com/iformall/config/ShiroConfig.java View File

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

import com.iformall.service.MallPermissionService;
import com.iformall.shiro.MyRetryLimitCredentialsMatcher;
import com.iformall.shiro.MyShiroRealm;
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.Qualifier;
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 {

@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
* <p>
* 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());
//filters.put("authc", new MyFormAuthenticationFilter());
shiroFilterFactoryBean.setFilters(filters);
// 如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面
shiroFilterFactoryBean.setLoginUrl("/#/");
// 登录成功后要跳转的链接

shiroFilterFactoryBean.setSuccessUrl("/usersPage");
//未授权界面;
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
//拦截器.
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();

//filterChainDefinitionMap.put("/ue/**", "anon");
//filterChainDefinitionMap.put("/config.json", "anon");
// login
filterChainDefinitionMap.put("/doLogin/**", "anon");
filterChainDefinitionMap.put("/bHidLogin/**", "anon");
filterChainDefinitionMap.put("/sendLoginPhoneCode/**", "anon");
filterChainDefinitionMap.put("/doLoginByPhone/**", "anon");
filterChainDefinitionMap.put("/wechat/login", "anon"); // 微信第三方登录callback
filterChainDefinitionMap.put("/wechat/callback", "anon"); // 微信网页登录回调
filterChainDefinitionMap.put("/wechat/weChatUserLogin", "anon"); // 微信第三方登录
// 验证码
filterChainDefinitionMap.put("/captcha.jpg", "anon");
// 官网
filterChainDefinitionMap.put("/wxMallApply/add", "anon");
// callback
filterChainDefinitionMap.put("/wxPay/notify/**", "anon"); // 支付回调
filterChainDefinitionMap.put("/wxPayBill/notify/**", "anon");
filterChainDefinitionMap.put("/wxMsgCallback/**", "anon");
filterChainDefinitionMap.put("/user/sendvalidationcode", "anon");
filterChainDefinitionMap.put("/user/updatepwd", "anon");
filterChainDefinitionMap.put("/carCallback/**", "anon");
filterChainDefinitionMap.put("/wxMallApply/sendvalidationcode", "anon");

// 补发消息
filterChainDefinitionMap.put("/wxCoupon/updateStokeAndValidDate", "anon");
// static files
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);
// }
// }
// swagger-ui
filterChainDefinitionMap.put("/swagger-ui.html", "anon");
filterChainDefinitionMap.put("/v2/**", "anon");
filterChainDefinitionMap.put("/swagger-resources/**", "anon");
filterChainDefinitionMap.put("/webjars/**", "anon");

filterChainDefinitionMap.put("/version", "anon");


//配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了
filterChainDefinitionMap.put("/logout", "authc");

// 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
*/
public MyRetryLimitCredentialsMatcher hashedCredentialsMatcher() {
MyRetryLimitCredentialsMatcher hashedCredentialsMatcher = new MyRetryLimitCredentialsMatcher();

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();
//设置session过期时间为1小时(单位:毫秒),默认为30分钟
sessionManager.setGlobalSessionTimeout(60 * 60 * 1000);
sessionManager.setSessionValidationSchedulerEnabled(true);
sessionManager.setSessionIdUrlRewritingEnabled(false);

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
suimangAdmin/src/main/java/com/iformall/config/ShiroLoginFilter.java View File

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

+ 61
- 0
suimangAdmin/src/main/java/com/iformall/config/Swagger2Config.java View File

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.paths.RelativePathProvider;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.servlet.ServletContext;
import java.util.ArrayList;
import java.util.List;

//参考:http://blog.csdn.net/catoop/article/details/50668896
@Configuration
@EnableSwagger2
public class Swagger2Config {

@Autowired
private ServletContext servletContext;

@Bean
public Docket createRestApi() {
ParameterBuilder tokenPar = new ParameterBuilder();
List<Parameter> pars = new ArrayList<Parameter>();
//增加一个request的header参数
tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
pars.add(tokenPar.build());
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.iformall.controller"))
.paths(PathSelectors.any())
.build()
.globalOperationParameters(pars)
.pathProvider(new RelativePathProvider(servletContext) {
@Override
public String getApplicationBasePath() {
return "/api";
}
});
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("a端 api")
.description("a api")
.termsOfServiceUrl("http://localhost:7000")
.version("2.0")
.build();
}

}

+ 164
- 0
suimangAdmin/src/main/java/com/iformall/config/WebConfig.java View File

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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationConfig;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.iformall.file.aliyun.AliyunOSS;
import com.iformall.interceptor.CurrentTenantInterceptor;
import com.iformall.interceptor.HttpServletRequestWrapperFilter;
import com.iformall.interceptor.RequestInterceptor;
import com.iformall.service.MallResourceService;
import com.iformall.ueditor.ActionEnter;
import com.iformall.ueditor.ConfigManager;
import com.iformall.ueditor.UEditorConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.*;

import javax.servlet.Filter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.List;

@Configuration
@EnableWebMvc
@EnableConfigurationProperties({UEditorConfig.class, AwsProperty.class})
public class WebConfig implements WebMvcConfigurer {
@Autowired
private UEditorConfig uEditorConfig;

@Autowired
private AwsProperty awsProperty;

@Autowired
private RequestInterceptor requestInterceptor;
@Autowired
private CurrentTenantInterceptor tenantInterceptor;

@Autowired
private MallResourceService mallResourceService;

@Autowired
private AliyunOSS aliyunOSS;

@Bean
@ConditionalOnMissingBean(ActionEnter.class)
public ActionEnter actionEnter() {
ActionEnter actionEnter = new ActionEnter(ConfigManager.getInstance(uEditorConfig, awsProperty, mallResourceService, aliyunOSS));
return actionEnter;
}

@Bean
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
final CorsConfiguration corsConfiguration = new CorsConfiguration();
// 允许cookies跨域
corsConfiguration.setAllowCredentials(true);
// 允许向该服务器提交请求的URI, *表示全部允许
corsConfiguration.addAllowedOrigin("*");
// 允许访问的头信息,*表示全部
corsConfiguration.addAllowedHeader("*");
// 允许提交请求的方法, *表示全部允许
corsConfiguration.addAllowedMethod("*");
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
return new CorsFilter(urlBasedCorsConfigurationSource);
}

/**
* 用于处理编码问题
*
* @return
*/
@Bean("myCharacterEncodingFilter")
public Filter characterEncodingFilter() {
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(true);
return characterEncodingFilter;
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(requestInterceptor).addPathPatterns("/**");
registry.addInterceptor(tenantInterceptor).addPathPatterns("/**");
}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
// ueditor
registry.addResourceHandler("/upload/**")
.addResourceLocations("file:" + uEditorConfig.getUploadPath());
registry.addResourceHandler("/config.json").addResourceLocations("classpath:/config.json");

}

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

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
//ObjectMapper 是Jackson库的主要类。它提供一些功能将转换成Java对象匹配JSON结构,反之亦然
ObjectMapper objectMapper = new ObjectMapper();
SimpleModule simpleModule = new SimpleModule();

//不显示为null的字段
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

DeserializationConfig dc = objectMapper.getDeserializationConfig();
// 设置反序列化日期格式、忽略不存在get、set的属性
objectMapper.setConfig(
dc.with(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"))
.without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
);

//序列化将Long转String类型
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
SimpleModule bigIntegerModule = new SimpleModule();
//序列化将BigInteger转String类型
bigIntegerModule.addSerializer(BigInteger.class, ToStringSerializer.instance);
SimpleModule bigDecimalModule = new SimpleModule();
//序列化将BigDecimal转String类型
bigDecimalModule.addSerializer(BigDecimal.class, ToStringSerializer.instance);
objectMapper.registerModule(simpleModule);
objectMapper.registerModule(bigDecimalModule);
objectMapper.registerModule(bigIntegerModule);
jackson2HttpMessageConverter.setObjectMapper(objectMapper);
converters.add(jackson2HttpMessageConverter);
}

@Bean
public FilterRegistrationBean<HttpServletRequestWrapperFilter> Filters() {
FilterRegistrationBean<HttpServletRequestWrapperFilter> registrationBean = new FilterRegistrationBean<HttpServletRequestWrapperFilter>();
registrationBean.setFilter(new HttpServletRequestWrapperFilter());
registrationBean.addUrlPatterns("/*");
registrationBean.setName("koalaSignFilter");
return registrationBean;
}
}

+ 32
- 0
suimangAdmin/src/main/java/com/iformall/config/WechatMpConfig.java View File

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

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class WechatMpConfig {

@Autowired
private WechatWebProperties wechatWebProperties;

@Bean
public WxMpService wxMpService() {
//创建WxMpService实例并设置appid和sectret
WxMpService wxMpService = new WxMpServiceImpl();
//这里的设置方式是跟着这个sdk的文档写的
wxMpService.setWxMpConfigStorage(wxConfigProvider());
return wxMpService;
}

public WxMpConfigStorage wxConfigProvider(){
WxMpDefaultConfigImpl wxConfigProvider = new WxMpDefaultConfigImpl();
wxConfigProvider.setAppId(wechatWebProperties.getAppId());
wxConfigProvider.setSecret(wechatWebProperties.getSecret());
return wxConfigProvider;
}
}

+ 59
- 0
suimangAdmin/src/main/java/com/iformall/config/WechatWebProperties.java View File

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

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* Stormeye
*/
@Component
@ConfigurationProperties(prefix = "wechat.web")
public class WechatWebProperties {
/**
* 设置微信第三方平台-微信登录的web应用appid
*/
private String appId;

/**
* 设置微信第三方平台-微信登录的web应用app secret
*/
private String secret;

/**
* 网页URL
* @return
*/
private String url;

public String getAppId() {
return appId;
}

public void setAppId(String appId) {
this.appId = appId;
}

public String getSecret() {
return secret;
}

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

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this,
ToStringStyle.MULTI_LINE_STYLE);
}
}

+ 89
- 0
suimangAdmin/src/main/java/com/iformall/controller/base/BaseController.java View File

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

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.domain.po.base.TenantEntity;
import com.iformall.shiro.UserSession;
import com.iformall.utils.Constant;
import com.iformall.utils.IPUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

@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);
// MallUserInfo user = new MallUserInfo();
// user.setId(463627091581734912L);
// user.setName("富茂光谷测试版管理员");
// user.setTenantId("1025");
// user.setParentTenantId("1024");
return user;
}

public Long getUserId(){
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userId);
// Long userId = 463627091581734912L;
return userId;
}
// @Deprecated
// public String getTenantId(){
// String tenantId = (String)SecurityUtils.getSubject().getSession().getAttribute(UserSession.tenantId);
// return tenantId;
// }

/**
* 返回租户信息
* @return
*/
public TenantEntity getTenantInfo(){
Session session = SecurityUtils.getSubject().getSession();
String tenantId = (String)session.getAttribute(UserSession.tenantId);
String parentTenantId = (String)session.getAttribute(UserSession.parentTenantId);
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setTenantId(tenantId);
tenantEntity.setParentTenantId(parentTenantId);
return tenantEntity;
}

public String getIpAddr() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String ipaddress = IPUtil.getIpAddr(request);
return ipaddress;
}
}

+ 56
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/EnumController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.Method;
import java.util.*;

@RestController
@RequestMapping("enum")
@Api(description="枚举接口")
public class EnumController {

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

@SystemControllerLog(description = "会员管理-标签获取")
@ApiOperation(value="获取枚举对象", notes="根据获取枚举类名获取枚举对象")
@GetMapping("/getEnum/{type}")
public ResultData getEnum(@PathVariable("type") String type) {
if(StringUtils.isBlank(type)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
String className = "com.iformall.enums." + type;
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
try {
// 1.得到枚举类对象
Class<Enum> clz = (Class<Enum>) Class.forName(className);
// 2.得到所有枚举常量
Object[] objects = clz.getEnumConstants();
Method getCode = clz.getMethod("getCode");
Method getMessage = clz.getMethod("getMessage");
Map<String, String> map = null;
for (Object obj : objects) {
map = new HashMap<String, String>();
map.put("code", getCode.invoke(obj).toString());
map.put("message", getMessage.invoke(obj).toString());
list.add(map);
}
} catch (Exception e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"数据不存在");
}
if(list.size() == 0){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"数据不存在");
}
return new ResultData(list);

}

}

+ 40
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/MallSaleTypeController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.MallSaleType;
import com.iformall.service.WxCUserTagsService;
import com.iformall.service.WxTagsService;
import com.iformall.service.sys.MallSaleTypeService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
@RequestMapping("mallSaleType")
@Api(description="销售类型")
public class MallSaleTypeController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private MallSaleTypeService mallSaleTypeService;

@GetMapping("getAllList")
@ApiOperation("标签弹窗接口")
@SystemControllerLog(description = "会员管理-标签获取")
public ResultData getAllList() {
logger.debug("[" + getIpAddr() + "] WxTagsController::getAllList");
return new ResultData(mallSaleTypeService.getList(new MallSaleType()));
}


}

+ 72
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java View File

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


import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.service.TtGoodsCategoryService;
import com.iformall.utils.DateUtils;
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.*;


/**
* @author gongbiao
*/
@RestController
@RequestMapping("goodsCategory")
public class TtGoodsCategoryController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private TtGoodsCategoryService ttGoodsCategoryService;

@TenantIgnore
@ApiOperation("分页列表接口")
@GetMapping("treeList")
@ApiImplicitParams({})
@SystemControllerLog(description = "列表")
public ResultData treeList() {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::treeList");
return new ResultData(ttGoodsCategoryService.findTreeList());
}

@TenantIgnore
@ApiOperation("查询类目")
@GetMapping("get")
@ApiImplicitParams({})
@SystemControllerLog(description = "列表")
public ResultData categoryGet(Integer categoryId) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::categoryGet");
if(categoryId == null){
categoryId = 0;
}
return new ResultData(ttGoodsCategoryService.categoryGet(categoryId));
}

@TenantIgnore
@ApiOperation("查询抖音类目")
@GetMapping("syncGet/{token}")
@ApiImplicitParams({})
@SystemControllerLog(description = "列表")
public ResultData syncGet(@PathVariable String token) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::get");
if(StringUtils.isBlank(token)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
String systemTime = DateUtils.getSystemTime("MMdd")+"syncgc";
if(!systemTime.equals(token)){
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
ttGoodsCategoryService.syncGet();
return new ResultData();
}

}

+ 321
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.controller.mem.AsyncTask;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.service.*;
import com.iformall.utils.Constant;
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.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("merchantPoi")
public class TtMerchantPoiController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private String fmUploadDir;

@Autowired
private TtMerchantPoiService ttMerchantPoiService;

@Autowired
private WxCouponChannelService wxCouponChannelService;

@Autowired
private WxCouponService wxCouponService;

@Autowired
StringRedisTemplate stringRedisTemplate;

@Autowired
private AsyncTask asyncTask;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "列表")
public ResultData list(@ModelAttribute TtMerchantPoi record, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::list");
if (null == record) record = new TtMerchantPoi();
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
final PageInfo<TtMerchantPoi> page = ttMerchantPoiService.listAsPage(record, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findById");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
TtMerchantPoi record = ttMerchantPoiService.getById(id);
return new ResultData(record);
}

@ApiOperation("更新商户接口")
@PostMapping("updateById")
@SystemControllerLog(description = "更新")
public ResultData updateById(@RequestBody TtMerchantPoi record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::updateById");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
TtMerchantPoi merchantPoi = ttMerchantPoiService.getById(record.getId());
if(merchantPoi == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到修改的数据");
}
if(!EnumSupplierMathStatus.match_update.getCode().equals(merchantPoi.getMatchStatus())
&& !EnumSupplierMathStatus.match_fail.getCode().equals(merchantPoi.getMatchStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该状态不允许修改");
}
record.updateTenantInfo(getTenantInfo());
record.setMatchStatus(EnumSupplierMathStatus.match_update.getCode());
ttMerchantPoiService.updateById(record);
return new ResultData(record);
}

@ApiOperation("新建匹配任务")
@PostMapping("match")
@SystemControllerLog(description = "新建匹配任务")
public ResultData match(@RequestBody List<Long> ids) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::match");
if(ids == null || ids.isEmpty()){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.match(getTenantInfo(),ids);
}

@ApiOperation("重新匹配任务")
@PostMapping("matchAgain")
@SystemControllerLog(description = "重新匹配任务")
public ResultData matchAgain(@RequestBody Map<String, Long> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::matchAgain");
Long id = param.get("id");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.matchAgain(getTenantInfo(),id);
}

@ApiOperation("商铺同步")
@PostMapping("merchantSync")
@SystemControllerLog(description = "商铺同步")
public ResultData merchantSync(@RequestBody Map<String, Long> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::merchantSync");
Long id = param.get("id");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.merchantSync(getTenantInfo(),id);
}

@ApiOperation("商铺同步结果")
@GetMapping("merchantQuery")
@SystemControllerLog(description = "商铺同步")
public ResultData merchantQuery(Long id) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::merchantQuery");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.supplierQuery(getTenantInfo(),id);
}

// @ApiOperation("获取商品可用的POI")
// @GetMapping("/findPoi")
// @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
// @SystemControllerLog(description = "查询")
// public ResultData findPoi(Long couponChannelId) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findPoi");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.findPoi(getTenantInfo(),couponChannelId);
// }

// @ApiOperation("商品同步")
// @PostMapping("spuSync")
// @SystemControllerLog(description = "商品同步")
// public ResultData spuSync(@RequestBody Map<String, String> param) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuSync");
// String couponChannelIdStr = param.get("couponChannelId");
// Long couponChannelId = null;
// try{
// couponChannelId = Long.parseLong(couponChannelIdStr);
// }catch(Exception e){
// return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR);
// }
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
//// String merchantIdStr = param.get("merchantIds");
//// List<Long> merchantIds = new ArrayList<>();
//// try{
//// List<String> strings = Arrays.asList(merchantIdStr.split(","));
//// merchantIds = strings.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
//// }catch(Exception e){
//// return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR);
//// }
//// if(merchantIds == null || merchantIds.size() == 0){
//// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
//// }
// return ttMerchantPoiService.spuSync(getTenantInfo(),couponChannelId,null);
// }

// @ApiOperation("商品同步查询")
// @GetMapping("spuGet")
// @SystemControllerLog(description = "商品同步查询")
// public ResultData spuGet(Long couponChannelId) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuGet");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.spuGet(getTenantInfo(),couponChannelId);
// }
//
// @ApiOperation("商品状态同步")
// @PostMapping("spuStatusSync")
// @SystemControllerLog(description = "商品状态同步")
// public ResultData spuStatusSync(@RequestBody Map<String, Long> param) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStatusSync");
// Long couponChannelId = param.get("couponChannelId");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.spuStatusSync(getTenantInfo(),couponChannelId);
// }
//
// @ApiOperation("商品库存同步")
// @PostMapping("spuStockSync")
// @SystemControllerLog(description = "商品库存同步")
// public ResultData spuStockSync(@RequestBody Map<String, Long> param) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStockSync");
// Long couponChannelId = param.get("couponChannelId");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId);
// }

@TenantIgnore
@PostMapping(value = "/importPoi", consumes = "multipart/*")
@SystemControllerLog(description = "poi-导入数据")
public ResultData importPoi(@RequestParam("file") MultipartFile mFile) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::importPoi");
if (mFile.isEmpty()) {
throw new MallinkException(Result.ERROR, "上传文件不能为空");
}
//得到当前用户ID
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = Constant.importMemPrev + userId;

//查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入
Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount");
if (allCount) {
return new ResultData(Result.SUCCESS, "模板正在导入");
}

stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + "");
stringRedisTemplate.expire(importKey,30, TimeUnit.MINUTES);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "");

String fpath = fmUploadDir;
File targetFile = new File(fpath);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
String fileName = "poi" + Math.round(Math.random() * 100000000000L);
int dot = mFile.getOriginalFilename().lastIndexOf('.');
fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length());

File lFile = new File(fpath + File.separator + fileName);

FileOutputStream fos = null;
BufferedInputStream fs = null;
try {
fos = new FileOutputStream(lFile);
fs = (BufferedInputStream) mFile.getInputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fs.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
fos.close();
fs.close();
} catch (Exception e) {
stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
}
}
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
}
}
}

asyncTask.importExcelPoiData(lFile, user, importKey);

return new ResultData(Result.SUCCESS, "模板正在导入");
}

}

+ 317
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java View File

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


import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.TtPoiTakeRate;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumCpsPlanContentType;
import com.iformall.enums.EnumCpsPlanStatus;
import com.iformall.enums.EnumCpsPlanType;
import com.iformall.service.TtCouponGoodsService;
import com.iformall.service.WxCouponService;
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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
* @author
*/
@RestController
@RequestMapping("poiPlan")
public class TtPoiPlanController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private TtCouponGoodsService ttCouponGoodsService;

@Autowired
private WxCouponService wxCouponService;

@ApiOperation("分页列表接口")
@GetMapping("takeRateList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "列表")
public ResultData takeRateList(@ModelAttribute TtPoiTakeRate record, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::list");
if (null == record) record = new TtPoiTakeRate();
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
final PageInfo<TtPoiTakeRate> page = ttCouponGoodsService.takeRateListAsPage(record, pageNum, pageSize);
if(page.getList() != null && !page.getList().isEmpty()){
List<Long> couponIds = page.getList().stream().map(cc -> cc.getCouponId()).collect(Collectors.toList());
Map<Long, WxCoupon> couponMap = wxCouponService.getCouponMap(couponIds, getTenantInfo());
for (TtPoiTakeRate takeRate:page.getList()) {
takeRate.setCoupon(couponMap.get(takeRate.getCouponId()));
}
}
return new ResultData(page);
}

@ApiOperation("通过id获取")
@GetMapping("getTakeRate")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "列表")
public ResultData getTakeRate(Long id) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getTakeRate");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
TtPoiTakeRate takeRateById = ttCouponGoodsService.getTakeRateById(getTenantInfo(), id);
return new ResultData(takeRateById);
}

// @TenantIgnore
@ApiOperation("通用计划分页列表接口")
@GetMapping("list")
@ApiImplicitParams({})
@SystemControllerLog(description = "列表")
public ResultData list(Long couponId,Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] TtPoiPlanController::list");
if(couponId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(pageNum == null){
pageNum = 1;
}
if(pageSize == null){
pageSize = 100;
}
return ttCouponGoodsService.poiPlanList(getTenantInfo(),couponId,pageNum,pageSize);
}

@ApiOperation("定向计划分页列表接口")
@GetMapping("orientedList")
@ApiImplicitParams({})
@SystemControllerLog(description = "列表")
public ResultData orientedList(Long couponId,Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] TtPoiPlanController::orientedList");
if(couponId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(pageNum == null){
pageNum = 1;
}
if(pageSize == null){
pageSize = 100;
}
return ttCouponGoodsService.poiOrientedPlanList(getTenantInfo(),couponId,pageNum,pageSize);
}

@ApiOperation("发布修改通用佣金计划")
@PostMapping("save")
@SystemControllerLog(description = "更新")
public ResultData save(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::save");
if(record.getTakeRate() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率为空");
}
if(record.getTakeRate() < 100 || record.getTakeRate() > 2900){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率需在万分位100-2900之间");
}

if(record.getContentType() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"带货场景为空");
}
if(record.getCouponId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
record.updateTenantInfo(getTenantInfo());
return ttCouponGoodsService.poiPlanSave(record);
}

@ApiOperation("发布修改定向佣金计划")
@PostMapping("saveOrientedPlan")
@SystemControllerLog(description = "更新")
public ResultData saveOrientedPlan(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::saveOrientedPlan");
if(StringUtils.isBlank(record.getName())){//不可修改
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划名称为空");
}
if(StringUtils.isBlank(record.getMerchantPhone())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划联系人为空");
}
if(record.getDouyinIdList() == null || record.getDouyinIdList().isEmpty()){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"定向达人抖音号为空");
}
//达人去重
List<String> collect = record.getDouyinIdList().stream().distinct().collect(Collectors.toList());
record.setDouyinIdList(collect);

if(record.getCouponId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
if(record.getContentType() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"带货场景为空");
}
EnumCpsPlanContentType planType = EnumCpsPlanContentType.getEnum(record.getContentType());
if(planType == null || (!planType.equals(EnumCpsPlanContentType.VIDEO) && !planType.equals(EnumCpsPlanContentType.LIVE))){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"带货场景错误");
}
if(planType.equals(EnumCpsPlanContentType.VIDEO)){
if(record.getStartTime() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划开始时间为空");
}
if(record.getEndTime() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划结束时间为空");
}
if(record.getCommissionDuration() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"佣金有效期为空");
}
}
if(record.getTakeRate() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率为空");
}
if(record.getTakeRate() < 0 || record.getTakeRate() > 2900){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率需在万分位0-2900之间");
}

record.updateTenantInfo(getTenantInfo());
return ttCouponGoodsService.saveOrientedPlan(record);
}

@ApiOperation("新增定向佣金达人合作")
@PostMapping("addOrientedPlanDouyin")
@SystemControllerLog(description = "更新")
public ResultData addOrientedPlanDouyin(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::addOrientedPlanDouyin");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"Id为空");
}
if(record.getDouyinIdList() == null || record.getDouyinIdList().isEmpty()){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"添加定向达人抖音号为空");
}

record.updateTenantInfo(getTenantInfo());
return ttCouponGoodsService.addOrientedPlanDouyin(record);
}

@ApiOperation("取消定向佣金达人合作")
@PostMapping("cancelOrientedPlanDouyin")
@SystemControllerLog(description = "更新")
public ResultData cancelOrientedPlanDouyin(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::cancelOrientedPlanDouyin");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"Id为空");
}
if(StringUtils.isBlank(record.getDouyinId())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"取消定向达人抖音号为空");
}
record.updateTenantInfo(getTenantInfo());
return ttCouponGoodsService.cancelOrientedPlanDouyin(record);
}

@ApiOperation("修改通用佣金计划状态")
@PostMapping("updateStatus")
@SystemControllerLog(description = "更新")
public ResultData updateStatus(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::updateStatus");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划ID为空");
}
if(record.getStatus() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态值为空");
}
EnumCpsPlanStatus planStatus = EnumCpsPlanStatus.getEnum(record.getStatus());
if(planStatus == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态不合法");
}
record.updateTenantInfo(getTenantInfo());

return ttCouponGoodsService.poiPlanUpdateStatus(record);
}

@ApiOperation("修改定向佣金计划状态")
@PostMapping("updateOrientedStatus")
@SystemControllerLog(description = "更新")
public ResultData updateOrientedStatus(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::updateOrientedStatus");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划ID为空");
}
if(record.getStatus() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态值为空");
}
EnumCpsPlanStatus planStatus = EnumCpsPlanStatus.getEnum(record.getStatus());
if(!EnumCpsPlanStatus.OFF.equals(planStatus)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态不合法");
}
record.updateTenantInfo(getTenantInfo());

return ttCouponGoodsService.poiOrientedPlanUpdateStatus(record);
}


@ApiOperation("获取佣金范围")
@PostMapping("getRateScope")
@SystemControllerLog(description = "获取")
public ResultData getRateScope(@RequestBody Map<String, Object> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getRateScope");

String couponIdStr = (String) param.get("couponId");
Integer planType = (Integer) param.get("planType");
if(StringUtils.isBlank(couponIdStr)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
Long couponId = Long.parseLong(couponIdStr);

EnumCpsPlanType anEnum = EnumCpsPlanType.getEnum(planType);
if(anEnum == null){
anEnum = EnumCpsPlanType.COMMON;
}

return ttCouponGoodsService.getRateScope(getTenantInfo(),couponId,anEnum);
}

@ApiOperation("设置总分佣率")
@PostMapping("setUpRateAll")
@SystemControllerLog(description = "更新")
public ResultData setUpAll(@RequestBody Map<String, Object> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::setUpAll");

String couponIdStr = (String) param.get("couponId");
if(StringUtils.isBlank(couponIdStr)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
Long couponId = Long.parseLong(couponIdStr);
Integer mallRate = (Integer) param.get("mallRate");

if(mallRate == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"总分佣率为空");
}

return ttCouponGoodsService.setUpAll(getTenantInfo(),couponId,mallRate);
}

@ApiOperation("获取总分佣率及范围")
@PostMapping("getRateAll")
@SystemControllerLog(description = "获取")
public ResultData getAll(@RequestBody Map<String, Object> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getAll");

String couponIdStr = (String) param.get("couponId");
if(StringUtils.isBlank(couponIdStr)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
Long couponId = Long.parseLong(couponIdStr);
return ttCouponGoodsService.getAll(getTenantInfo(),couponId);
}

}

+ 135
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxBrandController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxBrand;
import com.iformall.domain.po.WxMerchant;
import com.iformall.enums.EnumDelFlag;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.service.WxBrandService;
import com.iformall.service.WxMerchantService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
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 java.util.Map;


/**
* @author gongbiao
*/
@RestController
@RequestMapping("wxBrand")
public class WxBrandController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxBrandService wxBrandService;
@Autowired
private WxMerchantService wxMerchantService;


@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "品牌-列表")
public ResultData list(@ModelAttribute WxBrand wxBrand,Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxBrandController::list");
if (null == wxBrand) {
wxBrand = new WxBrand();
}
wxBrand.setTenantId(getTenantInfo().getFinalTenantId());
wxBrand.setSortColumns(BaseEntity.SortField.Id_DESC);
final PageInfo<WxBrand> page = wxBrandService.listAsPage(wxBrand, pageNum, pageSize);
return new ResultData(page);
}

@PostMapping("add")
@SystemControllerLog(description = "品牌-增加")
public ResultData add(@RequestBody WxBrand wxBrand) {
logger.debug("[" + getIpAddr() + "] WxBrandController::add");
wxBrand.setTenantId(getTenantInfo().getFinalTenantId());
return wxBrandService.save(wxBrand);
}

@TenantIgnore
@PostMapping("update")
@SystemControllerLog(description = "品牌-更新")
public ResultData update(@RequestBody WxBrand wxBrand) {
logger.debug("[" + getIpAddr() + "] WxBrandController::update");

if(wxBrand.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

if(EnumDelFlag.YES.getCode().equals(wxBrand.getIsDel())){
//判断是否解绑商户
WxMerchant wxMerchant = new WxMerchant();
// wxMerchant.updateTenantInfo(wxBrand);
wxMerchant.setIsDel(EnumYesOrNo.NO.getCode());
wxMerchant.setBrand(wxBrand.getId());

List<WxMerchant> merchantList = wxMerchantService.findList(wxMerchant);
if(CollectionUtils.isNotEmpty(merchantList)){
return new ResultData(Result.ERROR, "请先删除已绑定该品牌的商户。");
}
}
wxBrandService.update(wxBrand);
return new ResultData(Result.SUCCESS, "操作成功");
}

@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "品牌-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxBrandController::del");
wxBrandService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

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

@GetMapping("/queryBrand")
@SystemControllerLog(description = "品牌-租户-全部")
public ResultData queryBrand() {
List<Map<String,Object>> brandList = wxBrandService.queryBrand(getTenantInfo());
return new ResultData(brandList);
}


@ApiOperation("查询品牌名称是否存在")
@GetMapping("hasBrand")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "name", dataType = "String", paramType = "query", required = true),
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query")})
@SystemControllerLog(description = "品牌-名称是否存在")
public ResultData hasBrand(String name, Long id) {
logger.debug("[" + getIpAddr() + "] WxBrandController::hasBrand");
WxBrand wxBrand = new WxBrand();
wxBrand.setId(id);
wxBrand.setTenantId(getTenantInfo().getFinalTenantId());
wxBrand.setName(name);

return wxBrandService.hasBrand(wxBrand);
}


}

+ 239
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxCustomizeModuleController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxCustomizeModule;
import com.iformall.enums.EnumAppPlat;
import com.iformall.enums.EnumThemeType;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxCustomizeModuleService;
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.*;

import java.util.List;

@RestController
@Api(description = "CustomizeModule相关接口")
@RequestMapping("wxCustomizeModule")
public class WxCustomizeModuleController extends BaseController {

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

@Autowired
WxCustomizeModuleService wxCustomizeModuleService;

@Autowired
WxAppinfoService wxAppinfoService;

@ApiOperation("查询CustomizeModule列表")
@GetMapping(value = "/getDesc")
@SystemControllerLog(description = "查询CustomizeModule列表")
public ResultData getDesc(Integer themeType) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getDesc");
try {
WxCustomizeModule wxCustomizeModule = new WxCustomizeModule();
wxCustomizeModule.updateTenantInfo(getTenantInfo());
if(themeType == null){
wxCustomizeModule.setThemeType(EnumThemeType.C.getCode());
}
wxCustomizeModule.setIsUsing(EnumYesOrNo.YES.getCode());
List<WxCustomizeModule> list = wxCustomizeModuleService.findList(wxCustomizeModule);
String msg = "";
if(list == null || list.size() == 0){
msg = "注:当前自定义配置无数据,如须使用自定义配置,建议先同步默认配置,再进行修改";
}else if(list.size() < 4 || list.size() > 8){
msg = "注:功能按钮配置达到4个方可生效,最多可添加8个功能按钮";
}else{
msg = "注:配置已生效,请在2分钟后重新登入小程序查看";
}
return new ResultData(msg);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("查询CustomizeModule列表")
@GetMapping(value = "/list")
@SystemControllerLog(description = "查询CustomizeModule列表")
public ResultData getList(@ModelAttribute WxCustomizeModule wxCustomizeModule, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getList");
try {
if(wxCustomizeModule == null){
wxCustomizeModule = new WxCustomizeModule();
}
wxCustomizeModule.updateTenantInfo(getTenantInfo());
if(wxCustomizeModule.getThemeType() == null){
wxCustomizeModule.setThemeType(EnumThemeType.C.getCode());
}
PageInfo<WxCustomizeModule> page = wxCustomizeModuleService.listAsPage(wxCustomizeModule, pageNum, pageSize);
return new ResultData(page);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("查询CustomizeModule列表")
@GetMapping(value = "/findDefault")
@SystemControllerLog(description = "查询CustomizeModule列表")
public ResultData findDefault(@ModelAttribute WxCustomizeModule wxCustomizeModule) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getList");
try {
if(wxCustomizeModule == null){
wxCustomizeModule = new WxCustomizeModule();
}
wxCustomizeModule.updateTenantInfo(getTenantInfo());
if(wxCustomizeModule.getThemeType() == null){
wxCustomizeModule.setThemeType(EnumThemeType.C.getCode());
}
WxAppinfo cAppInfo = null;
if(EnumThemeType.C.getCode().equals(wxCustomizeModule.getThemeType())){
cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.WX);
if(cAppInfo == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到微信C端小程序");
}
}else if(EnumThemeType.TT_C.getCode().equals(wxCustomizeModule.getThemeType())){
cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO);
if(cAppInfo == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到抖音C端小程序");
}
}
if(cAppInfo == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到C端小程序");
}

List<WxCustomizeModule> aDefault = wxCustomizeModuleService.findDefault(wxCustomizeModule,cAppInfo);
PageInfo<WxCustomizeModule> page = new PageInfo(aDefault);
return new ResultData(page);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("恢复主题默认")
@PostMapping("/updateDefault")
@SystemControllerLog(description = "恢复主题默认")
public ResultData updateDefault(@RequestBody WxCustomizeModule wxCustomizeModule) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::updateDefault");
if(wxCustomizeModule == null){
wxCustomizeModule = new WxCustomizeModule();
}
wxCustomizeModule.updateTenantInfo(getTenantInfo());
if(wxCustomizeModule.getThemeType() == null){
wxCustomizeModule.setThemeType(EnumThemeType.C.getCode());
}
WxAppinfo cAppInfo = null;
if(EnumThemeType.C.getCode().equals(wxCustomizeModule.getThemeType())){
cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.WX);
if(cAppInfo == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到微信C端小程序");
}
}else if(EnumThemeType.TT_C.getCode().equals(wxCustomizeModule.getThemeType())){
cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO);
if(cAppInfo == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到抖音C端小程序");
}
}
if(cAppInfo == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到C端小程序");
}
return wxCustomizeModuleService.updateDefault(wxCustomizeModule,cAppInfo);
}

@ApiOperation("根据id查询接口")
@GetMapping("/getById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "-查询")
public ResultData getById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getById");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxCustomizeModule wxCustomizeModule = new WxCustomizeModule();
wxCustomizeModule.updateTenantInfo(getTenantInfo());
wxCustomizeModule.setId(id);
wxCustomizeModule = wxCustomizeModuleService.getById(wxCustomizeModule);
return new ResultData(wxCustomizeModule);
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::delete");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxCustomizeModule wxCustomizeModule = new WxCustomizeModule();
wxCustomizeModule.updateTenantInfo(getTenantInfo());
wxCustomizeModule.setId(id);
wxCustomizeModuleService.updateDel(wxCustomizeModule);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("/isNew")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "-置顶")
public ResultData isNew(Long id) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::delete");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxCustomizeModule wxCustomizeModule = new WxCustomizeModule();
wxCustomizeModule.updateTenantInfo(getTenantInfo());
wxCustomizeModule.setId(id);
wxCustomizeModule.setSort(0);
wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule);
return new ResultData(Result.SUCCESS, "置顶成功", null);
}

@PostMapping("add")
@SystemControllerLog(description = "-添加")
public ResultData add(@RequestBody WxCustomizeModule wxCustomizeModule) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::add");
if(wxCustomizeModule == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
wxCustomizeModule.updateTenantInfo(getTenantInfo());
if(wxCustomizeModule.getThemeType() == null){
wxCustomizeModule.setThemeType(EnumThemeType.C.getCode());
}
WxCustomizeModule wxCustomizeModuleQ = new WxCustomizeModule();
wxCustomizeModuleQ.updateTenantInfo(wxCustomizeModule);
wxCustomizeModuleQ.setThemeType(wxCustomizeModule.getThemeType());
wxCustomizeModuleQ.setIsUsing(EnumYesOrNo.YES.getCode());
List<WxCustomizeModule> list = wxCustomizeModuleService.findList(wxCustomizeModuleQ);
if(list != null && list.size() >= 8){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"当前已超限,最多可添加8条");
}
wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule);
return new ResultData();
}

@PostMapping("update")
@SystemControllerLog(description = "更新")
public ResultData update(@RequestBody WxCustomizeModule wxCustomizeModule) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::update");
if(wxCustomizeModule == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
wxCustomizeModule.updateTenantInfo(getTenantInfo());
wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule);
return new ResultData();
}

}

+ 73
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxGroupController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
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)})
@SystemControllerLog(description = "集团-列表")
public ResultData list(@ModelAttribute WxGroup wxGroup, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxGroupController::list");
if (null == wxGroup) wxGroup = new WxGroup();
final PageInfo<WxGroup> page = wxGroupService.listAsPage(wxGroup, pageNum, pageSize);
return new ResultData(page);
}

@PostMapping("add")
@SystemControllerLog(description = "集团-添加")
public ResultData add(@RequestBody WxGroup wxGroup) {
logger.debug("[" + getIpAddr() + "] WxGroupController::add");
//Assert.notNull(wxGroup.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxGroupService.saveOrUpdate(wxGroup);
return new ResultData();
}

@PostMapping("update")
@SystemControllerLog(description = "集团-更新")
public ResultData update(@RequestBody WxGroup wxGroup) {
logger.debug("[" + getIpAddr() + "] WxGroupController::update");
wxGroupService.saveOrUpdate(wxGroup);
return new ResultData();
}

@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
@SystemControllerLog(description = "集团-删除")
public ResultData delete(String id) {
logger.debug("[" + getIpAddr() + "] WxGroupController::delete");
wxGroupService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
@SystemControllerLog(description = "集团-查询")
public ResultData findById(String id) {
logger.debug("[" + getIpAddr() + "] WxGroupController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxGroupService.getById(id));
}


}

+ 88
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxMallBuildingController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxMallBuilding;
import com.iformall.domain.po.WxMallFloor;
import com.iformall.service.WxMallBuildingService;
import com.iformall.utils.Constant;
import com.iformall.utils.RedisCacheUtils;
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.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

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

@Autowired
private WxMallBuildingService wxMallBuildingService;

@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> objectCommonRedisTemplate;

@ApiOperation("获取楼层楼座数据")
@GetMapping("getbuildingfloorlist")
@SystemControllerLog(description = "商城-楼座-获取楼层楼座数据")
public ResultData getbuildingfloorlist() {
logger.debug("[" + getIpAddr() + "] WxMallBuildingController::getbuildingfloorlist");
return wxMallBuildingService.getBuildingFloorList(getTenantInfo());
}

@ApiOperation("保存楼层楼座地图")
@PostMapping("saveFloorImg")
@SystemControllerLog(description = "商城-楼座/楼层-保存地图")
public ResultData saveFloorImg(@RequestBody List<WxMallBuilding> record) {
logger.debug("[" + getIpAddr() + "] WxMallBuildingController::addBuildingAndFloor");
if(record == null && record.size() > 0) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
for (WxMallBuilding building: record) {
List<WxMallFloor> floors = building.getFloors();
if(floors != null && floors.size() > 0){
for (WxMallFloor floor:floors) {
if (floor.getId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
floor.updateTenantInfo(getTenantInfo());
wxMallBuildingService.saveFloorImg(floor);

}
}
}

String key = Constant.mallBuildingPrev + getTenantInfo().getTenantId();
RedisCacheUtils.removeCache(objectCommonRedisTemplate, key);
return new ResultData();
}

@ApiOperation("保存楼层楼座面积")
@PostMapping("saveFloorArea")
@SystemControllerLog(description = "商城-楼座/楼层-保存面积")
public ResultData saveFloorArea(@RequestBody WxMallFloor record) {
logger.debug("[" + getIpAddr() + "] WxMallBuildingController::addBuildingAndFloor");
if(record == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if (record.getId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if (record.getTotalArea() == null && record.getOperatingArea() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
record.updateTenantInfo(getTenantInfo());
wxMallBuildingService.saveFloorArea(record);
return new ResultData();
}

}

+ 100
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxMallController.java View File

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

import com.google.code.kaptcha.Constants;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxMall;
import com.iformall.enums.EnumGroupSupport;
import com.iformall.service.WxMallService;
import com.iformall.utils.ShiroUtils;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.IOUtils;
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.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.List;

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

@Autowired
private WxMallService wxMallService;

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "商城-更新")
public ResultData update(@RequestBody WxMall wxMall) {
logger.debug("[" + getIpAddr() + "] WxMallController::update");
wxMallService.update(wxMall);
return new ResultData();
}

@ApiOperation("根据id查询接口")
@GetMapping("/mallinfoExt")
@SystemControllerLog(description = "商城-查询")
public ResultData mallinfoExt() {
logger.debug("[" + getIpAddr() + "] WxMallController::mallinfoExt");
return new ResultData(wxMallService.getByTenantInfoExt(getTenantInfo()));
}

@ApiOperation("查询当前mall的信息")
@GetMapping("/mallinfo")
@SystemControllerLog(description = "商城-当前查询")
public ResultData mallinfo() {
logger.debug("[" + getIpAddr() + "] WxMallController::mallinfo");
WxMall mall = wxMallService.getByTenantInfo(getUser());
if(mall == null) {
logger.error("未配置相应的mall");
return new ResultData(Result.ERROR, "未配置相应的mall");
}
if (wxMallService.isgroupSupport(mall)) {
mall.setSubMalls(wxMallService.getSubByParentTenantId(mall.getTenantId()));
}
mall.setValidPrompt(wxMallService.mallValid(getUserId(),mall));
return new ResultData(mall);
}

@ApiOperation("查询当前mall的子广场")
@GetMapping("/childMall")
@SystemControllerLog(description = "商城-当前查询")
public ResultData childMall() {
logger.debug("[" + getIpAddr() + "] WxMallController::childMall");
WxMall mall = wxMallService.getByTenantInfo(getUser());
if(mall == null) {
logger.error("未配置相应的mall");
return new ResultData(Result.ERROR, "未配置相应的mall");
}
if (wxMallService.isgroupSupport(mall)) {
List<WxMall> childMall = wxMallService.getSubByParentTenantId(mall.getTenantId());
return new ResultData(childMall);
}
return new ResultData(Result.ERROR, "未查询到子广场");
}

@ApiOperation("验证码")
@GetMapping("/imgUrlH")
public ResultData imgUrlH(){
logger.debug("[" + getIpAddr() + "] WxMallController::imgUrlH");
WxMall mall = wxMallService.getByTenantInfo(getUser());
if(mall == null) {
logger.error("未配置相应的mall");
return new ResultData(Result.ERROR, "未配置相应的mall");
}
return new ResultData(mall.getImgUrlH());
}


}

+ 210
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxMapController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.BusinessCircleBase;
import com.iformall.domain.po.WxCouponOrder;
import com.iformall.domain.po.WxCreditHistory;
import com.iformall.domain.vo.WxCardSpendVo;
import com.iformall.enums.EnumShopStatus;
import com.iformall.service.*;
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.*;

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

/**
* @author
*/
@RestController
@RequestMapping("map")
public class WxMapController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxShopService wxShopService;

@Autowired
private WxMerchantService wxMerchantService;

@Autowired
private WxRentContractService wxRentContractService;

@Autowired
private WxCouponOrderService wxCouponOrderService;

@Autowired
private WxCardSpendService wxCardSpendService;

@Autowired
private WxBusinessCircleOrderService wxBusinessCircleOrderService;

@Autowired
private AliBusinessCircleOrderService aliBusinessCircleOrderService;

@Autowired
private WxCreditHistoryService wxCreditHistoryService;

@ApiOperation("根据id查询接口")
@GetMapping("/findShopBySid")
@ApiImplicitParam(name = "sid", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "店铺管理-id查询")
public ResultData findShopBySid(String sid) {
logger.debug("[" + getIpAddr() + "] WxMapController::findShopBySid");
Map<String, Object> resultObject = new HashMap<>();
Map<String, Object> wxShopObject = wxShopService.detailBySid(getTenantInfo(), sid);
Map<String, Object> wxMerchantObject = new HashMap<>();
Map<String, Object> wxRentContractObject = new HashMap<>();
if(wxShopObject != null && !wxShopObject.isEmpty()
&& EnumShopStatus.RENT.getCode().toString().equals(wxShopObject.get("status").toString())){
//已出租
long shopId = Long.parseLong(wxShopObject.get("id").toString());
String shopNumber = wxShopObject.get("shopNumber").toString();
wxMerchantObject = wxMerchantService.detailByShopId(getTenantInfo(), shopId);
if(wxMerchantObject != null && !wxMerchantObject.isEmpty()){
long merchantId = Long.parseLong(wxMerchantObject.get("id").toString());
wxRentContractObject = wxRentContractService.currentValidByMerchantId(getTenantInfo(),merchantId,shopNumber);
}
}
resultObject.put("wxShop",wxShopObject);
resultObject.put("wxMerchant",wxMerchantObject);
resultObject.put("wxRentContract",wxRentContractObject);
return new ResultData(Result.SUCCESS, "查询成功", resultObject);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findStatisticsBySid")
@ApiImplicitParam(name = "sid", value = "sid", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "店铺管理-id查询")
public ResultData findStatisticsBySid(String sid, Date startDate, Date endDate) {
logger.debug("[" + getIpAddr() + "] WxMapController::findStatisticsBySid");
Map<String, Object> resultMap = new HashMap<>();
Map<String, Object> wxShopObject = wxShopService.detailBySid(getTenantInfo(), sid);
if(wxShopObject != null && !wxShopObject.isEmpty()
&& EnumShopStatus.RENT.getCode().toString().equals(wxShopObject.get("status").toString())){
//已出租
long shopId = Long.parseLong(wxShopObject.get("id").toString());
Map<String, Object> wxMerchantObject = wxMerchantService.detailByShopId(getTenantInfo(), shopId);
if(wxMerchantObject != null && !wxMerchantObject.isEmpty()){
long merchantId = Long.parseLong(wxMerchantObject.get("id").toString());
WxCouponOrder wxCouponOrder = new WxCouponOrder();
wxCouponOrder.updateTenantInfo(getTenantInfo());
wxCouponOrder.setMerchantId(merchantId);
wxCouponOrder.setStartTime(startDate);
wxCouponOrder.setEndTime(endDate);
wxCouponOrderService.statisticsWriteOff(wxCouponOrder,resultMap);

WxCardSpendVo wxCardSpend = new WxCardSpendVo();
wxCardSpend.updateTenantInfo(getTenantInfo());
wxCardSpend.setMerchantId(merchantId);
wxCardSpend.setStartdate(startDate);
wxCardSpend.setEnddate(endDate);
resultMap.put("sumRealPayment",wxCardSpendService.sumRealPayment(wxCardSpend));

BusinessCircleBase businessCircle = new BusinessCircleBase();
businessCircle.updateTenantInfo(getTenantInfo());
businessCircle.setMerchantId(merchantId);
businessCircle.setStartTime(startDate);
businessCircle.setEndTime(endDate);
Integer wxCircleSumPayment = wxBusinessCircleOrderService.sumCirclePayment(businessCircle);
Integer aliCircleSumPayment = aliBusinessCircleOrderService.sumCirclePayment(businessCircle);
resultMap.put("sumCirclePayment",wxCircleSumPayment + aliCircleSumPayment);

WxCreditHistory wxCreditHistory = new WxCreditHistory();
wxCreditHistory.setTenantId(getTenantInfo().getFinalTenantId());
wxCreditHistory.setMerchantId(merchantId);
wxCreditHistory.setStartTime(startDate);
wxCreditHistory.setEndTime(endDate);
resultMap.put("sumCreditAmount",wxCreditHistoryService.getIncrementCreditAmount(wxCreditHistory));
}
}

return new ResultData(Result.SUCCESS, "查询成功", resultMap);
}


@ApiOperation("根据id查询接口")
@GetMapping("/findShopById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "店铺管理-id查询")
public ResultData findShopById(Long id) {
logger.debug("[" + getIpAddr() + "] WxMapController::findShopById");
return new ResultData(Result.SUCCESS, "查询成功", wxShopService.detailById(this.getTenantInfo(),id));
}

@ApiOperation("根据id查询接口")
@GetMapping("/findMerchantByShop")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "店铺管理-id查询")
public ResultData findMerchantByShop(Long shopId) {
logger.debug("[" + getIpAddr() + "] WxMapController::findMerchantByShop");
return new ResultData(Result.SUCCESS, "查询成功", wxMerchantService.findMerchantByShop(shopId));
}

@ApiOperation("根据id查询接口")
@GetMapping("/findRentByShop")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "店铺管理-id查询")
public ResultData findRentByShop(Long shopId) {
logger.debug("[" + getIpAddr() + "] WxMapController::findRentByShop");
return new ResultData(Result.SUCCESS, "查询成功", wxRentContractService.findRentByShop(shopId));
}

@ApiOperation("根据id查询接口")
@GetMapping("/findStatisticsByShop")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "店铺管理-id查询")
public ResultData findStatisticsByShop(Long shopId, Date startDate, Date endDate) {
logger.debug("[" + getIpAddr() + "] WxMapController::findStatisticsByShop");
Map<String, Object> resultMap = new HashMap<>();
Map<String, Object> merchantByShop = wxMerchantService.findMerchantByShop(shopId);
if(merchantByShop != null && merchantByShop.get("id") != null){
String tenantId = merchantByShop.get("tenant_id").toString();
String parentTenantId = "";
if(merchantByShop.get("parent_tenant_id") != null){
parentTenantId = merchantByShop.get("parent_tenant_id").toString();
}

Long merchantId = Long.parseLong(merchantByShop.get("id").toString());
WxCouponOrder wxCouponOrder = new WxCouponOrder();
wxCouponOrder.updateTenantInfo(getTenantInfo());
wxCouponOrder.setMerchantId(merchantId);
wxCouponOrder.setStartTime(startDate);
wxCouponOrder.setEndTime(endDate);
wxCouponOrderService.statisticsWriteOff(wxCouponOrder,resultMap);

WxCardSpendVo wxCardSpend = new WxCardSpendVo();
wxCardSpend.updateTenantInfo(getTenantInfo());
wxCardSpend.setMerchantId(merchantId);
wxCardSpend.setStartdate(startDate);
wxCardSpend.setEnddate(endDate);
resultMap.put("sumRealPayment",wxCardSpendService.sumRealPayment(wxCardSpend));

BusinessCircleBase businessCircle = new BusinessCircleBase();
businessCircle.updateTenantInfo(getTenantInfo());
businessCircle.setMerchantId(merchantId);
businessCircle.setStartTime(startDate);
businessCircle.setEndTime(endDate);
Integer wxCircleSumPayment = wxBusinessCircleOrderService.sumCirclePayment(businessCircle);
Integer aliCircleSumPayment = aliBusinessCircleOrderService.sumCirclePayment(businessCircle);
resultMap.put("sumCirclePayment",wxCircleSumPayment + aliCircleSumPayment);

WxCreditHistory wxCreditHistory = new WxCreditHistory();
wxCreditHistory.setTenantId(getTenantInfo().getFinalTenantId());
wxCreditHistory.setMerchantId(merchantId);
wxCreditHistory.setStartTime(startDate);
wxCreditHistory.setEndTime(endDate);
resultMap.put("sumCreditAmount",wxCreditHistoryService.getIncrementCreditAmount(wxCreditHistory));
}
return new ResultData(Result.SUCCESS, "查询成功", resultMap);
}

}

+ 52
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxMerchantBUserController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxMerchantBUser;
import com.iformall.domain.po.base.BaseEntity;
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("listVo")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "商户-列表")
public ResultData listVo(@ModelAttribute WxMerchantBUser wxMerchantBUser, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::list");
if (null == wxMerchantBUser) wxMerchantBUser = new WxMerchantBUser();
wxMerchantBUser.updateTenantInfo(getTenantInfo());
wxMerchantBUser.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
final PageInfo<WxMerchantBUser> page = wxMerchantBUserService.listAsPage(wxMerchantBUser, pageNum, pageSize);
return new ResultData(page);
}

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

}

+ 445
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.annotation.UserDataRuleAnnotation;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxProfitSharingReceiver;
import com.iformall.domain.vo.WxMerchantTradeDetailVo;
import com.iformall.domain.vo.WxMerchantTradeVo;
import com.iformall.domain.vo.WxMerchantVo;
import com.iformall.douyin.pay.enums.AppAddSubMerchantUrlType;
import com.iformall.enums.*;
import com.iformall.service.*;
import com.iformall.utils.Constant;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

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

@Autowired
private WxMerchantService wxMerchantService;
@Autowired
private QrCodeService qrCodeService;

@Autowired
private WxAppinfoService wxAppinfoService;
@Autowired
private WxPayAccountService payAccountService;

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;

@UserDataRuleAnnotation("merchant_list")
@ApiOperation("分页列表接口")
@GetMapping("listVo")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "商户-列表")
public ResultData listVo(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::list");
if (null == wxMerchant) wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC);
wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode());
final PageInfo<WxMerchant> page = wxMerchantService.listVoAsPage(wxMerchant, pageNum, pageSize,true);
return new ResultData(page);
}


@UserDataRuleAnnotation("merchant_list")
@ApiOperation("分页列表接口")
@GetMapping("listVo2")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "商户-列表")
public ResultData listVo2(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::list");
if (null == wxMerchant) wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC);
wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode());
final PageInfo<WxMerchant> page = wxMerchantService.listVoAsPage(wxMerchant, pageNum, pageSize,false);
return new ResultData(page);
}


@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "商户-列表")
public ResultData list(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::list");
if (null == wxMerchant) wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC);
wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode());
final PageInfo<WxMerchant> page = wxMerchantService.listAsPage(wxMerchant, pageNum, pageSize);
return new ResultData(page);
}

@TenantIgnore
@ApiOperation("分页列表接口")
@GetMapping("parentList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "商户-列表")
public ResultData parentList(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::parentList");
if (null == wxMerchant) wxMerchant = new WxMerchant();
String tenantId = getUser().getTenantId();
// wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setParentTenantId(tenantId);
wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC);
wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode());
final PageInfo<WxMerchant> page = wxMerchantService.listAsPage(wxMerchant, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("获取商管商户")
@GetMapping("adminMerchantOne")
@SystemControllerLog(description = "商户-列表")
public ResultData adminMerchantOne() {
logger.debug("[" + getIpAddr() + "] WxMerchantController::adminMerchantOne");
WxMerchant wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setStatus(EnumMerchantStatus.VALID.getCode());
wxMerchant.setIsAdmin(EnumMerchantAdmin.PUBLIC_ADMIN.getCode());
wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC);
List<WxMerchant> list = wxMerchantService.findList(wxMerchant);
if(list == null || list.isEmpty()){
return new ResultData(ErrorCode.SYS_NULLPOINTER_ERROR.getCode(),"未找到商管商户");
}
return new ResultData(list.get(0));
}
@ApiOperation("获取商户ID,名称接口")
@GetMapping("IdAndNamelist")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "类型", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)
})
@SystemControllerLog(description = "商户-列表")
public ResultData IdAndNamelist(Integer type,Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::list");
WxMerchant wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC);
wxMerchant.setStatus(EnumMerchantStatus.VALID.getCode());
wxMerchant.setType(type);
wxMerchant.setCarVendorType(0);
return new ResultData(wxMerchantService.queryIdAndNames(wxMerchant));
}


@ApiOperation("ETCP商户列表")
@GetMapping("etcplist")
@SystemControllerLog(description = "商户-ETCP商户列表")
public ResultData etcpList(@ModelAttribute WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::etcpList");
if (null == wxMerchant) wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
final List<WxMerchant> merchantList = wxMerchantService.etcpList(wxMerchant);
return new ResultData(merchantList);
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "商户-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::delete");
wxMerchantService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "商户-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::findById");
WxMerchant wxMerchant = wxMerchantService.getById(id);
return new ResultData(wxMerchant);
}

@ApiOperation("停用")
@GetMapping("disable")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "商户-停用")
public ResultData disable(Long id) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::disable");
wxMerchantService.disable(id);
return new ResultData(Result.SUCCESS, "停用成功");
}

@ApiOperation("新增商户接口")
@PostMapping("addMerchant")
@SystemControllerLog(description = "商户-新增")
public ResultData addMerchant(@RequestBody WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::addMerchant");
wxMerchant.updateTenantInfo(getTenantInfo());
ResultData resultData = wxMerchantService.addMerchant(wxMerchant, getUserId());

if(resultData.code == 200){
wxMerchantService.updateQrCode(wxMerchant,wxMerchant.getId());
}

return resultData;
}
@ApiOperation("更新商户接口")
@PostMapping("updateMerchant")
@SystemControllerLog(description = "商户-更新")
public ResultData updateMerchant(@RequestBody WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchant");
wxMerchant.updateTenantInfo(getTenantInfo());
return wxMerchantService.updateMerchant(wxMerchant);
}

// @ApiOperation("更新账户接口")
// @PostMapping("updateMerchantAccount")
// @SystemControllerLog(description = "商户-更新账户")
// public ResultData updateMerchantAccount(@RequestBody WxMerchant wxMerchant) {
// logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAccount");
// wxMerchant.updateTenantInfo(getTenantInfo());
// return wxMerchantService.updateMerchantAccount(wxMerchant,EnumPayWay.PAY_WAY_WECHAT);
// }

@ApiOperation("更新管理员接口")
@PostMapping("updateMerchantAdmin")
@SystemControllerLog(description = "商户-更新管理员")
public ResultData updateMerchantAdmin(@RequestBody WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAdmin");
wxMerchant.updateTenantInfo(getTenantInfo());
return wxMerchantService.updateMerchantAdmin(wxMerchant);
}

@ApiOperation("更新法人接口")
@PostMapping("updateMerchantCorp")
@SystemControllerLog(description = "商户-更新法人")
public ResultData updateMerchantCopr(@RequestBody WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantCorp");
wxMerchant.updateTenantInfo(getTenantInfo());
return wxMerchantService.updateMerchantCorp(wxMerchant);
}

@ApiOperation("更新税务接口")
@PostMapping("updateMerchantTax")
@SystemControllerLog(description = "商户-更新税务")
public ResultData updateMerchantTax(@RequestBody WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantTax");
wxMerchant.updateTenantInfo(getTenantInfo());
return wxMerchantService.updateMerchantTax(wxMerchant);
}

@ApiOperation("商户信息设置接口")
@PostMapping("updateMerchantLevel")
@SystemControllerLog(description = "商户-更新会员等级权益")
public ResultData updateMerchantLevel(@RequestBody WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantLevel");
wxMerchant.updateTenantInfo(getTenantInfo());
return wxMerchantService.updateMerchantLevel(wxMerchant);
}

@ApiOperation("查询当前租户下商户名称列表")
@GetMapping("/name_list")
@SystemControllerLog(description = "查询当前租户下商户名称列表")
public ResultData nameList() {
logger.debug("[" + getIpAddr() + "] WxMerchantController::name_list");
return new ResultData(wxMerchantService.findList(getTenantInfo()));
}

@ApiOperation("根据id查询接口")
@GetMapping("/findMerchantById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "商户-查询")
public ResultData findMerchantById(Long id) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::findMerchantById");
WxMerchantVo wxMerchant = wxMerchantService.findMerchantById(getTenantInfo(),id);
return new ResultData(wxMerchant);
}

@UserDataRuleAnnotation("merchant_list")
@ApiOperation("商户数据导出")
@GetMapping("/exportData")
@SystemControllerLog(description = "商户-商户数据导出")
public void exportData(@ModelAttribute WxMerchant wxMerchant, HttpServletRequest request, HttpServletResponse response) {
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC);
wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode());
wxMerchantService.exportData(wxMerchant,request,response);
}

@ApiOperation("置顶")
@PostMapping("top")
@SystemControllerLog(description = "商户-置顶")
public ResultData top(@RequestBody WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::top");
wxMerchant.updateTenantInfo(getTenantInfo());
return wxMerchantService.top(wxMerchant);
}

// @ApiOperation("更新收款账户状态")
// @PostMapping("useAccount")
// @SystemControllerLog(description = "商户-更新收款账户状态")
// public ResultData useAccount(@RequestBody WxProfitSharingReceiver wxProfitSharingReceiver) {
// logger.debug("[" + getIpAddr() + "] WxMerchantController::useAccount");
// wxProfitSharingReceiver.updateTenantInfo(getTenantInfo());
// return wxMerchantService.useAccount(wxProfitSharingReceiver);
// }

@ApiOperation("查看是否存在商户名称相同记录")
@GetMapping("/hasMerchant")
@SystemControllerLog(description = "商户-查看是否存在商户名称相同记录")
public ResultData hasMerchant(@ModelAttribute WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::hasMerchant");
wxMerchant.updateTenantInfo(getTenantInfo());
boolean has = wxMerchantService.hasMerchant(wxMerchant);
return new ResultData(has);
}

@ApiOperation("查看是否存在商户名称相同记录")
@GetMapping("/hasMerchantEncode")
@SystemControllerLog(description = "商户-查看是否存在商户编码相同记录")
@TenantIgnore
public ResultData hasMerchantEncode(@ModelAttribute WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::hasMerchantEncode{}"+wxMerchant.toString());
boolean has = wxMerchantService.hasMerchantEncode(wxMerchant);
return new ResultData(has);
}

@ApiOperation("商户会员消费分页列表接口")
@GetMapping("userTradeList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "商户-消费列表")
public ResultData userTradeList(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::list");
if (null == wxMerchant) wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC);
final PageInfo<WxMerchantTradeVo> page = wxMerchantService.userTradeList(wxMerchant, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("商户会员消费明细列表接口")
@GetMapping("userTradeDetailList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "商户-商户会员消费明细列表接口")
public ResultData userTradeDetailList(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::list");
if (null == wxMerchant) wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
final PageInfo<WxMerchantTradeDetailVo> page = wxMerchantService.userTradeDetailList(wxMerchant, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("导出商户会员消费分页列表")
@GetMapping("exportUserTradeDetailList")
@SystemControllerLog(description = "导出商户会员消费分页列表")
public void exportUserTradeList(@ModelAttribute WxMerchant wxMerchant,HttpServletRequest request, HttpServletResponse response) throws Exception{
logger.debug("[" + getIpAddr() + "] WxBusinessController::exportUserTradeDetailList");
if (null == wxMerchant) wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(getTenantInfo());
wxMerchantService.exportUserTradeList(wxMerchant, request,response);
}

@ApiOperation("刷新进件页面")
@GetMapping("/updateTtReceiver")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "商户-删除")
public ResultData updateTtReceiver(Long id) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::updateTtReceiver");
WxMerchant merchant = wxMerchantService.selectById(id);
if(merchant == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
return wxProfitSharingReceiverService.updateTtReceiver(merchant);
}


@ApiOperation("获取进件/余额页面")
@GetMapping("/getTtReceiverUrl")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData getTtReceiver(Long id,Integer urlType) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::getTtReceiver");
if(urlType == null || id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请检查传递参数");
}

WxMerchant merchant = wxMerchantService.selectById(id);
if(merchant == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
AppAddSubMerchantUrlType anEnum = AppAddSubMerchantUrlType.getEnum(urlType);
if(anEnum == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
if(anEnum.equals(AppAddSubMerchantUrlType.improt_URL)){
return wxProfitSharingReceiverService.getTtReceiverImprotURL(merchant);
}else if(anEnum.equals(AppAddSubMerchantUrlType.Balance_URL)){
return wxProfitSharingReceiverService.getTtReceiverBalanceURL(merchant);
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}

}

@ApiOperation("修改可用状态")
@GetMapping("/updateTtReceiverIsUse")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "商户-删除")
public ResultData updateTtReceiverIsUse(Long id) {
WxMerchant merchant = wxMerchantService.selectById(id);
if(merchant == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxAppinfo appInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO);
if(appInfo == null) {
return new ResultData(ErrorCode.APP_ID_NOT_FOUND);
}
WxPayAccount payAcount = payAccountService.getById(appInfo.getPayId());
if(payAcount == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND);
}
return wxProfitSharingReceiverService.updateTtReceiverIsUse(merchant);
}

}

+ 40
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxMerchantShopController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
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("queryShopList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "商户商铺--获取关联商铺信息")
public ResultData queryShopList(@ModelAttribute WxMerchantShop wxMerchantShop, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantShopController::queryShopList");
if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop();
wxMerchantShop.updateTenantInfo(getTenantInfo());
final PageInfo<WxShop> page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize);
return new ResultData(page);
}

}

+ 168
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxMiniappThemeController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.enums.*;
import com.iformall.service.*;
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
@Api(description = "MiniappTheme相关接口")
@RequestMapping("wxMiniappTheme")
public class WxMiniappThemeController extends BaseController {

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

@Autowired
WxMiniappThemeService wxMiniappThemeService;
@Autowired
WxAppinfoService wxAppinfoService;

@ApiOperation("查询MiniappTheme列表")
@GetMapping(value = "/list")
@SystemControllerLog(description = "查询MiniappTheme列表")
@TenantIgnore
public ResultData getList(@ModelAttribute WxMiniappTheme wxMiniappTheme, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::getList");
try {
if(wxMiniappTheme == null){
wxMiniappTheme = new WxMiniappTheme();
}
wxMiniappTheme.setTenantId(getTenantInfo().getTenantId());
if(wxMiniappTheme.getType() == null){
wxMiniappTheme.setType(EnumThemeType.C.getCode());
}
if(EnumThemeType.C.getCode().equals(wxMiniappTheme.getType())){
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.WX);
if(cAppInfo == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到微信C端小程序");
}
wxMiniappTheme.setMouldType(cAppInfo.getMouldType());
}else if(EnumThemeType.TT_C.getCode().equals(wxMiniappTheme.getType())){
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO);
if(cAppInfo == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到抖音C端小程序");
}
wxMiniappTheme.setMouldType(cAppInfo.getMouldType());
}
if(wxMiniappTheme.getMouldType() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请先确认模板类型");
}

PageInfo<WxMiniappTheme> page = wxMiniappThemeService.listAsPage(wxMiniappTheme, pageNum, pageSize);
if(page.getList() != null && page.getList().size() > 0){
WxThemeMall wxThemeMall = new WxThemeMall();
wxThemeMall.setTenantId(getTenantInfo().getTenantId());
wxThemeMall.setThemeType(wxMiniappTheme.getType());
wxThemeMall.setMouldType(wxMiniappTheme.getMouldType());
WxThemeMall themeMall = wxMiniappThemeService.findThemeMall(wxThemeMall);
boolean updateStatus = true;
if(themeMall != null){
for (WxMiniappTheme theme:page.getList()) {
if(theme.getId().equals(themeMall.getThemeId())){
theme.setStatus(0);
updateStatus = false;
}else{
theme.setStatus(1);
}
}
}
if(updateStatus){
page.getList().get(0).setStatus(0);
}
}
return new ResultData(page);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("根据id使之生效")
@PostMapping("/updateEffect")
@ApiImplicitParam(name = "themeId", value = "themeId", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "根据id使之生效")
@TenantIgnore
public ResultData updateEffect(@RequestBody WxThemeMall wxThemeMall) {
logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::updateEffect");
if(wxThemeMall == null || wxThemeMall.getThemeId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxMiniappTheme miniappTheme = new WxMiniappTheme();
miniappTheme.setTenantId(getTenantInfo().getTenantId());
miniappTheme.setId(wxThemeMall.getThemeId());
WxMiniappTheme theme = wxMiniappThemeService.selectById(miniappTheme);
if(theme == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}

wxThemeMall.setTenantId(getTenantInfo().getTenantId());
wxThemeMall.setMouldType(theme.getMouldType());
wxThemeMall.setThemeType(theme.getType());

wxMiniappThemeService.updateEffect(wxThemeMall);
return new ResultData(Result.SUCCESS);
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "-删除")
@TenantIgnore
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::delete");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
wxMiniappThemeService.updateDel(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@PostMapping("add")
@SystemControllerLog(description = "-添加")
@TenantIgnore
public ResultData add(@RequestBody WxMiniappTheme wxMiniappTheme) {
logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::add");
if(wxMiniappTheme == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

wxMiniappTheme.setTenantId(getTenantInfo().getTenantId());
if(wxMiniappTheme.getType() == null){
wxMiniappTheme.setType(EnumThemeType.C.getCode());
}
if(wxMiniappTheme.getMouldType() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请确认模板类型");
}
wxMiniappThemeService.saveOrUpdate(wxMiniappTheme);
return new ResultData();
}

@PostMapping("update")
@SystemControllerLog(description = "-更新")
public ResultData update(@RequestBody WxMiniappTheme wxMiniappTheme) {
logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::update");
if(wxMiniappTheme == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
wxMiniappTheme.setTenantId(getTenantInfo().getTenantId());
wxMiniappThemeService.saveOrUpdate(wxMiniappTheme);
return new ResultData();
}




}

+ 130
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxProfitSharingReceiverApplyController.java View File

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

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxProfitSharingReceiver;
import com.iformall.domain.po.WxProfitSharingReceiverApply;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxMerchantReceiverApplyVo;
import com.iformall.douyin.pay.enums.MerchantImportStatus;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.file.aliyun.AliyunOSS;
import com.iformall.service.WxMerchantService;
import com.iformall.service.WxProfitSharingReceiverApplyService;
import com.iformall.service.WxProfitSharingReceiverService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
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.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("sharingReceiverApply")
@Api(description = "进件相关接口")
@Slf4j
public class WxProfitSharingReceiverApplyController extends BaseController {

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

@Autowired
private WxProfitSharingReceiverApplyService wxProfitSharingReceiverApplyService;

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;

@Autowired
private WxMerchantService wxMerchantService;

@Autowired
private AliyunOSS aliyunOSS;

@ApiOperation("分页列表接口")
@GetMapping("listVo")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "商户-列表")
public ResultData listVo(WxMerchantReceiverApplyVo receiver, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::listVo");
if (null == receiver) receiver = new WxMerchantReceiverApplyVo();
receiver.updateTenantInfo(getTenantInfo());

final PageInfo<WxMerchantReceiverApplyVo> page = wxProfitSharingReceiverApplyService.listVoAsPage(receiver, pageNum, pageSize);
return new ResultData(page);
}

@TenantIgnore
@ApiOperation("分页列表接口")
@GetMapping("tenantListVo")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "商户-列表")
public ResultData tenantListVo(WxMerchantReceiverApplyVo receiver, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::tenantListVo");
if (null == receiver) receiver = new WxMerchantReceiverApplyVo();
final PageInfo<WxMerchantReceiverApplyVo> page = wxProfitSharingReceiverApplyService.listVoAsPage(receiver, pageNum, pageSize);
return new ResultData(page);
}

@TenantIgnore
@ApiOperation("修改功能状态")
@PostMapping("/updateFunctionState")
@SystemControllerLog(description = "修改")
public ResultData updateFunctionState(@RequestBody WxProfitSharingReceiverApply receiverAdd) {
log.debug("[" + getIpAddr() + "] merchantProfitSharingReceiver::updateFunctionState");
if(receiverAdd.getId() == null || receiverAdd.getFunctionState() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxProfitSharingReceiverApply receiverApply = wxProfitSharingReceiverApplyService.selectById(receiverAdd.getId());
if(receiverApply == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到进件数据");
}
if(!EnumSharingReceiverApplymentState.APPLYMENT_STATE_FINISHED.getCode().equals(receiverApply.getApplymentState())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "进件还未完成");
}
receiverAdd.updateTenantInfo(receiverApply);
return wxProfitSharingReceiverApplyService.updateFunctionState(receiverAdd);
}

@TenantIgnore
@ApiOperation("刷新审核状态")
@GetMapping("/syncApplymentStates")
@SystemControllerLog(description = "刷新")
public ResultData syncApplymentStates(Long id) {
log.debug("[" + getIpAddr() + "] merchantProfitSharingReceiver::syncApplymentStates");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "ID不能为空");
}

WxProfitSharingReceiverApply receiverApply = wxProfitSharingReceiverApplyService.findResultStateById(id);
if(receiverApply == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到进件数据");
}

return wxProfitSharingReceiverApplyService.handApplymentStates(receiverApply);
}

}

+ 889
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxProjectConfigController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.config.WechatWebProperties;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxWeappInfo;
import com.iformall.douyin.pay.TtPayService;
import com.iformall.douyin.payv2.request.CallBackSettingsRequest;
import com.iformall.enums.*;
import com.iformall.service.*;
import com.iformall.shiro.PasswordHelper;
import com.iformall.utils.Constant;
import com.iformall.utils.MaUtil;
import io.swagger.annotations.Api;
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.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import java.util.*;
import java.util.concurrent.TimeUnit;

@RestController
@Api(description = "初始化相关接口")
@RequestMapping("wxProjectConfig")
public class WxProjectConfigController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxProjectConfigService wxProjectConfigService;

@Autowired
WxCouponSendConfigService wxCouponSendConfigService;

@Autowired
WxMallService wxMallService;

@Autowired
WxPayAccountService wxPayAccountService;

@Autowired
MallUserInfoService userInfoService;

@Autowired
WxAppinfoService wxAppinfoService;

@Autowired
WxMsgConfigService wxMsgConfigService;

@Autowired
WxParkService wxParkService;

@Autowired
WxWiWideInfoService wxWiWideInfoService;

@Autowired
WxAuthorizerInfoService wxAuthorizerInfoService;

@Autowired
WxWeappExtSetService wxWeappExtSetService;

@Autowired
WxScoreRulesService wxScoreRulesService;

@Autowired
WxTemplateMsgService wxTemplateMsgService;

@Autowired
WxQuestionService wxQuestionService;

@Autowired
WxMsgValidationcodeModelService wxMsgValidationcodeModelService;

@Autowired
WxFlowConfigService wxFlowConfigService;

@Autowired
WxMallBuildingService wxMallBuildingService;

@Autowired
MallUserInfoService mallUserInfoService;

@Autowired
private WechatWebProperties wechatWebProperties;

@Autowired
private MaUtil maUtil;

@Autowired
@Qualifier("openRedisTemplate")
RedisTemplate<String, String> openRedisTemplate;


// @ApiOperation("添加商场基础数据")
// @GetMapping(value = "/init/{id}")
// @SystemControllerLog(description = "商场基础数据")
// @TenantIgnore
// public ResultData init(@PathVariable Long id) {
// logger.debug("[" + getIpAddr() + "] WxProjectConfigController::init");
// try {
// wxProjectConfigService.initProjectConfig(id);
// return new ResultData();
// }catch (Exception e){
// logger.error(e.getMessage(),e);
// return new ResultData(ErrorCode.SYS_SERVER_ERROR);
// }
//
// }

@ApiOperation("查询商场集团列表")
@GetMapping(value = "/childMallList")
@SystemControllerLog(description = "商场基础数据")
@TenantIgnore
public ResultData childMallList(@ModelAttribute WxMall wxMall, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::getMallList");
try {
if(wxMall == null){
wxMall = new WxMall();
}
wxMall.setParentTenantId(this.getTenantInfo().getTenantId());
PageInfo<WxMall> page = wxMallService.listAsPage(wxMall, pageNum, pageSize);
return new ResultData(page);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("查询商场集团列表")
@GetMapping(value = "/mallList")
@SystemControllerLog(description = "商场基础数据")
@TenantIgnore
public ResultData getMallList(@ModelAttribute WxMall wxMall, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::getMallList");
try {
if(wxMall == null){
wxMall = new WxMall();
}
PageInfo<WxMall> page = wxMallService.listAsPage(wxMall, pageNum, pageSize);
return new ResultData(page);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("查询商场集团列表(选择子集团)")
@GetMapping(value = "/mallListbyMall")
@SystemControllerLog(description = "商场基础数据")
@TenantIgnore
public ResultData mallListbyMall(@ModelAttribute WxMall wxMall) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::mallListbyMall");
try {
if(wxMall == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(wxMall.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setTenantId(wxMall.getId().toString());

WxMall parentWxMall = wxMallService.getByTenantInfo(tenantEntity);
if(parentWxMall == null
|| !parentWxMall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())
|| StringUtils.isNotBlank(parentWxMall.getParentTenantId())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}

List<WxMall> list = wxMallService.listAsSelectMall(wxMall.getId());
return new ResultData(list);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}


@ApiOperation("添加修改商场集团")
@PostMapping("/init/mall")
@SystemControllerLog(description = "商场集团-更新")
@TenantIgnore
public ResultData initMall(@RequestBody WxMall wxMall) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initMall");
try {
//集团版
if(EnumSaleType.GROUP.getCode().equals(wxMall.getSaleType())
|| EnumSaleType.GROUP_v1.getCode().equals(wxMall.getSaleType())){
wxMall.setGroupSupport(EnumGroupSupport.SUPPORT.getCode());
}else{
wxMall.setGroupSupport(EnumGroupSupport.NOT_SUPPORT.getCode());
}
if(wxMall.getId() == null && StringUtils.isBlank(wxMall.getBusinessHours())){
wxMall.setBusinessHours("[]");
}
if(wxMall.getId() == null && StringUtils.isBlank(wxMall.getIntroduction())){
wxMall.setIntroduction("");
}
if(wxMall.getId() == null && StringUtils.isBlank(wxMall.getImg())){
wxMall.setImg("");
}
if(wxMall.getId() == null && StringUtils.isBlank(wxMall.getWeapNote())){
wxMall.setWeapNote("{}");
}
wxProjectConfigService.initMall(wxMall);

return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("添加修改商场楼座信息")
@PostMapping("/init/building")
@SystemControllerLog(description = "商场楼座-更新")
@TenantIgnore
public ResultData initBuilding(@RequestBody List<WxMallBuilding> wxMallBuildings) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initBuilding");
try {
if(wxMallBuildings == null || wxMallBuildings.size() == 0){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
for (WxMallBuilding wxMallBuilding:wxMallBuildings) {
if(StringUtils.isBlank(wxMallBuilding.getTenantId())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
}
wxProjectConfigService.initBuilding(wxMallBuildings);

return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("添加修改商户号信息")
@PostMapping("/init/payAccount")
@SystemControllerLog(description = "商户号-更新")
@TenantIgnore
public ResultData initPayAccount(@RequestBody WxPayAccount wxPayAccount) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initPayAccount");
try {
if(wxPayAccount.getAppInfoId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"小程序Id必传");
}
// if(StringUtils.isBlank(wxPayAccount.getTenantId())){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"tenantId 必传");
// }
WxAppinfo appinfo = wxAppinfoService.getById(wxPayAccount.getAppInfoId());
if(appinfo == null || !EnumAppType.C.getCode().equals(appinfo.getType())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"小程序未找到或不是C端小程序");
}
wxPayAccount.updateTenantInfo(appinfo);

if(StringUtils.isBlank(wxPayAccount.getNotifyUrl())){
wxPayAccount.setNotifyUrl(wechatWebProperties.getUrl()+"/wxPay/notify");
}
// if(StringUtils.isBlank(wxPayAccount.getCertPath())){
// wxPayAccount.setCertPath("/opt/iformall/service/apiclient_cert.p12");
// }
if(wxPayAccount.getType() == null){
wxPayAccount.setType(1);//0:普通商户模式, 1:服务商模式(默认服务商模式)
}
if(wxPayAccount.getShare() == null){
wxPayAccount.setShare(0);//0: 未分账,1:分账(默认不分账)
}

wxProjectConfigService.initPayAccount(appinfo,wxPayAccount);

return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("查询商户号信息")
@GetMapping("/getinit/payAccount")
@SystemControllerLog(description = "商户号-查询")
@TenantIgnore
public ResultData getinitPayAccount(Long appInfoId) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initPayAccount");
try {
if(appInfoId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"小程序Id必传");
}
// if(StringUtils.isBlank(wxPayAccount.getTenantId())){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"tenantId 必传");
// }
WxAppinfo appinfo = wxAppinfoService.getById(appInfoId);
if(appinfo == null || !EnumAppType.C.getCode().equals(appinfo.getType())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"小程序未找到或不是C端小程序");
}
Map<String, Object> map = new HashMap<String, Object>();
if(appinfo.getPayId() != null) {
WxPayAccount wxPayAccount = wxPayAccountService.getById(appinfo.getPayId());
map.put("wxPayAccount",wxPayAccount);
}

return new ResultData(map);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("添加修改小程序信息")
@PostMapping("/init/appinfo")
@SystemControllerLog(description = "小程序信息-更新")
@TenantIgnore
public ResultData initAppinfo(@RequestBody WxAppinfo wxAppinfo) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initAppinfo");
try {
if(StringUtils.isBlank(wxAppinfo.getTenantId())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

wxAppinfoService.saveOrUpdate(wxAppinfo);

WxAuthorizerInfo wxAuthorizerInfo = wxAuthorizerInfoService.getByAppId(wxAppinfo.getAppId());
if(wxAuthorizerInfo == null){
wxAuthorizerInfo = new WxAuthorizerInfo();
}
// wxAuthorizerInfo.updateTenantInfo(wxAppinfo);
wxAuthorizerInfo.setTenantId(wxAppinfo.getTenantId());
wxAuthorizerInfo.setType(wxAppinfo.getType());
wxAuthorizerInfo.setAuthorizerAppid(wxAppinfo.getAppId());
wxAuthorizerInfo.setPlat(wxAppinfo.getPlat());
if(wxAuthorizerInfo.getAuthorizationStatus() == null){
wxAuthorizerInfo.setAuthorizationStatus(0);//授权状态,0为已授权,1为已取消授权
wxAuthorizerInfo.setAuthTime(new Date());
}
if(wxAuthorizerInfo.getBaseStatus() == null){
wxAuthorizerInfo.setBaseStatus(0);//微信基础版本设置状态,0为已设置,1为设置失败
wxAuthorizerInfo.setBaseTime(new Date());
}
if(wxAuthorizerInfo.getDomainStatus() == null){
wxAuthorizerInfo.setDomainStatus(0);//服务器域名设置状态,0为已设置,1为设置失败
wxAuthorizerInfo.setDomainTime(new Date());
}
if(wxAuthorizerInfo.getWebdomainStatus() == null){
wxAuthorizerInfo.setWebdomainStatus(0);//服务器业务域名设置状态,0为已设置,1为设置失败
wxAuthorizerInfo.setWebdomainTime(new Date());
}
if(StringUtils.isBlank(wxAuthorizerInfo.getRefreshToken())){
wxAuthorizerInfo.setRefreshToken("");
}
if(StringUtils.isBlank(wxAuthorizerInfo.getAccessToken())){
wxAuthorizerInfo.setAccessToken("");
}
wxAuthorizerInfoService.saveOrUpdate(wxAuthorizerInfo);

return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("启用/禁用小程序")
@PostMapping("/appinfoOnOff")
@SystemControllerLog(description = "启用/禁用小程序信息")
@TenantIgnore
public ResultData appinfoOnOff(@RequestBody WxAppinfo wxAppinfo) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::appinfoOnOff");
try {
if(wxAppinfo.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxAppinfo byId = wxAppinfoService.getById(wxAppinfo.getId());
if(byId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到小程序");
}
if(!EnumAppType.B.getCode().equals(byId.getType())
&& !EnumAppType.C.getCode().equals(byId.getType())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"小程序类型不支持");
}
if(wxAppinfo.getEnable() == null ||
(!EnumEnableType.Enable.getCode().equals(wxAppinfo.getEnable()) &&
!EnumEnableType.Disable.getCode().equals(wxAppinfo.getEnable()))){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"参数enable 不合法");
}
WxAppinfo updAppinfo = new WxAppinfo();
updAppinfo.setId(wxAppinfo.getId());
updAppinfo.setEnable(wxAppinfo.getEnable());
wxAppinfoService.saveOrUpdate(updAppinfo);
return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

/**
* 这里添加多个用户会生成多套角色
*/
@ApiOperation("添加修改商场后台管理帐号")
@PostMapping("/init/userInfo")
@SystemControllerLog(description = "商场后台管理帐号-更新")
@TenantIgnore
public ResultData initUserInfo(@RequestBody MallUserInfo userInfo) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initUserInfo");
try {
if(StringUtils.isBlank(userInfo.getTenantId())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(StringUtils.isBlank(userInfo.getUsername())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(StringUtils.isBlank(userInfo.getPhone())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
boolean bChangedPhone = false;
if(userInfo.getId() == null){
if(userInfoService.cntByUserName(userInfo.getUsername()) > 0){
return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在");
}
if(userInfoService.cntByUserPhone(userInfo.getPhone()) > 0){
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在");
}
Assert.notNull(userInfo.getPassword(), "密码不能为空");
PasswordHelper passwordHelper = new PasswordHelper();
passwordHelper.encryptPassword(userInfo);
userInfo.setIsAdmin(EnumUserAdmin.ADMIN.getCode());
userInfo.setInvestRule(EnumInvestUserType.ALL.getCode());

wxProjectConfigService.initUserInfo(userInfo);
}else{
MallUserInfo oldUser = userInfoService.getById(userInfo.getId());
if (!oldUser.getUsername().equals(userInfo.getUsername())) {
if(userInfoService.cntByUserName(userInfo.getUsername()) > 0){
return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在");
}
}
if (!oldUser.getPhone().equals(userInfo.getPhone())) {
if(userInfoService.cntByUserPhone(userInfo.getPhone()) > 0){
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在");
}
bChangedPhone = true;
}
if (StringUtils.isNotBlank(userInfo.getPassword()) && userInfo.getPassword().length() > 0) {
PasswordHelper passwordHelper = new PasswordHelper();
passwordHelper.encryptPassword(userInfo);
}else{
userInfo.setPassword(null);
}
userInfo.setIsAdmin(EnumUserAdmin.ADMIN.getCode());
userInfoService.saveOrUpdate(userInfo);

if(bChangedPhone) {
// 手机号修改,清除bopen_id, 清除web_open_id
userInfoService.cleanAllOpenId(userInfo);
}
}
return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

// @ApiOperation("添加修改商场短信配置")
// @PostMapping("/init/msgConfig")
// @SystemControllerLog(description = "商场后短信配置-更新")
// public ResultData initMsgConfig(@RequestBody WxMsgConfig wxMsgConfig) {
// logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initMsgConfig");
// try {
// if(StringUtils.isBlank(wxMsgConfig.getTenantId())){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// if(wxMsgConfig.getSmsChannel() == null){
// wxMsgConfig.setSmsChannel(EnumSMSChannel.WIWIDE.getCode());
// }
// if(wxMsgConfig.getSmsChannel() == EnumSMSChannel.WIWIDE.getCode()){
// wxMsgConfig.setSecret("7305150347587283553aa8898e7dbf20");
// wxMsgConfig.setPublickey("MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvh8j/zagfxQdnSh5OIic\\r" +
// "\\nMzN+MuRuWQJPjgu4Gza4+gX3j5Ln2xNDBOTjpwyuLBjh/JcBd1cGO3lAaKCwcaix\\r" +
// "\\nsmhTq56wVXXUMgDiAChu4ud8FSvRc8G8tdZAirKVAIi3NW+/pYgpWBs/0wnF8hz4\\r" +
// "\\n8no4pyJHl9Jc1LH3VNIMz8vqzKUPc4ack4pFUXlcNj6C+sBlaurmI4/vwLqNxBGs\\r" +
// "\\n7/zyM7dv6oy3DSU/Y1qBArM1YPjfL2dNun8rmtPgJvlPwXqA7uoHPwQ2Ym3aUn59\\r" +
// "\\npkS7QI6IE8uuqNkfSte8BXLd2nIqPLFxLYLDmdll7eoyRblHcHqAYSj8stK6StC7\\r" +
// "\\nDNryNKEjTEwbgf9trUI0uvF1pfgTy2gpclnY69FtD/m0+FvLyorMq+nmBqYMjka5\\r" +
// "\\nK0txDQJPOa7gsi//uXd/cJW2SAXY9MSO1AfMi8Xq/YKRQzN9FW5iapskXFHca7uX\\r" +
// "\\ng5NhH7flr6DW+QInFlpoN6WIEAuDF1aj4O49Ikm3WxwhTqnvEkdSCfivpYQkp9Sh\\r" +
// "\\n4kQ/SQdxuT7VX+Nz6k+uMx2z4cySk33bHi0KoHbA9QFGg/54Qd0+eU4qZnd4mrgh\\r" +
// "\\nhH7/QQhL7Z9eF1U5UPrsHq2Vq3rEnN+tYQ26AuKeU8vzTxBrC/SxC6C/SMFt3f/Y\\r" +
// "\\nnuFh1UnNJZleZwyQt+ZdGO0CAwEAAQ==");
// wxMsgConfig.setBid("465565");
// wxMsgConfig.setAccount("15626593768");
// wxMsgConfig.setNotifyurl("https://admin.malls.iformall.com/wxMsgCallback/receivemsg/" + wxMsgConfig.getTenantId());
// wxMsgConfig.setModelnotifyurl("https://admin.malls.iformall.com/wxMsgCallback/receivemodel/" + wxMsgConfig.getTenantId());
// wxMsgConfig.setVerifynotifyurl("https://admin.malls.iformall.com/wxMsgCallback/receiveverifymodel/" + wxMsgConfig.getTenantId());
// }
// if(wxMsgConfig.getTotal() == null){
// wxMsgConfig.setTotal((long) 100000);
// }
// wxMsgConfig.setRecharge((long) 0);
// wxMsgConfig.setRemains(wxMsgConfig.getTotal());
// wxMsgConfig.setReminderstatus(0);
// wxMsgConfigService.saveOrUpdate(wxMsgConfig);
// return new ResultData();
// }catch (Exception e){
// logger.error(e.getMessage(),e);
// return new ResultData(ErrorCode.SYS_SERVER_ERROR);
// }
// }

@ApiOperation("添加修改停车场配置")
@PostMapping("/init/park")
@SystemControllerLog(description = "商场停车场配置-更新")
@TenantIgnore
public ResultData initPark(@RequestBody WxPark wxPark) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initPark");
try {
if(StringUtils.isBlank(wxPark.getTenantId())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(StringUtils.isBlank(wxPark.getAddr())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(wxPark.getNumber() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(wxPark.getId() == null && StringUtils.isBlank(wxPark.getVendorParams())){
wxPark.setVendorParams("{}");
}
if(wxPark.getId() == null && wxPark.getVendorType() == null){
wxPark.setVendorType(0);
}
if(wxPark.getId() == null && StringUtils.isBlank(wxPark.getParkId())){
wxPark.setParkId("0");
}
if(wxPark.getId() == null && StringUtils.isBlank(wxPark.getStopFee())){
wxPark.setStopFee("");
}
if(wxPark.getId() == null && wxPark.getEntryExit() == null){
wxPark.setEntryExit(1);
}
wxParkService.saveOrUpdate(wxPark);
return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

// @ApiOperation("添加修改迈外迪信息")
// @PostMapping("/init/wiwidi")
// @SystemControllerLog(description = "迈外迪信息配置-更新")
// public ResultData initWiwidi(@RequestBody WxWiWideInfo wxWiWideInfo) {
// logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initPark");
// try {
// if(StringUtils.isBlank(wxWiWideInfo.getTenantId())){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// wxWiWideInfoService.saveOrUpdate(wxWiWideInfo);
// return new ResultData();
// }catch (Exception e){
// logger.error(e.getMessage(),e);
// return new ResultData(ErrorCode.SYS_SERVER_ERROR);
// }
// }

// @ApiOperation("添加修改微信公众账号的基本信息")
// @PostMapping("/init/authorizer")
// @SystemControllerLog(description = "微信公众账号的基本信息-更新")
// public ResultData initAuthorizer(@RequestBody WxAuthorizerInfo wxAuthorizerInfo) {
// logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initAuthorizer");
// try {
// if(StringUtils.isBlank(wxAuthorizerInfo.getTenantId())){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// if(wxAuthorizerInfo.getAuthorizationStatus() == null){
// wxAuthorizerInfo.setAuthorizationStatus(0);//授权状态,0为已授权,1为已取消授权
// wxAuthorizerInfo.setAuthTime(new Date());
// }
// if(wxAuthorizerInfo.getBaseStatus() == null){
// wxAuthorizerInfo.setBaseStatus(0);//微信基础版本设置状态,0为已设置,1为设置失败
// wxAuthorizerInfo.setBaseTime(new Date());
// }
// if(wxAuthorizerInfo.getDomainStatus() == null){
// wxAuthorizerInfo.setDomainStatus(0);//服务器域名设置状态,0为已设置,1为设置失败
// wxAuthorizerInfo.setDomainTime(new Date());
// }
// if(wxAuthorizerInfo.getWebdomainStatus() == null){
// wxAuthorizerInfo.setWebdomainStatus(0);//服务器业务域名设置状态,0为已设置,1为设置失败
// wxAuthorizerInfo.setWebdomainTime(new Date());
// }
// if(StringUtils.isNotBlank(wxAuthorizerInfo.getCurrentVersion())
// && wxAuthorizerInfo.getReleaseTime() != null){
// wxAuthorizerInfo.setReleaseTime(new Date());
// }
// if(StringUtils.isNotBlank(wxAuthorizerInfo.getOpenAppid())
// && wxAuthorizerInfo.getBindOpenTime() != null){
// wxAuthorizerInfo.setBindOpenTime(new Date());
// }
// if(StringUtils.isBlank(wxAuthorizerInfo.getRefreshToken())){
// wxAuthorizerInfo.setRefreshToken("");
// }
// if(StringUtils.isBlank(wxAuthorizerInfo.getAccessToken())){
// wxAuthorizerInfo.setAccessToken("");
// }
// wxAuthorizerInfoService.saveOrUpdate(wxAuthorizerInfo);
// return new ResultData();
// }catch (Exception e){
// logger.error(e.getMessage(),e);
// return new ResultData(ErrorCode.SYS_SERVER_ERROR);
// }
// }

@ApiOperation("查询商场基础数据")
@GetMapping(value = "/getinit/{id}")
@SystemControllerLog(description = "商场基础数据")
@TenantIgnore
public ResultData getinit(@PathVariable Long id) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::getinit");
try {
Map<String, Object> map = new HashMap<String, Object>();
WxMall wxMall = wxMallService.getById(id);
map.put("wxMall",wxMall);
List<WxMall> subWxMall = wxMallService.getSubByParentTenantId(wxMall.getTenantId());
map.put("subWxMall",subWxMall);
WxCouponSendConfig wxCouponSendConfig = new WxCouponSendConfig();
wxCouponSendConfig.setTenantId(wxMall.getTenantId());
List<WxCouponSendConfig> wxCouponSendConfigList = wxCouponSendConfigService.findList(wxCouponSendConfig);
map.put("wxCouponSendConfigList",wxCouponSendConfigList);
WxScoreRules wxScoreRules = new WxScoreRules();
wxScoreRules.setTenantId(wxMall.getTenantId());
List<WxScoreRules> wxScoreRulesList = wxScoreRulesService.findList(wxScoreRules);
map.put("wxScoreRulesList",wxScoreRulesList);
WxTemplateMsg wxTemplateMsg = new WxTemplateMsg();
wxTemplateMsg.setTenantId(wxMall.getTenantId());

List<WxTemplateMsg> wxTemplateMsgList = wxTemplateMsgService.findList(wxTemplateMsg);
map.put("wxTemplateMsgList",wxTemplateMsgList);
WxQuestion wxQuestion = new WxQuestion();
wxQuestion.setTenantId(wxMall.getTenantId());

List<WxQuestion> wxQuestionList = wxQuestionService.findList(wxQuestion);
map.put("wxQuestionList",wxQuestionList);
WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel();
wxMsgValidationcodeModel.setTenantId(wxMall.getTenantId());

List<WxMsgValidationcodeModel> wxMsgValidationcodeModelList = wxMsgValidationcodeModelService.findList(wxMsgValidationcodeModel);
map.put("wxMsgValidationcodeModelList",wxMsgValidationcodeModelList);
WxFlowConfig wxFlowConfig = new WxFlowConfig();
wxFlowConfig.setTenantId(wxMall.getTenantId());

List<WxFlowConfig> wxFlowConfigList = wxFlowConfigService.findList(wxFlowConfig);
map.put("wxFlowConfigList",wxFlowConfigList);
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setTenantId(wxMall.getTenantId());

ResultData wxMallBuildingFloorList = wxMallBuildingService.getBuildingFloorList(tenantEntity);
map.put("wxMallBuildingFloorList",wxMallBuildingFloorList.data);
WxAppinfo wxAppinfo = new WxAppinfo();
wxAppinfo.setTenantId(wxMall.getTenantId());

List<WxAppinfo> wxAppinfoList = wxAppinfoService.getList(wxAppinfo);
map.put("wxAppinfoList",wxAppinfoList);
MallUserInfo mallUserInfo = new MallUserInfo();
mallUserInfo.setTenantId(wxMall.getTenantId());
mallUserInfo. setIsAdmin(1);

List<MallUserInfo> mallUserInfoList = mallUserInfoService.findList(mallUserInfo);
map.put("mallUserInfoList",mallUserInfoList);
WxMsgConfig wxMsgConfig = new WxMsgConfig();
wxMsgConfig.setTenantId(wxMall.getTenantId());

WxMsgConfig wxMsgConfigObject = wxMsgConfigService.findObject(wxMsgConfig);
map.put("wxMsgConfig",wxMsgConfigObject);
WxPark wxPark = new WxPark();
wxPark.setTenantId(wxMall.getTenantId());

WxPark wxParkObj = wxParkService.getByObj(wxPark);
map.put("wxPark",wxParkObj);
WxWiWideInfo wxWiWideInfo = new WxWiWideInfo();
wxWiWideInfo.setTenantId(wxMall.getTenantId());

WxWiWideInfo wxWiWideInfoObject = wxWiWideInfoService.findObject(wxWiWideInfo);
map.put("wxWiWideInfo",wxWiWideInfoObject);
WxWeappInfo wxWeappInfo = new WxWeappInfo();
wxWeappInfo.setTenantId(wxMall.getTenantId());

List<WxWeappInfo> wxAuthorizerInfoList = wxAuthorizerInfoService.getList(wxWeappInfo);
map.put("wxAuthorizerInfoList",wxAuthorizerInfoList);

return new ResultData(map);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("集团新增修改子广场")
@PostMapping("/init/submall")
@SystemControllerLog(description = "子广场-更新")
@TenantIgnore
public ResultData initSubmall(@RequestBody Map<String, Object> map) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initSubmall");
try {
String tenantId = (String) map.get("tenantId");
List<String> subTenantIds = (List<String>) map.get("subTenantIds");

if(StringUtils.isBlank(tenantId)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
// if(subTenantIds == null || subTenantIds.length == 0){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setTenantId(tenantId);
if(!wxMallService.isgroupSupport(tenantEntity)){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}
wxProjectConfigService.initSubmall(tenantId,subTenantIds);

return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("刷集团商场历史数据(五分钟内只能掉一次)")
@PostMapping("/init/after/group")
@SystemControllerLog(description = "商场-数据更新")
@TenantIgnore
public ResultData initAfterGroup(@RequestBody Map<String, Object> map) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initAfterGroup");
try {
String tenantId = (String) map.get("tenantId");
List<String> subTenantIds = (List<String>) map.get("subTenantIds");
String subTenantIdStrs = null;

if(StringUtils.isBlank(tenantId)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(subTenantIds == null || subTenantIds.size() == 0){
//return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}else{
subTenantIdStrs = StringUtils.join(subTenantIds, ',');
}
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setTenantId(tenantId);

if(!wxMallService.isgroupSupport(tenantEntity)){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}
StringBuilder sb = new StringBuilder();
sb.append(Constant.INTERFACE_VISIT_LIMIT_KEY).append("initAfterGroup");
String key = sb.toString();
boolean hasKey = openRedisTemplate.hasKey(key);
if(hasKey){
return new ResultData(ErrorCode.TOO_MANY_REQUEST);
}else{
openRedisTemplate.opsForValue().set(key,"1",3000, TimeUnit.SECONDS);
}

// String join = StringUtils.join(subTenantIds, ',');
wxProjectConfigService.initAfterGroup(tenantId,subTenantIdStrs);

return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("查询ext数据")
@GetMapping(value = "/getExt/{appId}")
@SystemControllerLog(description = "商场基础数据")
@TenantIgnore
public ResultData getExt(@PathVariable String appId) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::getExt");
try {
if(StringUtils.isBlank(appId)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxWeappExtSet byAppId = wxWeappExtSetService.getByAppId(appId);
return new ResultData(byAppId);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("添加修改ext数据配置")
@PostMapping("/init/appExt")
@SystemControllerLog(description = "商场ext数据配置-更新")
@TenantIgnore
public ResultData initAppExt(@RequestBody WxWeappExtSet wxWeappExtSet) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initAppExt");
try {
wxWeappExtSetService.updateById(wxWeappExtSet);
return new ResultData();
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("获取抖音支付2.0 回调接口配置")
@GetMapping("/ttcallback/query/settings")
@SystemControllerLog(description = "")
@TenantIgnore
public ResultData ttcallbackQuerySettings(String appid) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackQuerySettings");
try {
WxAppinfo appinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appid);
if(appinfo == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序");
}
if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat())
|| !EnumAppType.C.getCode().equals(appinfo.getType())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持");
}
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appinfo.getPayId());
if(payAccount == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的支付数据");
}
TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount);
CallBackSettingsRequest callBackSettingsRequest = ttPayService.querySettings();
return new ResultData(callBackSettingsRequest);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("配置抖音支付2.0 回调接口")
@PostMapping("/ttcallback/settings")
@SystemControllerLog(description = "商场集团-更新")
@TenantIgnore
public ResultData ttcallbackSettings(@RequestBody Map<String, String> map) {
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackSettings");
String appid = map.get("appid");
String create_order_callback = map.get("createOrderCallback");
String refund_callback = map.get("refundCallback");
String delivery_qrcode_redirect = map.get("deliveryQrcodeRedirect");
if(StringUtils.isBlank(appid) || StringUtils.isBlank(create_order_callback)
|| StringUtils.isBlank(refund_callback)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
try {
WxAppinfo appinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appid);
if(appinfo == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序");
}
if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat())
|| !EnumAppType.C.getCode().equals(appinfo.getType())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持");
}
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appinfo.getPayId());
if(payAccount == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的支付数据");
}
TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount);
CallBackSettingsRequest request = new CallBackSettingsRequest();
request.setCreateOrderCallback(create_order_callback);
request.setRefundCallback(refund_callback);
request.setDeliveryQrcodeRedirect(delivery_qrcode_redirect);
boolean b = ttPayService.callbackSettings(request);
if(b){
return new ResultData();
}else{
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

}

+ 209
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxShopController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
* @author gongbiao
*/
@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)})
@SystemControllerLog(description = "店铺管理-列表")
public ResultData list(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxShopController::list");
if (null == wxShop){
wxShop = new WxShop();
}
wxShop.updateTenantInfo(getTenantInfo());
wxShop.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC);

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

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "店铺管理-新增")
public ResultData add(@RequestBody WxShop wxShop) {
logger.debug("[" + getIpAddr() + "] WxShopController::add");
wxShop.updateTenantInfo(getTenantInfo());
return wxShopService.saveOrUpdate(wxShop);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "店铺管理-更新")
public ResultData update(@RequestBody WxShop wxShop) {
logger.debug("[" + getIpAddr() + "] WxShopController::update");
if (null == wxShop){
wxShop = new WxShop();
}
wxShop.updateTenantInfo(getTenantInfo());
return wxShopService.saveOrUpdate(wxShop);
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@SystemControllerLog(description = "店铺管理-删除")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxShopController::delete");
Integer isAdmin = getUser().getIsAdmin();
return wxShopService.deleteById(id, isAdmin);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "店铺管理-id查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxShopController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxShopService.getById(id));
}

@ApiOperation("获取商铺数据")
@GetMapping("getShopListByShopNumber")
@ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true)
@SystemControllerLog(description = "店铺管理-获取商铺数据")
public ResultData getShoplist(String shopNumber) {
logger.debug("[" + getIpAddr() + "] WxShopController::getbshoplist");
return wxShopService.getShopList(getTenantInfo(), shopNumber);
}

@ApiOperation("获取商户商铺数据")
@GetMapping("getMerchantShopByShopId")
@ApiImplicitParam(name = "shopId", value = "shopId", dataType = "String", paramType = "query", required = true)
@SystemControllerLog(description = "店铺管理-获取商户商铺数据")
public ResultData getMerchantShopByShopId(String shopId) {
logger.debug("[" + getIpAddr() + "] WxShopController::getMerchantShopByShopId");
return wxShopService.getMerchantShopByShopId(getTenantInfo(), 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"),
@ApiImplicitParam(name = "type", value = "type", dataType = "Integer", paramType = "query", required = true)})
@SystemControllerLog(description = "店铺管理-查询商铺号是否存在")
public ResultData hasShopNumber(String shopNumber, Long id, Integer type) {
logger.debug("[" + getIpAddr() + "] WxShopController::hasShopNumber");
WxShop wxShop = new WxShop();
wxShop.setShopNumber(shopNumber);
wxShop.setType(type);

wxShop.setId(id);
wxShop.updateTenantInfo(getTenantInfo());
return wxShopService.hasShopNumber(wxShop);
}

@ApiOperation("查询商铺地图sid是否存在")
@GetMapping("hasShopSid")
@ApiImplicitParams({
@ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true),
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query"),
@ApiImplicitParam(name = "type", value = "type", dataType = "Integer", paramType = "query", required = true)})
@SystemControllerLog(description = "店铺管理-查询商铺号是否存在")
public ResultData hasShopSid(String shopSid, Long id) {
logger.debug("[" + getIpAddr() + "] WxShopController::hasShopSid");
WxShop wxShop = new WxShop();
wxShop.setSid(shopSid);

wxShop.setId(id);
wxShop.updateTenantInfo(getTenantInfo());
return wxShopService.hasShopSid(wxShop);
}


@ApiOperation("分页列表接品-合同访问")
@GetMapping("listShopFromContract")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "店铺管理-合同访问")
public ResultData listShopFromContract(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxShopController::listShopFromContract");
if (null == wxShop){
wxShop = new WxShop();
}
wxShop.updateTenantInfo(getTenantInfo());
wxShop.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<Map<String, Object>> page = wxShopService.listShopFromContract(wxShop, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("导出店铺")
@GetMapping("/exportShop")
@SystemControllerLog(description = "店铺管理-导出店铺")
public void exportShop(@ModelAttribute WxShop wxShop, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxShopController::exportShop");
if (null == wxShop){
wxShop = new WxShop();
}
wxShop.updateTenantInfo(getTenantInfo());
wxShop.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC);
wxShopService.exportShop(wxShop, request, response);
}

@TenantIgnore
@ApiOperation("导出未出租店铺")
@GetMapping("/exportNotRentShop")
@SystemControllerLog(description = "商铺出租数据-未出租商铺列表-导出")
public void exportNotRentShop(@ModelAttribute WxShop wxShop, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxShopController::exportNotRentShop");
if (null == wxShop){
wxShop = new WxShop();
}
wxShop.updateTenantInfo(getTenantInfo());
wxShop.setSortColumns(BaseEntity.SortField.SCreateDate_DESC,BaseEntity.SortField.SId_DESC);
wxShopService.exportNotRentShop(wxShop, request, response);
}

@TenantIgnore
@ApiOperation("未出租商铺分页列表接口")
@GetMapping("notRentShopList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "未出租商铺分页列表接口")
public ResultData notRentShopList(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxShopController::notRentShopList");
if (null == wxShop){
wxShop = new WxShop();
}
wxShop.updateTenantInfo(getTenantInfo());
wxShop.setSortColumns(BaseEntity.SortField.SCreateDate_DESC,BaseEntity.SortField.SId_DESC);

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

+ 52
- 0
suimangAdmin/src/main/java/com/iformall/controller/basic/WxTagsController.java View File

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

import java.util.Arrays;

import com.iformall.annotation.SystemControllerLog;
import com.iformall.controller.base.BaseController;
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.Result;
import com.iformall.common.ResultData;
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("标签弹窗接口")
@SystemControllerLog(description = "会员管理-标签获取")
public ResultData getAllList() {
logger.debug("[" + getIpAddr() + "] WxTagsController::getAllList");
return new ResultData(wxTagsService.listAllVo(getTenantInfo()));
}

@ApiOperation("查询会员用户人群")
@GetMapping("findCountByTag")
@SystemControllerLog(description = "会员管理-查询会员用户人群")
public Result findCountByTag(Long[] tagIds) {
logger.debug("[" + getIpAddr() + "] WxTagsController::findCountByTag");
return new ResultData(wxCUserTagsService.findTagList(getTenantInfo(), Arrays.asList(tagIds)));
}


}

+ 113
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/AliBusinessCircleOrderController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.AliBusinessCircleOrder;
import com.iformall.domain.po.WxBusinessCircleOrder;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.service.AliBusinessCircleOrderService;
import com.iformall.utils.Constant;
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.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
@RequestMapping("aliCircle")
@Api(description = "订单相关接口")
public class AliBusinessCircleOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private AliBusinessCircleOrderService aliBusinessCircleOrderService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "-列表")
public ResultData list(@ModelAttribute AliBusinessCircleOrder circleOrder, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::list");
if (null == circleOrder) {
circleOrder = new AliBusinessCircleOrder();
}
circleOrder.updateTenantInfo(getTenantInfo());
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<AliBusinessCircleOrder> page = aliBusinessCircleOrderService.listAsPage(circleOrder, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("统计接口")
@GetMapping("statistics")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "-统计")
public ResultData statistics(@ModelAttribute AliBusinessCircleOrder circleOrder) {
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::statistics");
if (null == circleOrder) {
circleOrder = new AliBusinessCircleOrder();
}
circleOrder.updateTenantInfo(getTenantInfo());
Integer sumPayAmount = aliBusinessCircleOrderService.sumCirclePayment(circleOrder);
Integer sumRefundAmount = aliBusinessCircleOrderService.sumCircleRefundAmount(circleOrder);
Map resultMap = new HashMap();
resultMap.put("sumPayAmount",sumPayAmount);
resultMap.put("sumRefundAmount",sumRefundAmount);
return new ResultData(resultMap);
}

@ApiOperation("详情接口")
@GetMapping("detail")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true)
})
public ResultData detail(String orderId) {
if (StringUtils.isBlank(orderId) || orderId.equalsIgnoreCase(Constant.UNDEFINED)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
Long id;
try {
id = Long.valueOf(orderId);
} catch (NumberFormatException e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "orderId: " + orderId + ", e: " + e.getMessage());
}

AliBusinessCircleOrder order = aliBusinessCircleOrderService.detail(id,getTenantInfo());
return new ResultData(order);
}

@GetMapping("exportData")
@SystemControllerLog(description = "券订单数据-导出数据")
public void exportData(@ModelAttribute AliBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::exportData");
if (null == circleOrder) {
circleOrder = new AliBusinessCircleOrder();
}
circleOrder.updateTenantInfo(getTenantInfo());
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
aliBusinessCircleOrderService.exportData(circleOrder, request, response);
}


}

+ 46
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/FengNiaoMapController.java View File

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

import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.FengNiaoMapConfig;
import com.iformall.service.FengNiaoMapService;
import io.swagger.annotations.Api;
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.*;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("fengniaomap")
@Api(description = "蜂鸟地图")
public class FengNiaoMapController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private FengNiaoMapService fengNiaoMapService;

@ApiOperation("查询地图配置")
@GetMapping("/getConfig")
public ResultData getConfig() {
String tenantId = getTenantInfo().getTenantId();
if (!StringUtils.isBlank(tenantId)) {
try {
FengNiaoMapConfig config = fengNiaoMapService.getConfigByTenantId(tenantId);
return new ResultData(Result.SUCCESS, "查询成功", config);
}catch(Exception e) {
logger.error("fengniaomap getConfig error.",e);
return new ResultData(Result.SUCCESS, "查询成功", null);
}
}else {
return new ResultData(Result.SUCCESS, "查询成功", null);
}
}
}

+ 124
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/MarkingDataReportController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.dto.MarkingCouponDataReportDto;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.service.MarkingDataReportService;
import com.iformall.service.WxMallService;
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.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
* 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;
@Autowired
private WxMallService wxMallService;

@TenantIgnore
@ApiOperation("查询券数据")
@GetMapping("/couponData")
@SystemControllerLog(description = "券数据-查询券数据")
public ResultData findCouponData() {
logger.debug("[" + getIpAddr() + "] MarkingDataReportController::findCouponData");
return new ResultData(markingDataReportService.getCouponData(getTenantInfo()));
}

@TenantIgnore
@ApiOperation("查询券数据列表")
@GetMapping("/couponDataList")
@SystemControllerLog(description = "券数据-查询券数据列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData findCouponDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] MarkingDataReportController::findCouponDataList");
return new ResultData(markingDataReportService.getCouponDataList(getTenantInfo(), markingCouponDataReportDto, pageNum, pageSize));
}

@TenantIgnore
@ApiOperation("查询场景投放券数据")
@GetMapping("/sceneData")
@SystemControllerLog(description = "券数据-查询场景投放券数据")
public ResultData findSceneData() {
logger.debug("[" + getIpAddr() + "] MarkingDataReportController::findSceneData");
return new ResultData(markingDataReportService.getSceneData(getTenantInfo()));
}

@TenantIgnore
@ApiOperation("查询场景营销数据列表")
@GetMapping("/sceneDataList")
@SystemControllerLog(description = "券数据-查询场景营销数据列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData findSceneDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] MarkingDataReportController::findSceneDataList");
return new ResultData(markingDataReportService.getSceneDataList(getTenantInfo(), markingCouponDataReportDto, pageNum, pageSize));
}

@TenantIgnore
@ApiOperation("查询触达用户数数据")
@GetMapping("/touchUsersData")
@SystemControllerLog(description = "券数据-查询触达用户数数据")
public ResultData touchUsersData() {
logger.debug("[" + getIpAddr() + "] MarkingDataReportController::touchUsersData");
return new ResultData(markingDataReportService.getTouchUsersReportData(getTenantInfo()));
}

@TenantIgnore
@ApiOperation("查询触达用户数数据列表")
@GetMapping("/touchUsersDataList")
@SystemControllerLog(description = "券数据-查询触达用户数数据列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData touchUsersDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] MarkingDataReportController::touchUsersDataList");
TenantEntity tenantInfo = getTenantInfo();
//List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantInfo);
//markingCouponDataReportDto.setTenantEntitys(tenantEntitys);
markingCouponDataReportDto.updateTenantInfo(tenantInfo);
markingCouponDataReportDto.setTenantEntity(tenantInfo);
return new ResultData(markingDataReportService.getTouchUsersReportList(markingCouponDataReportDto, pageNum, pageSize));
}

@TenantIgnore
@ApiOperation("触达用户数数据导出")
@GetMapping("/exportTouchUsersData")
@SystemControllerLog(description = "券数据-触达用户数数据导出")
public void exportTouchUsersData(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, HttpServletRequest request, HttpServletResponse response) {
TenantEntity tenantInfo = getTenantInfo();
//List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantInfo);
//markingCouponDataReportDto.setTenantEntitys(tenantEntitys);
markingCouponDataReportDto.updateTenantInfo(tenantInfo);
markingCouponDataReportDto.setTenantEntity(tenantInfo);
markingDataReportService.exportTouchUsersData(request, response, markingCouponDataReportDto);
}


}

+ 42
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/PushLimitController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.PushLimit;
import com.iformall.service.PushLimitService;
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("pushLimit")
@Api(description = "疲劳度相关接口")
public class PushLimitController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private PushLimitService pushLimitService;

@ApiOperation("疲劳度配置")
@GetMapping("setting")
@SystemControllerLog(description = "疲劳度-配置获取")
public ResultData list() {
logger.debug("[" + getIpAddr() + "] PushLimitController::list");
PushLimit pushLimit = pushLimitService.getPushLimit(getTenantInfo());
return new ResultData(pushLimit);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "疲劳度-配置更新")
public ResultData update(@RequestBody PushLimit pushLimit) {
logger.debug("[" + getIpAddr() + "] PushLimitController::update");
pushLimit.updateTenantInfo(getTenantInfo());
pushLimitService.saveOrUpdate(pushLimit);
return new ResultData();
}
}

+ 189
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.TtCouponChannelVo;
import com.iformall.domain.vo.TtCouponVo;
import com.iformall.douyin.web.bean.GoodsTemplateGet;
import com.iformall.enums.*;
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 me.chanjar.weixin.common.error.WxErrorException;
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.*;


@RestController
@RequestMapping("ttgoods")
@Api(description = "抖音商品库")
public class TtCouponGoodsController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponService wxCouponService;

@Autowired
private TtCouponGoodsService ttCouponGoodsService;

@Autowired
private TtMerchantPoiService ttMerchantPoiService;

@Autowired
private TtGoodsCategoryService ttGoodsCategoryService;

// @ApiOperation("分页列表接口")
// @GetMapping("couponList")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
// @SystemControllerLog(description = "-列表")
// public ResultData couponList(@ModelAttribute TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) {
// logger.debug("[" + getIpAddr() + "] WxCouponController::couponList");
// if (ttCouponVo == null) ttCouponVo = new TtCouponVo();
// ttCouponVo.updateTenantInfo(getTenantInfo());
// ttCouponVo.setType(EnumCouponType.COUPON_DOUYIN.getCode());
// if(StringUtils.isNotBlank(ttCouponVo.getSortColumn())){
// String coryColumn = "c."+ttCouponVo.getSortColumns();
// ttCouponVo.setSortColumns(coryColumn);
// ttCouponVo.setSortColumn(null);
// }else{
// ttCouponVo.setSortColumns(BaseEntity.SortField.CCreateDate_DESC, BaseEntity.SortField.CId_DESC);
// }
// if (ttCouponVo.getStatus() != null && ttCouponVo.getStatus() == -1)
// ttCouponVo.setStatus(null);
// return ttCouponGoodsService.couponList(ttCouponVo, pageNum, pageSize);
// }
//
// @ApiOperation("分页列表接口")
// @GetMapping("channelList")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
// @SystemControllerLog(description = "-列表")
// public ResultData channelList(@ModelAttribute TtCouponChannelVo ttChannelVo, Integer pageNum, Integer pageSize) {
// logger.debug("[" + getIpAddr() + "] WxCouponController::channelList");
// if (ttChannelVo == null) ttChannelVo = new TtCouponChannelVo();
// ttChannelVo.updateTenantInfo(getTenantInfo());
// ttChannelVo.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode());
// if(null == ttChannelVo.getSourceType()){
// ttChannelVo.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
// }
//
// if(StringUtils.isNotBlank(ttChannelVo.getSortColumn())){
// String coryColumn = "cc."+ttChannelVo.getSortColumns();
// ttChannelVo.setSortColumns(coryColumn);
// ttChannelVo.setSortColumn(null);
// }else{
// ttChannelVo.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);
// }
//
// return ttCouponGoodsService.channelList(ttChannelVo, pageNum, pageSize);
// }

@ApiOperation("根据类目获取商品模板")
@GetMapping("getTemplate")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "根据类目获取商品模板")
public ResultData getGoodsTemplate(Long couponId,Integer categoryId,Integer productType) {
logger.debug("[" + getIpAddr() + "] WxCouponController::getGoodsTemplate");
if(productType == null){
productType = 1;
}
if(couponId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxCoupon coupon = wxCouponService.getAttrsById(couponId, getTenantInfo().getTenantId());
if(coupon == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

try {
GoodsTemplateGet goodsTemplateGet = ttMerchantPoiService.getTtWebService(getTenantInfo()).getGoodsService().templateGet(categoryId, productType);
ttGoodsCategoryService.adminIsShow(goodsTemplateGet);
ttGoodsCategoryService.handTemplate(goodsTemplateGet,coupon);
return new ResultData(goodsTemplateGet);
} catch (WxErrorException e) {
e.printStackTrace();
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}

}

@TenantIgnore
@ApiOperation("提交审核")
@PostMapping("product/save")
@SystemControllerLog(description = "提交审核")
public ResultData productSave(@RequestBody WxCoupon wxCoupon) {
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(), getTenantInfo().getTenantId());
if(coupon == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(coupon.getSalePrice() == null || coupon.getSalePrice().intValue() == 0){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"免费券无需提审");
}

try {
return ttCouponGoodsService.productSave(coupon);
} catch (Exception e) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}
}

@ApiOperation("实时查询审核状态")
@GetMapping("product/draft")
@SystemControllerLog(description = "实时查询审核状态")
public ResultData productDraft(Long id) {
if (id == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
return ttCouponGoodsService.productDraftGet(getTenantInfo(),id);
}

@ApiOperation("实时查询线上商品状态")
@GetMapping("product/online")
@SystemControllerLog(description = "实时查询审核状态")
public ResultData productOnline(Long id) {
if (id == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
return ttCouponGoodsService.productOnlineGet(getTenantInfo(),id);
}

@ApiOperation("实时同步上下架状态")
@GetMapping("product/operate")
@SystemControllerLog(description = "实时同步上下架状态")
public ResultData productOperate(Long id) {
if (id == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
return ttCouponGoodsService.productOperate(getTenantInfo(),id);
}

@ApiOperation("实时同步库存")
@GetMapping("product/stock/sync")
@SystemControllerLog(description = "实时同步库存")
public ResultData productStockSync(Long id) {
if (id == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
return ttCouponGoodsService.productStockSync(getTenantInfo(),id);
}



}

+ 27
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/UeditorController.java View File

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

import com.iformall.ueditor.ActionEnter;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("/ue")
@Api(description = "网页bannner图接口")
public class UeditorController {

@Autowired
private ActionEnter actionEnter;

@ResponseBody
@RequestMapping("/ueditor/exec")
public Object exe(HttpServletRequest request){
return actionEnter.exec(request);
}

}

+ 132
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxActivityController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxActivity;
import com.iformall.enums.EnumActivityStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxActivityService;
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.*;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("wxActivity")
@Api(description = "活动")
public class WxActivityController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxActivityService wxActivityService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "活动-列表")
public ResultData list(@ModelAttribute WxActivity wxActivity, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxActivityController::list");
if (null == wxActivity) wxActivity = new WxActivity();
if (wxActivity.getStatus() != null && wxActivity.getStatus() == -1) {
wxActivity.setStatus(null);
}
wxActivity.updateTenantInfo(getTenantInfo());
wxActivity.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<WxActivity> page = wxActivityService.listAsPage(wxActivity, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "活动-新增")
public ResultData add(@RequestBody WxActivity wxActivity) {
logger.debug("[" + getIpAddr() + "] WxActivityController::add");
wxActivity.setStatus(EnumActivityStatus.STATUS_THROW_IN.getCode());
wxActivity.updateTenantInfo(getTenantInfo());
try {
return wxActivityService.saveOrUpdate(wxActivity);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "活动-id更新")
public ResultData update(@RequestBody WxActivity wxActivity) {
logger.debug("[" + getIpAddr() + "] WxActivityController::update");
try {
return wxActivityService.saveOrUpdate(wxActivity);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
}

@ApiOperation("根据id更新接口")
@PostMapping("updateStatus")
@SystemControllerLog(description = "活动-更新状态")
public ResultData updateStatus(@RequestBody WxActivity wxActivity) {
logger.debug("[" + getIpAddr() + "] WxActivityController::updateStatus");
try {
return wxActivityService.updateStatus(wxActivity);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "活动-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxActivityController::findById");
WxActivity wxActivity = wxActivityService.getById(id);
return new ResultData(wxActivity);
}

@ApiOperation("投放到宣传页")
@GetMapping("/sendToCampaign")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "活动-投放到宣传页")
public ResultData sendToCampaign(Long id) {
logger.debug("[" + getIpAddr() + "] WxActivityController::sendToCampaign");
return wxActivityService.sendToCampaign(id);
}

@ApiOperation("从宣传页下线")
@PostMapping("offLineCampaign")
@SystemControllerLog(description = "活动-更新状态")
public ResultData offLineCampaign(@RequestBody WxActivity wxActivity) {
logger.debug("[" + getIpAddr() + "] WxActivityController::updateStatus");
return wxActivityService.offLineCampaign(wxActivity);
}

@ApiOperation("删除")
@PostMapping("deleteById")
@SystemControllerLog(description = "活动-删除")
public ResultData deleteById(@RequestBody WxActivity wxActivity) {
logger.debug("[" + getIpAddr() + "] WxActivityController::deleteById");
if(wxActivity.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return wxActivityService.deleteById(wxActivity.getId(),getTenantInfo().getTenantId());
}

}

+ 114
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxActivityJoinController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxActivityJoin;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxActivityJoinService;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("wxActivityJoin")
@Api(description = "活动参与信息")
public class WxActivityJoinController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxActivityJoinService wxActivityJoinService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "活动参与信息-列表")
public ResultData list(@ModelAttribute WxActivityJoin wxActivityJoin, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxActivityJoinController::list");
if (null == wxActivityJoin) {
wxActivityJoin = new WxActivityJoin();
}
wxActivityJoin.updateTenantInfo(getTenantInfo());
wxActivityJoin.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<WxActivityJoin> page = wxActivityJoinService.listAsPage(wxActivityJoin, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("确认或取消报名")
@PostMapping("modifyStatus")
@SystemControllerLog(description = "活动参与信息-确认或取消报名")
public ResultData modifyStatus(@RequestBody WxActivityJoin wxActivityJoin) {
logger.debug("[" + getIpAddr() + "] WxActivityJoinController::modifyStatus");

if (wxActivityJoin.getId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空");
}
if (wxActivityJoin.getActivityId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空");
}
if (wxActivityJoin.getStatus() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "status不能为空");
}
try {
return wxActivityJoinService.modifyStatus(wxActivityJoin);
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(), e.getMessage());
}
}

@ApiOperation("导出报名表")
@RequestMapping("/exportData")
@SystemControllerLog(description = "活动参与信息-导出报名表")
public void exportData(@ModelAttribute WxActivityJoin wxActivityJoin, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxActivityJoinController::exportData");
if (wxActivityJoin.getActivityId() == null) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空");
}
wxActivityJoin.updateTenantInfo(getTenantInfo());
wxActivityJoinService.exportData(request, response, wxActivityJoin);

}

@ApiOperation("查询报名总数")
@GetMapping("queryJoinInfo")
@SystemControllerLog(description = "活动参与信息-查询报名总数")
public ResultData queryJoinInfo(@ModelAttribute WxActivityJoin wxActivityJoin) {
logger.debug("[" + getIpAddr() + "] WxActivityJoinController::queryJoinInfo");

if (wxActivityJoin.getActivityId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空");
}
wxActivityJoin.updateTenantInfo(getTenantInfo());
return wxActivityJoinService.queryJoinInfo(wxActivityJoin);
}

@ApiOperation("发送短信")
@GetMapping("sendMsg")
@SystemControllerLog(description = "活动参与信息-发送短信")
public ResultData sendMsg(@ModelAttribute WxActivityJoin wxActivityJoin) {
logger.debug("[" + getIpAddr() + "] WxActivityJoinController::confirmCompletion");

if (wxActivityJoin.getActivityId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空");
}
wxActivityJoin.updateTenantInfo(getTenantInfo());
return wxActivityJoinService.sendMsg(wxActivityJoin);
}

}

+ 109
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxBusinessCircleOrderController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.service.*;
import com.iformall.utils.Constant;
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.HashMap;
import java.util.Map;

@RestController
@RequestMapping("wxCircle")
@Api(description = "订单相关接口")
public class WxBusinessCircleOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxBusinessCircleOrderService wxBusinessCircleOrderService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "-列表")
public ResultData list(@ModelAttribute WxBusinessCircleOrder circleOrder, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxBusinessCircleOrderController::list");
if (null == circleOrder) {
circleOrder = new WxBusinessCircleOrder();
}
circleOrder.updateTenantInfo(getTenantInfo());
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<WxBusinessCircleOrder> page = wxBusinessCircleOrderService.listAsPage(circleOrder, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("统计接口")
@GetMapping("statistics")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "-统计")
public ResultData statistics(@ModelAttribute WxBusinessCircleOrder circleOrder) {
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::statistics");
if (null == circleOrder) {
circleOrder = new WxBusinessCircleOrder();
}
circleOrder.updateTenantInfo(getTenantInfo());
Integer sumPayAmount = wxBusinessCircleOrderService.sumCirclePayment(circleOrder);
Integer sumRefundAmount = wxBusinessCircleOrderService.sumCircleRefundAmount(circleOrder);
Map resultMap = new HashMap();
resultMap.put("sumPayAmount",sumPayAmount);
resultMap.put("sumRefundAmount",sumRefundAmount);
return new ResultData(resultMap);
}

@ApiOperation("详情接口")
@GetMapping("detail")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true)
})
public ResultData detail(String orderId) {
if (StringUtils.isBlank(orderId) || orderId.equalsIgnoreCase(Constant.UNDEFINED)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
Long id;
try {
id = Long.valueOf(orderId);
} catch (NumberFormatException e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "orderId: " + orderId + ", e: " + e.getMessage());
}

WxBusinessCircleOrder order = wxBusinessCircleOrderService.detail(id,getTenantInfo());
return new ResultData(order);
}

@GetMapping("exportData")
@SystemControllerLog(description = "券订单数据-导出数据")
public void exportData(@ModelAttribute WxBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxBusinessCircleOrderController::exportData");
if (null == circleOrder) {
circleOrder = new WxBusinessCircleOrder();
}
circleOrder.updateTenantInfo(getTenantInfo());
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
wxBusinessCircleOrderService.exportData(circleOrder, request, response);
}


}

+ 216
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCampaignController.java View File

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

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxCampaign;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.*;
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.Date;
import java.util.List;

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

@Autowired
private WxCampaignService wxCampaignService;

@Autowired
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)})
@SystemControllerLog(description = "宣传页-列表")
public ResultData list(@ModelAttribute WxCampaign wxCampaign, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::list");
if (null == wxCampaign) wxCampaign = new WxCampaign();
if (wxCampaign.getStatus() != null && wxCampaign.getStatus() == -1) {
wxCampaign.setStatus(null);
}
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
wxCampaign.updateTenantInfo(getTenantInfo());
wxCampaign.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<WxCampaign> page = wxCampaignService.listAsPage(wxCampaign, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "宣传页-新增")
public ResultData add(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::add");
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(EnumCampaignStatus.STATUS_THROW_IN.getCode());
wxCampaign.updateTenantInfo(getTenantInfo());
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
return wxCampaignService.saveOrUpdate(wxCampaign);
}

@ApiOperation(value = "新增接口-小程序路径", notes = "produceType,produceId,pagePath,pageScene必填")
@PostMapping("addByPath")
@SystemControllerLog(description = "宣传页-新增")
public ResultData addByPath(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::addByPath");
wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode());
wxCampaign.updateTenantInfo(getTenantInfo());
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
return wxCampaignService.addForPath(wxCampaign);
}

@ApiOperation(value = "新增接口-小程序路径", notes = "produceType,produceId,pagePath,pageScene必填")
@PostMapping("addByAPPPath")
@SystemControllerLog(description = "宣传页-新增")
public ResultData addByAPPPath(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::addByAPPPath");
wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode());
wxCampaign.updateTenantInfo(getTenantInfo());
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
return wxCampaignService.addByAPPPath(wxCampaign);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "宣传页-id更新")
public ResultData update(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::update");

if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) {
String[] arys = wxCampaign.getCouponIds().split(",");
wxCampaign.setCouponIds(JSON.toJSONString(arys));
} else {
wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0]));
}
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
return wxCampaignService.saveOrUpdate(wxCampaign);
}

@ApiOperation("根据id更新接口")
@PostMapping("updateStatus")
@SystemControllerLog(description = "宣传页-更新状态")
public ResultData updateStatus(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::updateStatus");
WxCampaign campaign = wxCampaignService.getById(wxCampaign.getId());
// check coupon 状态
if (campaign.getType().equals(EnumCampaignType.STABLE.getCode())) {
if (campaign.getStatus().equals(EnumCampaignStatus.STATUS_THROW_IN.getCode())
&& !wxCampaign.getStatus().equals(EnumCampaignStatus.STATUS_TAKE_OFFF.getCode())) {
// 宣传页 - 下架不检查状态
List<String> ids = JSONArray.parseArray(campaign.getCouponIds(), String.class);
for (String couponIdStr : ids) {
Long couponId = Long.parseLong(couponIdStr);

WxCoupon wxCoupon = wxCouponService.getById(couponId,campaign.getTenantId());
if (wxCoupon == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) {
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF);
}
if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(new Date())) {
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF);
}
}
}
}
wxCampaign.setPlat(campaign.getPlat());
return wxCampaignService.updateStatus(wxCampaign);
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "宣传页-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::delete");
wxCampaignService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "宣传页-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::findById");
WxCampaign wxCampaign = wxCampaignService.getById(id);
if (wxCampaign != null) {
WxCouponChannel wxCouponChannel = new WxCouponChannel();
wxCouponChannel.updateTenantInfo(wxCampaign);
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode());
wxCouponChannel.setSubTargetId(wxCampaign.getId());
wxCouponChannel.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode());
List<WxCouponChannelVo> voList = wxCouponChannelService.newfindListVo(wxCouponChannel);
wxCampaign.setCoupons(voList);
}
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)})
@SystemControllerLog(description = "宣传页-调整顺序")
public ResultData move(Long sourceId, Long targetId) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::move");
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);
}


}

+ 243
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCardPayController.java View File

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


import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCardSpendVo;
import com.iformall.domain.vo.WxCardVo;
import com.iformall.enums.EnumMerchantSubsidySource;
import com.iformall.enums.EnumMerchantSubsidyType;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxCardInfoService;
import com.iformall.service.WxCardSpendService;
import com.iformall.service.WxMerchantService;
import com.iformall.service.WxOrderService;
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.ArrayList;
import java.util.List;
import java.util.Map;

/**
* @author Stormeye Wu wuguoqiang@iformall.com
*/
@RestController
@RequestMapping("cardPay")
@Api(description = "储值卡支付-C端扫B端商户码")
public class WxCardPayController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxMerchantService wxMerchantService;

@Autowired
WxOrderService wxOrderService;

@Autowired
WxCardInfoService wxCardInfoService;

@Autowired
WxCardSpendService wxCardSpendService;

@ApiOperation("售卡记录列表分页接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "储值卡支付-售卡记录列表")
public ResultData cardOrderList(@ModelAttribute WxCardVo wxCardVo, Integer pageNum, Integer pageSize) {
String ipStr = getIpAddr();
logger.info("cardPay/cardOrderList: " + ipStr);
if (wxCardVo == null) {wxCardVo = new WxCardVo();}
else {
if(StringUtils.isBlank(wxCardVo.getOuPhone())) {
wxCardVo.setOuPhone(null);
}
}
wxCardVo.updateTenantInfo(getTenantInfo());
if(StringUtils.isNotBlank(wxCardVo.getStatusStr())) {
String [] statusAttr = wxCardVo.getStatusStr().split(",");
List<Integer> tmpList = new ArrayList<Integer>();
for(String status: statusAttr) {
tmpList.add(Integer.valueOf(status));
}
if(!tmpList.isEmpty()) {
wxCardVo.setStatusS(tmpList);
}
}
final PageInfo<WxCardVo> page = wxCardInfoService.listAsPage(wxCardVo, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("C端扫B端储值卡交易流水(消费记录 + 补贴)列表接口")
@GetMapping("cardSpendlist")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "储值卡支付-储值卡交易流水")
public ResultData cardSpendlist(@ModelAttribute WxCardSpendVo wxCardSpendVo, Integer pageNum, Integer pageSize) {
String ipStr = getIpAddr();
logger.info("cardPay/cardSpendlist: " + ipStr);
if (wxCardSpendVo == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
}
wxCardSpendVo.updateTenantInfo(getTenantInfo());
if(StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) {
String [] statusAttr = wxCardSpendVo.getPayStatusStr().split(",");
List<Integer> tmpList = new ArrayList<Integer>();
for(String status: statusAttr) {
tmpList.add(Integer.valueOf(status));
}
if(!tmpList.isEmpty()) {
wxCardSpendVo.setPayStatusS(tmpList);
}
}
List<Integer> sources = new ArrayList<Integer>();
sources.add(EnumMerchantSubsidySource.CARD.getCode());
wxCardSpendVo.setSources(sources);
wxCardSpendVo.setCardSpendListShow(1);
final PageInfo<WxCardSpendVo> page = wxCardSpendService.listAsPage(wxCardSpendVo, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("C端扫B端储值卡交易流水SUM")
@GetMapping("sum")
@SystemControllerLog(description = "储值卡支付-储值卡交易流水SUM")
public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) {
String ipStr = getIpAddr();
logger.info("cardPay/sumCardSpendList: " + ipStr + " :" + wxCardSpend.toString());
if (wxCardSpend == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
}
wxCardSpend.updateTenantInfo(getTenantInfo());
List<Integer> sources = new ArrayList<Integer>();
sources.add(EnumMerchantSubsidySource.CARD.getCode());
wxCardSpend.setSources(sources);
wxCardSpend.setCardSpendListShow(1);
final List<Map<String, Object>> mapList = wxCardSpendService.sumCardSpendForMerchant(wxCardSpend);
return new ResultData(mapList);
}

@ApiOperation("交易流水导出")
@GetMapping("/exportData")
@SystemControllerLog(description = "储值卡支付-储值卡交易流水导出")
public void exportData(@ModelAttribute WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response) {
logger.info("[" + getIpAddr() + "] cardPay/exportData");
if (wxCardSpendVo == null) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
}
wxCardSpendVo.updateTenantInfo(getTenantInfo());
if(StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) {
String [] statusAttr = wxCardSpendVo.getPayStatusStr().split(",");
List<Integer> tmpList = new ArrayList<Integer>();
for(String status: statusAttr) {
tmpList.add(Integer.valueOf(status));
}
if(!tmpList.isEmpty()) {
wxCardSpendVo.setPayStatusS(tmpList);
}
}
wxCardSpendService.exportData(wxCardSpendVo, request, response);
}

@ApiOperation("更新卡消费支付状态")
@PostMapping("/updatePayStatus")
@SystemControllerLog(description = "储值卡支付-更新卡消费支付状态")
public ResultData update(@RequestBody WxCardSpend wxCardSpend) {
String ipStr = getIpAddr();
logger.info("cardPay/updatePayStatus: " + ipStr + " :" + wxCardSpend.toString());
if (wxCardSpend == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
}
wxCardSpend.updateTenantInfo(getTenantInfo());
wxCardSpendService.update(wxCardSpend);
return new ResultData();
}

@ApiOperation("卡完结")
@PostMapping("/finishCard")
@SystemControllerLog(description = "储值卡支付-卡完结")
public ResultData finishCard(@RequestBody WxCardInfo wxCardInfo) {
String ipStr = getIpAddr();
logger.info("cardPay/finishCard: " + ipStr + " :" + wxCardInfo.toString());
if (wxCardInfo == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
}
if (wxCardInfo.getId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件ID为空");
}
wxCardInfo.updateTenantInfo(getTenantInfo());
int remainShareAmount = wxCardSpendService.finishCard(wxCardInfo);
return new ResultData(remainShareAmount);
}

@ApiOperation("卡订单-导出数据")
@GetMapping("/exportCardOrder")
@SystemControllerLog(description = "卡订单-导出数据")
public void exportCardOrder(@ModelAttribute WxCardVo wxCardVo, HttpServletRequest request, HttpServletResponse response) {
logger.info("[" + getIpAddr() + "] cardPay/exportCardOrder");
if (wxCardVo == null) {
wxCardVo = new WxCardVo();
} else {
if (StringUtils.isBlank(wxCardVo.getOuPhone())) {
wxCardVo.setOuPhone(null);
}
}
wxCardVo.updateTenantInfo(getTenantInfo());
if (StringUtils.isNotBlank(wxCardVo.getStatusStr())) {
String[] statusAttr = wxCardVo.getStatusStr().split(",");
List<Integer> tmpList = new ArrayList<Integer>();
for (String status : statusAttr) {
tmpList.add(Integer.valueOf(status));
}
if (!tmpList.isEmpty()) {
wxCardVo.setStatusS(tmpList);
}
}
wxCardInfoService.exportData(wxCardVo, request, response);
}

@ApiOperation("卡消费订单-导出数据")
@GetMapping("exportCardSpend")
@SystemControllerLog(description = "卡消费订单-导出数据")
public void exportCardSpend(@ModelAttribute WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response) {
String ipStr = getIpAddr();
logger.info("cardPay/exportCardSpend: " + ipStr);
if (wxCardSpendVo == null) {
wxCardSpendVo = new WxCardSpendVo();
}
wxCardSpendVo.updateTenantInfo(getTenantInfo());
if (StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) {
String[] statusAttr = wxCardSpendVo.getPayStatusStr().split(",");
List<Integer> tmpList = new ArrayList<Integer>();
for (String status : statusAttr) {
tmpList.add(Integer.valueOf(status));
}
if (!tmpList.isEmpty()) {
wxCardSpendVo.setPayStatusS(tmpList);
}
}
List<Integer> sources = new ArrayList<Integer>();
sources.add(EnumMerchantSubsidySource.CARD.getCode());
wxCardSpendVo.setSources(sources);
wxCardSpendVo.setCardSpendListShow(1);
wxCardSpendService.exportData(wxCardSpendVo, request, response);

}

}

+ 104
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCashOutController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.po.base.BaseEntity.SortField;
import com.iformall.enums.EnumCashOutStatus;
import com.iformall.enums.EnumPayWay;
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 java.util.ArrayList;
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.*;

/**
* 提现。微信需要小程序开通“企业付款到零钱”功能。
* @author alascor
*
*/
@RestController
@RequestMapping("/cashout")
@Api(description = "提现相关接口")
public class WxCashOutController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCashOutService wxCashOutService;
@Autowired
WxCUserService wxCUserService;
@Autowired
WxMerchantService wxMerchantService;
@Autowired
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 WxCashOut wxCashOut, Integer pageNum, Integer pageSize) {
if (null == wxCashOut) wxCashOut = new WxCashOut();
TenantEntity tenantInfo = getTenantInfo();
wxCashOut.updateTenantInfo(tenantInfo);
if (null != wxCashOut.getStatus() && wxCashOut.getStatus().intValue()>0) {
//提现中
List<Integer> statusList = new ArrayList<Integer>();
if (wxCashOut.getStatus().intValue()==99) {
statusList.add(EnumCashOutStatus.DOING.getCode());
statusList.add(EnumCashOutStatus.WAITING.getCode());
wxCashOut.setStatusList(statusList);
wxCashOut.setStatus(null);
//提现成功
}else if (wxCashOut.getStatus().intValue()==98) {
statusList.add(EnumCashOutStatus.SUCCESS.getCode());
wxCashOut.setStatusList(statusList);
wxCashOut.setStatus(null);
//提现失败
}else if (wxCashOut.getStatus().intValue()==97) {
statusList.add(EnumCashOutStatus.FAIL.getCode());
statusList.add(EnumCashOutStatus.BACK.getCode());
wxCashOut.setStatusList(statusList);
wxCashOut.setStatus(null);
//提现拒绝
}else if (wxCashOut.getStatus().intValue()==96) {
statusList.add(EnumCashOutStatus.REJECT.getCode());
wxCashOut.setStatusList(statusList);
wxCashOut.setStatus(null);
//审批中
}else if (wxCashOut.getStatus().intValue()==95) {
statusList.add(EnumCashOutStatus.AUDIOING.getCode());
wxCashOut.setStatusList(statusList);
wxCashOut.setStatus(null);
}
}else {
wxCashOut.setStatus(null);
}
wxCashOut.setSortColumns(SortField.CreateDate_DESC);
final PageInfo<WxCashOut> page = wxCashOutService.listAsPage(wxCashOut, pageNum, pageSize);
return new ResultData(page);
}
@ApiOperation("查询当前提现信息")
@GetMapping("getInfo")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", paramType = "query", required = true)})
public ResultData getCurrentCashOutData(Long id) {
TenantEntity tenantInfo = getTenantInfo();
WxCashOut out = wxCashOutService.getById(id, tenantInfo.getTenantId());
return new ResultData(out);
}
}

+ 81
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponActionLogController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCouponActionLog;
import com.iformall.service.WxCouponActionLogService;
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("wxCouponActionLog")
@Api(description = "发券行为记录接口")
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)})
@SystemControllerLog(description = "注券记录-图表")
public ResultData list(@ModelAttribute WxCouponActionLog wxCouponActionLog, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::list");
if (null == wxCouponActionLog) wxCouponActionLog = new WxCouponActionLog();
final PageInfo<WxCouponActionLog> page = wxCouponActionLogService.listAsPage(wxCouponActionLog, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "注券记录-新增")
public ResultData add(@RequestBody WxCouponActionLog wxCouponActionLog) {
logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::add");
//Assert.notNull(wxCouponActionLog.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCouponActionLogService.saveOrUpdate(wxCouponActionLog);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "注券记录-更新")
public ResultData update(@RequestBody WxCouponActionLog wxCouponActionLog) {
logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::update");
wxCouponActionLogService.saveOrUpdate(wxCouponActionLog);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "注券记录-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::delete");
wxCouponActionLogService.deleteById(id,getTenantInfo().getTenantId());
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "注券记录-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCouponActionLogService.getById(id,getTenantInfo().getTenantId()));
}


}

+ 71
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponCarController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCouponCar;
import com.iformall.service.WxCouponCarService;
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("wxCouponCar")
@Api(description = "停车券接口")
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)})
@SystemControllerLog(description = "停车券-列表")
public ResultData list(@ModelAttribute WxCouponCar wxCouponCar, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponCarController::list");
if (null == wxCouponCar) wxCouponCar = new WxCouponCar();
final PageInfo<WxCouponCar> page = wxCouponCarService.listAsPage(wxCouponCar, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "停车券-新增")
public ResultData add(@RequestBody WxCouponCar wxCouponCar) {
logger.debug("[" + getIpAddr() + "] WxCouponCarController::add");
//Assert.notNull(wxCouponCar.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCouponCarService.save(wxCouponCar);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "停车券-更新")
public ResultData update(@RequestBody WxCouponCar wxCouponCar) {
logger.debug("[" + getIpAddr() + "] WxCouponCarController::update");
wxCouponCarService.update(wxCouponCar);
return new ResultData();
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "停车券-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponCarController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCouponCarService.getById(id));
}


}

+ 275
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java View File

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

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.dto.WxCouponChannelDto;
import com.iformall.domain.po.*;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.EnumCouponSourceType;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumCouponStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import com.iformall.service.util.CouponCacheUtils;
import com.iformall.utils.RedisLock;

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.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
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;
@Autowired
RedisLock redisLock;
@Autowired
private WxCouponService wxCouponService;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-列表")
public ResultData list(@ModelAttribute WxCouponChannel wxCouponChannel, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::list");
if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel();
if (wxCouponChannel.getStatus() != null && wxCouponChannel.getStatus() == -1) {
wxCouponChannel.setStatus(null);
}
wxCouponChannel.updateTenantInfo(getTenantInfo());

if(null == wxCouponChannel.getSourceType()){
wxCouponChannel.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
}

if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){
//
}else{
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);
}
final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "券投放-更新")
public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::update");
wxCouponChannel.updateTenantInfo(getTenantInfo());
ResultData resultData = wxCouponChannelService.saveOrUpdate(wxCouponChannel);
WxCouponChannel couponChannel = (WxCouponChannel)resultData.data;
//生成二维码
if(couponChannel!=null){
wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType());
}
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), null, null);
return resultData;
}

@ApiOperation("预审核上架")
@PostMapping("updateOnline")
@SystemControllerLog(description = "预审核上架")
public ResultData updateOnline(@RequestBody WxCouponChannel wxCouponChannel) {
wxCouponChannel.updateTenantInfo(getTenantInfo());
if (wxCouponChannel.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
ResultData resultData = wxCouponChannelService.updateOnline(wxCouponChannel);
if(resultData.code == 200){
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), null, null);
}

return resultData;
}



@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCouponChannelService.getById(id,getTenantInfo().getTenantId()));
}

@TenantIgnore
@ApiOperation("批量新增")
@PostMapping("/addbatch")
@SystemControllerLog(description = "券投放-批量新增")
public ResultData addbatch(@RequestBody WxCouponChannelDto wxCouponChannelDto) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::addbatch");
String[] ids = wxCouponChannelDto.getCouponIds().split(",");
String[] channelId = wxCouponChannelDto.getChannelId().split(",");
ResultData resultData = wxCouponChannelService.addBatch(wxCouponChannelDto.getType(),ids, channelId, getTenantInfo(),
wxCouponChannelDto.getShowBeginTime(), wxCouponChannelDto.getBeginTime(), wxCouponChannelDto.getEndTime(),wxCouponChannelDto.getChannelPrice(),wxCouponChannelDto.getChannelStock());
if (null != channelId && channelId.length > 0 ) {
for (String chId: channelId) {
if (!StringUtils.isBlank(chId)) {
CouponCacheUtils.removeCouponChannelCache(redisTemplate, Long.parseLong(chId));
}
}
}
CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, this.getTenantInfo().getTenantId(), null, null);
return resultData;
}

@ApiOperation("根据id查询接口")
@GetMapping("/findChannelByCouponId")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-查询")
public ResultData findChannelByCouponId(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::findChannelByCouponId");
List<Integer> channellist = new ArrayList<>();
WxCouponChannel wxCouponChannel = new WxCouponChannel();
wxCouponChannel.updateTenantInfo(getTenantInfo());
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));
}
@ApiOperation("设置库存")
@PostMapping("/setChannelStock")
@SystemControllerLog(description = "设置渠道库存")
public ResultData setChannelStock(@RequestBody WxCouponChannel wxCouponChannel) {
if (null == wxCouponChannel.getChannelStock() || wxCouponChannel.getChannelStock() <= 0) {
return new ResultData(Result.ERROR, "库存未设置或者库存小于0, 如不需要可点击解除锁定库存.");
}
wxCouponChannel.updateTenantInfo(getTenantInfo());
WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId(), wxCouponChannel.getTenantId());
if (coupon.getRemainInventory().intValue() < wxCouponChannel.getChannelStock().intValue()) {
return new ResultData(Result.ERROR, "渠道库存不能大于券剩余总库存.");
}
try {
wxCouponChannelService.setChannelStock(wxCouponChannel, wxCouponChannel.getChannelStock());
redisLock.setCouponStock(wxCouponChannel.getCouponId(), coupon.getRemainInventory());
redisLock.setCouponChannelStock(wxCouponChannel.getId(), wxCouponChannel.getChannelStock());
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("setChannelStock error.",e);
return new ResultData(e.getErrorCode(),e.getMessage());
}catch(Exception e){
return new ResultData(Result.ERROR,e.getMessage());
}

}
@ApiOperation("解除锁定库存")
@PostMapping("/releaseChannelStock")
@SystemControllerLog(description = "释放渠道锁定库存")
public ResultData releaseChannelStock(@RequestBody WxCouponChannel wxCouponChannel) {
wxCouponChannel.updateTenantInfo(getTenantInfo());
try {
wxCouponChannelService.releaseChannelStock(wxCouponChannel);
redisLock.removeCouponStock(wxCouponChannel.getCouponId());
redisLock.removeCouponChannelStock(wxCouponChannel.getId());
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("releaseChannelStock error.",e);
return new ResultData(e.getErrorCode(),e.getMessage());
}catch(Exception e){
return new ResultData(Result.ERROR,e.getMessage());
}
}
@ApiOperation("设置价格")
@PostMapping("/setChannelPrice")
@SystemControllerLog(description = "设置渠道价格")
public ResultData setChannelPrice(@RequestBody WxCouponChannel wxCouponChannel) {
if (null == wxCouponChannel.getChannelPrice() || wxCouponChannel.getChannelPrice() < 0) {
return new ResultData(Result.ERROR, "价格未设置或者价格小于0, 如不需要可点击解除价格设置.");
}
wxCouponChannel.updateTenantInfo(getTenantInfo());
//免费券不能设置有价
WxCouponChannel cc = wxCouponChannelService.getById(wxCouponChannel.getId(), wxCouponChannel.getTenantId());
if (null == cc ) {
return new ResultData(Result.ERROR, "id无效.");
}
WxCoupon coupon = wxCouponService.getById(cc.getCouponId(), wxCouponChannel.getTenantId());
if (null == coupon ) {
return new ResultData(Result.ERROR, "优惠券不存在.");
}
if (coupon.getSalePrice() <= 0) {
return new ResultData(Result.ERROR, "免费券不能设置渠道价格.");
}
try {
wxCouponChannelService.setChannelPrice(wxCouponChannel);
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("setChannelPrice error.",e);
return new ResultData(e.getErrorCode(),e.getMessage());
}catch(Exception e){
return new ResultData(Result.ERROR,e.getMessage());
}
}
@ApiOperation("解除价格设置")
@PostMapping("/releaseSetChannelPrice")
@SystemControllerLog(description = "设置渠道价格")
public ResultData releaseSetChannelPrice(@RequestBody WxCouponChannel wxCouponChannel) {
wxCouponChannel.setChannelPrice(null);
wxCouponChannel.updateTenantInfo(getTenantInfo());
try {
wxCouponChannelService.setChannelPrice(wxCouponChannel);
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("releaseSetChannelPrice error.",e);
return new ResultData(e.getErrorCode(),e.getMessage());
}catch(Exception e){
return new ResultData(Result.ERROR,e.getMessage());
}

}


}

+ 739
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.TtCouponVo;
import com.iformall.domain.vo.WxCouponStatisVo;
import com.iformall.douyin.web.bean.GoodsTemplateGet;
import com.iformall.enums.*;
import com.iformall.mapper.WxCouponChannelMapper;
import com.iformall.service.*;
import com.iformall.service.util.CouponCacheUtils;
import com.iformall.utils.DateUtils;
import com.iformall.utils.RedisLock;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

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

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

@Autowired
private WxCouponService wxCouponService;
@Autowired
private WxCouponPasswordService couponPasswordService;
@Autowired
private WxCouponChannelService wxCouponChannelService;
@Autowired
private WxFlowService wxFlowService;
@Autowired
private WxMallService wxMallService;
@Autowired
private WxCouponMallService wxCouponMallService;
@Autowired
RedisLock redisLock;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;

@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,Boolean isList) {
logger.debug("[" + getIpAddr() + "] WxCouponController::list");
if (wxCoupon == null) wxCoupon = new WxCoupon();
wxCoupon.updateTenantInfo(getTenantInfo());
return couponList(wxCoupon, pageNum, pageSize, isList);
}
@TenantIgnore
@ApiOperation("父券分页列表接口")
@GetMapping("parentCouponList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData parentCouponList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize,Boolean isList) {
logger.debug("[" + getIpAddr() + "] WxCouponController::list");
if (wxCoupon == null) wxCoupon = new WxCoupon();
TenantEntity mallTenantEntity = getTenantInfo();
wxCoupon.setTenantId(mallTenantEntity.getParentTenantId());
wxCoupon.setParentTenantId(null);
//平台券
if (EnumCouponType.COUPON_DOUYIN_PLAT.getCode() == wxCoupon.getType()) {
//查询已经分配了的parentCouponList
WxCouponMall couponMall = new WxCouponMall();
couponMall.updateTenantInfo(wxCoupon);
couponMall.setMallTenantId(mallTenantEntity.getTenantId());
List<Long> couponIds = wxCouponMallService.listCouponIds(couponMall);
if (null != couponIds && couponIds.size() > 0 ) {
wxCoupon.setIds(couponIds);
}else {
wxCoupon.setId(-1L);
}
}
return couponList(wxCoupon, pageNum, pageSize, isList);
}
private ResultData couponList(WxCoupon wxCoupon, Integer pageNum, Integer pageSize,Boolean isList) {
//默认A端建券
if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
}
//排序处理
if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){
String coryColumn = "c."+wxCoupon.getSortColumns();
wxCoupon.setSortColumns(coryColumn);
wxCoupon.setSortColumn(null);
}

//isList true 查全部 / 否则 只查询主动领取和定向投放的。
if(wxCoupon.getSendType() == null && !(isList == null?false:isList)){
Integer[] sendTypeArray = {
EnumCouponSendType.ACTIVE.getCode(),
EnumCouponSendType.PASSIVE.getCode(),};
wxCoupon.setSendTypes(Arrays.asList(sendTypeArray));
}

return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表
}

@ApiOperation("分页列表接口")
@GetMapping("listWithTypePress")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-列表")
public ResultData listWithTypePress(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponController::list");
if (wxCoupon == null) wxCoupon = new WxCoupon();
wxCoupon.updateTenantInfo(getTenantInfo());
Integer[] typeArray = {
EnumCouponType.COUPON_MANJIAN.getCode(),
EnumCouponType.COUPON_DAIJIN.getCode(),
// EnumCouponType.COUPON_TUANGOU.getCode(),
EnumCouponType.COUPON_LIPIN.getCode(),
EnumCouponType.COUPON_TINGCHE.getCode(),
EnumCouponType.COUPON_MULTIMCH.getCode(),
EnumCouponType.COUPON_DOUYIN.getCode(),
EnumCouponType.COUPON_PRESS.getCode(),
EnumCouponType.COUPON_PREORDER.getCode()};

wxCoupon.setTypes(Arrays.asList(typeArray));

Integer[] sendTypeArray = {
EnumCouponSendType.ACTIVE.getCode(),
EnumCouponSendType.PASSIVE.getCode(),};

wxCoupon.setSendTypes(Arrays.asList(sendTypeArray));

if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){
String coryColumn = "c."+wxCoupon.getSortColumns();
wxCoupon.setSortColumns(coryColumn);
wxCoupon.setSortColumn(null);
}
return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表
}
@TenantIgnore
@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "券投放-新增")
public ResultData add(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::add");
TenantEntity tenantEntity = getTenantInfo();
wxCoupon.updateTenantInfo(tenantEntity);

if(null == wxCoupon.getContentType()){
wxCoupon.setContentType(EnumCouponContentType.NORMAL.getCode());
}
if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
}
ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon);
if (resultData.code != 200) {
return resultData;
}
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
//启动投放审批
if(wxCoupon.getFlowParams() !=null && wxCoupon.getFlowParams().size()>0) {
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId());
wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), tenantEntity);
//修改coupon applyStatus状态为审核中
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
}
return resultData;
}

@TenantIgnore
@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "券投放-更新")
public ResultData update(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::update");
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
wxCoupon.updateTenantInfo(getTenantInfo());
WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId());
if (null == coupon) {
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId());
}

if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){
if(!EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(coupon.getStatus())){
return new ResultData(ResultData.ERROR, "请先作废,再进行删除。");
}
wxCouponService.deleteById(wxCoupon.getId(),wxCoupon.getTenantId());
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId());
return new ResultData();
}

//启动审批流
if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) {
logger.info("------coupon.update().businessType:"+wxCoupon.getFlowParams().get("businessType"));
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId());
wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantInfo());
//作废审批
if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())) {
wxCoupon.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
return new ResultData(wxCoupon);
} else {
//投放审批
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
}
}

ResultData result = null;
if(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())){
result = wxCouponService.disable(wxCoupon, wxCoupon.getId());
}else{
result = wxCouponService.saveOrUpdate(wxCoupon);
if(wxCoupon.getRemainInventory() != null){
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
}
}

CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId());
return result;
}

@ApiOperation("根据id更新接口")
@PostMapping("continueAdd")
@SystemControllerLog(description = "继续添加")
public ResultData continueAdd(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::update");
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
if(wxCoupon.getProductType() == null || wxCoupon.getCategoryId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "缺少必要参数");
}

wxCoupon.updateTenantInfo(getTenantInfo());
WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId());
if (null == coupon) {
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId());
}

coupon.setProductType(wxCoupon.getProductType());
coupon.setCategoryId(wxCoupon.getCategoryId());
coupon.setProductAttrs(wxCoupon.getProductAttrs());
coupon.setSkuAttrs(wxCoupon.getSkuAttrs());

ResultData result = wxCouponService.updateTtProduct(coupon);
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId());
return result;
}

@ApiOperation("根据id更新库存及有效期接口")
@PostMapping("updateStokeAndValidDate")
@SystemControllerLog(description = "券投放-库存/有效期更新")
public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate");
if (wxCoupon.getId() == null) {
logger.error("缺少id");
return new ResultData(ResultData.ERROR, "缺少id");
}
if (wxCoupon.getType() == null) {
logger.error("缺少type");
return new ResultData(ResultData.ERROR, "缺少type");
}
if (wxCoupon.getRemainInventory() == null || wxCoupon.getInventory() == null) {
logger.error("库存错误1");
return new ResultData(ErrorCode.COUPON_STOCK_ERR);
}
if (wxCoupon.getRemainInventory() > wxCoupon.getInventory()) {
logger.error("库存错误2");
return new ResultData(ErrorCode.COUPON_STOCK_ERR);
}
if (wxCoupon.getValidType() == null) {
logger.error("库存错误3");
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR);
}
if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) {
if (wxCoupon.getValidEndDate() == null) {
logger.error("有效期错误1");
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR);
}
} else {
if (wxCoupon.getValidDays() == null) {
logger.error("有效期错误2");
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR);
}
}
if (wxCoupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode()) ||
wxCoupon.getType().equals(EnumCouponType.COUPON_CREDIT_PARK.getCode())) {
logger.error("券库存有效期不支持停车券");
return new ResultData(ErrorCode.COUPON_STOCK_DATE_NO_CAR);
}
wxCoupon.updateTenantInfo(getTenantInfo());

WxCoupon coupon = wxCouponService.findById(wxCoupon);
if (coupon == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
if(EnumCouponSendType.GIFT.getCode().equals(coupon.getSendType())){
return new ResultData(ErrorCode.COUPON_GIFT_NOTUPD_INVENTORY);
}
if ((wxCoupon.getValidEndDate() != null && coupon.getValidEndDate() != null && DateUtils.format(wxCoupon.getValidEndDate()).equals(DateUtils.format(coupon.getValidEndDate()))
&& wxCoupon.getInventory().equals(coupon.getInventory()))
||
(wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getInventory().equals(coupon.getInventory()) &&
wxCoupon.getValidDays().equals(coupon.getValidDays()))
) {
return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR);
}

if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(coupon.getValidEndDate())) {
return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR);
}
if (wxCoupon.getInventory() != null && wxCoupon.getInventory().intValue() < coupon.getInventory().intValue()) {
return new ResultData(ErrorCode.COUPON_STOCK_INV_ERR);
}

if (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getValidDays().intValue() < coupon.getValidDays().intValue()) {
return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR);
}
wxCoupon.setSalePrice(coupon.getSalePrice());
if(!wxCouponService.validCouponDate(wxCoupon)) {
return new ResultData(ResultData.ERROR,"券有效结束日期必须在30天以内。");
}
wxCoupon.setSalePrice(null);


//启动审批流
if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) {
List<Map<String, Object>> variables = (List) wxCoupon.getFlowParams().get("variables");
Map<String, Object> map = new HashedMap();
map.put("key", "inventory");
map.put("value", wxCoupon.getInventory());
variables.add(map);
map = new HashedMap();
map.put("key", "remainInventory");
map.put("value", wxCoupon.getRemainInventory());
variables.add(map);
map = new HashedMap();
map.put("key", "type");
map.put("value", wxCoupon.getType());
variables.add(map);
map = new HashedMap();
map.put("key", "validEndDate");
map.put("value", wxCoupon.getValidEndDate());
map = new HashedMap();
map.put("key", "validStartDate");
map.put("value", wxCoupon.getValidStartDate());
map = new HashedMap();
map.put("key", "validType");
map.put("value", wxCoupon.getValidType());
variables.add(map);
map = new HashedMap();
map.put("key", "validDays");
map.put("value", wxCoupon.getValidDays());
variables.add(map);
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId());
wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), wxCoupon);
//更新状态
WxCoupon updateCoupon = new WxCoupon();
updateCoupon.updateTenantInfo(wxCoupon);
updateCoupon.setId(wxCoupon.getId());
updateCoupon.setStockApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
updateCoupon.setUpdateDate(new Date());
wxCouponService.update(updateCoupon);
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
} else {
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
return wxCouponService.updateCouponStockAndEndTime(wxCoupon);
}
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::delete");
wxCouponService.deleteById(id,getTenantInfo().getTenantId());
CouponCacheUtils.removeCouponCache(redisTemplate, id);
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@TenantIgnore
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-查询")
public ResultData findById(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::findById");
TenantEntity tenantEntity = getTenantInfo();
return new ResultData(wxCouponService.getVoById(id,tenantEntity.getTenantId(),tenantEntity));
}
@TenantIgnore
@ApiOperation("根据id查询接口")
@GetMapping("/findParentCouponById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-查询")
public ResultData findParentCouponById(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::findById");
TenantEntity tenantEntity = getTenantInfo();
return new ResultData(wxCouponService.getVoById(id,getTenantInfo().getParentTenantId(),tenantEntity));
}

@TenantIgnore
@ApiOperation("卡营销列表接口")
@GetMapping("findCardCountList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-卡营销列表")
public ResultData findCardCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
//默认时间本月第一天,截止到当天
Map<String, Object> result = new HashedMap();
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
if (wxCoupon.getStartdate() == null) {
wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth());
}
if (wxCoupon.getEnddate() == null) {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
}
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCountData(wxCoupon,tenantEntitys, pageNum, pageSize);
for (WxCouponStatisVo coupon : pageInfo.getList()) {
if (coupon.getSaleAmount() == null) {
coupon.setSaleAmount(0);
}
if (coupon.getSumPayment() == null) {
coupon.setSumPayment(0);
}
if (coupon.getSumSubsidy() == null) {
coupon.setSumSubsidy(0);
}
}
result.put("list", pageInfo);
return new ResultData(result);
}
@ApiOperation("卡营销列表记录导出")
@GetMapping("/cardCountExportData")
@SystemControllerLog(description = "营销统计-卡营销数据导出")
public void cardCountExportData(@ModelAttribute WxCoupon wxCoupon, HttpServletRequest request, HttpServletResponse response) {
//默认时间本月第一天,截止到当天
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
if (wxCoupon.getStartdate() == null) {
wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth());
}
if (wxCoupon.getEnddate() == null) {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
}
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
wxCouponService.exportCardData(wxCoupon,tenantEntitys, request, response);
}

@TenantIgnore
@ApiOperation("券营销列表接口")
@GetMapping("findCouponCountList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-券营销列表")
public ResultData findCouponCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
//默认时间本月第一天,截止到当天
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
Map<String, Object> result = new HashedMap();
if (wxCoupon.getStartdate() == null) {
wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth());
}
if (wxCoupon.getEnddate() == null) {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
}

wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());

PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCouponData(wxCoupon, tenantEntitys, pageNum, pageSize);
for (WxCouponStatisVo coupon : pageInfo.getList()) {
if (coupon.getSumSubsidy() == null) {
coupon.setSumSubsidy(0);
}
if (coupon.getSumSubsidy() == null) {
coupon.setSumSubsidy(0);
}
}
return new ResultData(pageInfo);
}
@ApiOperation("券营销列表记录导出")
@GetMapping("/couponCountExportData")
@SystemControllerLog(description = "营销统计-券营销数据导出")
public void couponCountExportData(@ModelAttribute WxCoupon wxCoupon, HttpServletRequest request, HttpServletResponse response) {
//默认时间本月第一天,截止到当天
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
if (wxCoupon.getStartdate() == null) {
wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth());
}
if (wxCoupon.getEnddate() == null) {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
}

wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
wxCouponService.exportCouponData(wxCoupon,tenantEntitys, request, response);
}

@TenantIgnore
@ApiOperation("砍价营销列表接口")
@GetMapping("findPressCountList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-砍价营销列表")
public ResultData findPressCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
wxCoupon.updateTenantInfo(tenantEntity);
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
PageInfo<WxCouponStatisVo> pages = wxCouponService.findPressData(wxCoupon,tenantEntitys,pageNum,pageSize);
return new ResultData(pages);
}
@ApiOperation("砍价营销列表记录导出")
@GetMapping("/pressCountExportData")
@SystemControllerLog(description = "营销统计-券营销数据导出")
public void pressCountExportData(@ModelAttribute WxCoupon wxCoupon, HttpServletRequest request, HttpServletResponse response) {
//默认时间本月第一天,截止到当天
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
wxCoupon.updateTenantInfo(tenantEntity);
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
wxCouponService.exportPressData(wxCoupon,tenantEntitys, request, response);
}

@GetMapping("exportCouponPassword")
@SystemControllerLog(description = "卡券兑换码-导出数据")
public void exportCouponPassword(@ModelAttribute WxCouponPassword wxCouponPassword, HttpServletRequest request, HttpServletResponse response) {
wxCouponPassword.updateTenantInfo(getTenantInfo());
if (wxCouponPassword.getCouponId() == null) {
wxCouponPassword.setCouponId(0L);
}
couponPasswordService.exportData(request, response, wxCouponPassword);
if (null != wxCouponPassword.getCouponId()) {
CouponCacheUtils.removeCouponCache(redisTemplate, wxCouponPassword.getCouponId());
}
}

@ApiOperation("根据id获取富文本接口")
@GetMapping("/getHtml")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-富文本获取")
public ResultData getHtml(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById");
return new ResultData(wxCouponService.getHtmlById(id,getTenantInfo().getTenantId()));
}
@ApiOperation("卡延期")
@PostMapping("/cardDefer")
@SystemControllerLog(description = "卡延期")
public ResultData cardDefer(@RequestBody WxCoupon wxCoupon) {
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
if (wxCoupon.getValidEndDate() == null) {
return new ResultData(ResultData.ERROR, "缺少validEndDate");
}
ResultData result = wxCouponService.cardDefer(wxCoupon.getId(),getTenantInfo().getTenantId(),wxCoupon.getValidEndDate());
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
return result;
}
@ApiOperation("集团查询:查询平台券商场列表")
@GetMapping("/getPlatMallList")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData getPlatMallList(@RequestParam Long id) {
WxCouponMall wxCouponMall = new WxCouponMall();
wxCouponMall.updateTenantInfo(getTenantInfo());
wxCouponMall.setProductId(id);
return new ResultData(wxCouponMallService.list(wxCouponMall,true));
}
@TenantIgnore
@ApiOperation("平台券商场列表")
@GetMapping("/getCouponMall")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)})
public ResultData getCouponMall(Long id) {
//如果是集团查询,则查询所有的,如果是商场查询,则只查询商场的
WxCouponMall wxCouponMall = new WxCouponMall();
TenantEntity tenantEntity = getTenantInfo();
if (null == tenantEntity.getParentTenantId()) {
wxCouponMall.updateTenantInfo(tenantEntity);
wxCouponMall.setProductId(id);
}else {
wxCouponMall.setTenantId(tenantEntity.getParentTenantId());
//一个商场,每个平台券只有一条记录
wxCouponMall.setMallTenantId(tenantEntity.getTenantId());
wxCouponMall.setProductId(id);
}
List<WxCouponMall> mallList= wxCouponMallService.list(wxCouponMall,false);
if (null != mallList && mallList.size() > 0 ) {
boolean isComplete = true;
for (int i = 0 ; i < mallList.size(); i ++) {
WxCouponMall cm = mallList.get(i);
if (EnumCouponMallStatus.UNFINISED.getCode() == cm.getStatus()) {
isComplete = false;
break;
}
}
if (isComplete) {
return new ResultData("{\"isCompleted\":1}");
}else {
return new ResultData("{\"isCompleted\":0}");
}
}else {
return new ResultData("{\"isCompleted\":0}");
}
}
@TenantIgnore
@ApiOperation("商场设置平台券商户")
@PostMapping("/setParentCouponMerchants")
public ResultData setMallMerchants(@RequestBody WxCoupon wxCoupon) {
try {
wxCouponService.setParentCouponMallMerchants(getTenantInfo(),wxCoupon);
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
return new ResultData();
}
@ApiOperation("自己券商户是否自动分账")
@PostMapping("/couponMerchantAutoShare")
public ResultData couponMerchantAutoShare(@RequestBody WxCoupon wxCoupon) {
wxCoupon.updateTenantInfo(getTenantInfo());
try {
Map<Long, Boolean> map = wxCouponService.couponMerchantAutoShare(wxCoupon,wxCoupon);
return new ResultData(map);
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
}
@TenantIgnore
@ApiOperation("父券商户是否自动分账")
@PostMapping("/parentCouponMerchantAutoShare")
public ResultData parentCouponMerchantAutoShare(@RequestBody WxCoupon wxCoupon) {
TenantEntity tenantEntity = getTenantInfo();
wxCoupon.setTenantId(tenantEntity.getParentTenantId());
wxCoupon.setParentTenantId(null);
try {
Map<Long, Boolean> map = wxCouponService.couponMerchantAutoShare(tenantEntity,wxCoupon);
return new ResultData(map);
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
}
@TenantIgnore
@ApiOperation("商场设置平台券已完成")
@PostMapping("/setPlatCouponFinished")
public ResultData setPlatCouponFinished(@RequestBody WxCoupon wxCoupon) {
try {
TenantEntity tenantEntity = getTenantInfo();
String mallTenantId = tenantEntity.getTenantId();
String tenantId = tenantEntity.getTenantId();
if (null != tenantEntity.getParentTenantId()) {
tenantId = tenantEntity.getParentTenantId();
}
wxCouponMallService.finised(tenantId, wxCoupon.getId(), mallTenantId);
return new ResultData();
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
}
@TenantIgnore
@ApiOperation("商场设置平台券未完成")
@PostMapping("/setPlatCouponUnFinished")
public ResultData setPlatCouponUnFinished(@RequestBody WxCoupon wxCoupon) {
try {
if (null == wxCoupon.getType()) {
return new ResultData(Result.ERROR,"缺少参数");
}
TenantEntity tenantEntity = getTenantInfo();
String mallTenantId = tenantEntity.getTenantId();
String tenantId = tenantEntity.getTenantId();
if (null != tenantEntity.getParentTenantId()) {
tenantId = tenantEntity.getParentTenantId();
}
wxCouponMallService.unfinised(tenantId, wxCoupon.getId(),wxCoupon.getType(), mallTenantId);
return new ResultData();
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
}

}

+ 103
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponInjectController.java View File

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

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxCouponInject;
import com.iformall.service.WxCouponInjectService;
import com.iformall.service.WxCUserTagsService;
import com.iformall.service.WxMsgModelService;
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("couponInject")
@Api(description = "精准投放接口")
public class WxCouponInjectController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponInjectService wxCouponInjectService;
@Autowired
private WxCUserTagsService wxCUserTagsService;
@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)})
@SystemControllerLog(description = "精准投放-列表")
public ResultData list(@ModelAttribute WxCouponInject couponInject, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponInjectController::list");
if (null == couponInject) couponInject = new WxCouponInject();
if (couponInject.getStatus() != null && couponInject.getStatus() == -1) {
couponInject.setStatus(null);
}
couponInject.updateTenantInfo(getTenantInfo());
couponInject.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<WxCouponInject> page = wxCouponInjectService.listAsPage(couponInject, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "精准投放-新增")
public ResultData add(@RequestBody WxCouponInject couponInject) {
logger.debug("[" + getIpAddr() + "] WxCouponInjectController::add");

MallUserInfo user = getUser();
couponInject.updateTenantInfo(user);
couponInject.setMUserId(user.getId());

return wxCouponInjectService.add(couponInject);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "精准投放-更新")
public ResultData update(@RequestBody WxCouponInject couponInject) {
logger.debug("[" + getIpAddr() + "] WxCouponInjectController::update");

couponInject.setTags(JSON.toJSONString(couponInject.getFilterList()));
wxCouponInjectService.saveOrUpdate(couponInject);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "精准投放-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponInjectController::delete");
wxCouponInjectService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "精准投放-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponInjectController::findById");
WxCouponInject couponInject = wxCouponInjectService.getById(id);
if (couponInject != null) {
couponInject.setMsgModel(wxMsgModelService.getById(couponInject.getModelId()));
}
return new ResultData(Result.SUCCESS, "查询成功", couponInject);
}


}

+ 164
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponOrderController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxCouponOrder;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCouponOrderBVo;
import com.iformall.enums.EnumAppType;
import com.iformall.enums.EnumPayType;
import com.iformall.enums.EnumPayWay;
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;

@TenantIgnore
@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 WxCouponOrderBVo wxCouponOrder, Integer pageNum, Integer pageSize) {
if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderBVo();
wxCouponOrder.updateTenantInfo(getTenantInfo());
if (wxCouponOrder.getMerchantName() != null &&
wxCouponOrder.getMerchantName().isEmpty()) {
wxCouponOrder.setMerchantName(null);
}
return wxCouponOrderService.listAdminAsPage(wxCouponOrder, pageNum, pageSize);
}
@TenantIgnore
@ApiOperation("子商场查询集团券核销分页列表接口")
@GetMapping("groupList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData groupList(@ModelAttribute WxCouponOrderBVo wxCouponOrder, Integer pageNum, Integer pageSize) {
if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderBVo();
TenantEntity mallTenantEntity = getTenantInfo();
wxCouponOrder.setTenantId(mallTenantEntity.getParentTenantId());
if (wxCouponOrder.getMerchantName() != null &&
wxCouponOrder.getMerchantName().isEmpty()) {
wxCouponOrder.setMerchantName(null);
}
wxCouponOrder.setBTenantId(mallTenantEntity.getTenantId());
return wxCouponOrderService.listAdminAsPage(wxCouponOrder, pageNum, pageSize);
}

@TenantIgnore
@ApiOperation(value = "卡券详情接口")
@GetMapping("detail")
@ApiImplicitParams({
@ApiImplicitParam(name = "couponOrderId", value = "券ID", dataType = "Long", paramType = "query", required = true)
})
public ResultData detail(@RequestParam("couponOrderId") Long couponOrderId) {
if(couponOrderId == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return wxCouponOrderService.detailAdminVo(couponOrderId,getTenantInfo());
}
@ApiOperation(value = "退券退款", notes = "{\"couponOrderId\":\"string\"}")
@PostMapping("/refund")
@SystemControllerLog(description = "券包-退券退款")
public ResultData create(@RequestBody Map<String, String> paramMap) {
logger.debug("[" + getIpAddr() + "] WxCouponOrderController::create");
//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);
}

WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId,getTenantInfo().getTenantId());
if (wxCouponOrder == null) {
logger.error("券ID不存在:" + couponOrderId);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}

try {
wxRefundOrderService.createRefundOrder(getTenantInfo(), wxCouponOrder.getOrderId(), EnumPayType.PAY_ADMIN_REFUND, null,getUserId());
return new ResultData();
} catch (MallinkException e) {
logger.error(e.getMessage(),e);
return new ResultData(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.REFUND_ORDER_ERROR);
}
}

@GetMapping("exportData")
@SystemControllerLog(description = "券订单数据-导出数据")
public void exportData(@ModelAttribute WxCouponOrderBVo wxCouponOrder, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxCouponOrderController::exportData");
if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderBVo();
wxCouponOrder.updateTenantInfo(getTenantInfo());
if (wxCouponOrder.getMerchantName() != null &&
wxCouponOrder.getMerchantName().isEmpty()) {
wxCouponOrder.setMerchantName(null);
}
wxCouponOrderService.exportData(false,wxCouponOrder, request, response);
}
@TenantIgnore
@GetMapping("exportGroupData")
@SystemControllerLog(description = "券订单数据-导出数据")
public void exportGroupData(@ModelAttribute WxCouponOrderBVo wxCouponOrder, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxCouponOrderController::exportData");
if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderBVo();
TenantEntity mallTenantEntity = getTenantInfo();
wxCouponOrder.setTenantId(mallTenantEntity.getParentTenantId());
if (wxCouponOrder.getMerchantName() != null &&
wxCouponOrder.getMerchantName().isEmpty()) {
wxCouponOrder.setMerchantName(null);
}
wxCouponOrder.setBTenantId(mallTenantEntity.getTenantId());
wxCouponOrderService.exportData(false,wxCouponOrder, request, response);
}

}

+ 83
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponPasswordController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxCouponPassword;
import com.iformall.domain.vo.WxCouponPasswordCountInfoVO;
import com.iformall.service.WxCouponPasswordService;
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.*;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("couponPassword")
@Api(description = "免费卡接口")
public class WxCouponPasswordController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponPasswordService wxCouponPasswordService;

@ApiOperation("分页列表接口")
@GetMapping("/list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "列表")
public ResultData list(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::list");
wxCouponPassword.updateTenantInfo(getTenantInfo());
wxCouponPassword.setSortColumns(BaseEntity.SortField.CreateDate_DESC, BaseEntity.SortField.Id_DESC);
final PageInfo<WxCouponPassword> page = wxCouponPasswordService.listAsPage(wxCouponPassword, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("可发送卡数据")
@GetMapping("/findCouponList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "可发送卡数据")
public ResultData findCouponList(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::findCouponList");
wxCouponPassword.updateTenantInfo(getTenantInfo());
final PageInfo<WxCouponPasswordCountInfoVO> page = wxCouponPasswordService.findCouponList(wxCouponPassword, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation(value = "卡密延期", notes = "{\"couponId\":\"string\", \"expireDate\":\"string\"}")
@PostMapping("/postpone")
@SystemControllerLog(description = "卡密延期")
public ResultData postpone(@RequestBody WxCouponPassword wxCouponPassword) {
logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::postpone");
if (wxCouponPassword.getCouponId() == null) {
logger.error("couponId不能为空: ");
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxCouponPassword couponPassword = new WxCouponPassword();
couponPassword.updateTenantInfo(getTenantInfo());
couponPassword.setCouponId(wxCouponPassword.getCouponId());
couponPassword.setExpireDate(wxCouponPassword.getExpireDate());
try {
wxCouponPasswordService.postpone(couponPassword);
} catch (Exception e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.COUPON_PASSWORD_POSTPONE_ERR);
}
return new ResultData();
}


}

+ 145
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponPresentController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumCouponPasswordStatus;
import com.iformall.enums.EnumCouponStatus;
import com.iformall.enums.EnumCouponValidType;
import com.iformall.enums.EnumPayWay;
import com.iformall.exception.MallinkException;
import com.iformall.service.PushLimitService;
import com.iformall.service.WxCouponPasswordService;
import com.iformall.service.WxCouponPresentService;
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.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.HashSet;
import java.util.List;
import java.util.Set;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("couponPresent")
@Api(description = "卡投放接口")
public class WxCouponPresentController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponPresentService wxCouponPresentService;

@Autowired
PushLimitService pushLimitService;

@Autowired
WxCouponService wxCouponService;

@Autowired
WxCouponPasswordService wxCouponPasswordService;

@ApiOperation("分页列表接口")
@GetMapping("/list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "列表")
public ResultData list(@ModelAttribute WxCouponPresent wxCouponPresent, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponPresentController::list");
wxCouponPresent.updateTenantInfo(getTenantInfo());
wxCouponPresent.setSortColumns(BaseEntity.SortField.CreateTime_DESC, BaseEntity.SortField.Id_DESC);
final PageInfo<WxCouponPresent> page = wxCouponPresentService.listAsPage(wxCouponPresent, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "查询")
public ResultData findById(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponPresentController::findById");
return new ResultData(wxCouponPresentService.findById(id));
}


@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "新增")
public ResultData add(@RequestBody WxCouponPresent wxCouponPresent) {
logger.debug("[" + getIpAddr() + "] WxCouponInjectController::add");

if (wxCouponPresent.getCouponId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请选择卡");
}

if (wxCouponPresent.getPhones().isEmpty()) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写手机号");
}
MallUserInfo user = getUser();
wxCouponPresent.setUserId(user.getId());
wxCouponPresent.updateTenantInfo(user);
try {
pushLimitService.checkSendTime(user);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
WxCoupon wxCoupon = wxCouponService.getById(wxCouponPresent.getCouponId(),wxCouponPresent.getTenantId());
if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { //时间范围
if (new Date().after(wxCoupon.getValidEndDate())) {
return new ResultData(ErrorCode.COUPON_IS_EXPIRED);
}
}
if (!wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode())) {
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF);
}

//获取手机号
String phones = wxCouponPresent.getPhones();
String[] phoneSplit = phones.split(",");
Set<String> phoneSet = new HashSet<>(phoneSplit.length);
for (String phone : phoneSplit) {
if (!phone.isEmpty()) {
phoneSet.add(phone);
}
}
//查询有效券数量
WxCouponPassword wxCouponPassword = new WxCouponPassword();
wxCouponPassword.updateTenantInfo(user);
wxCouponPassword.setCouponId(wxCouponPresent.getCouponId());
wxCouponPassword.setStatus(EnumCouponPasswordStatus.INIT.getCode());
List<WxCouponPassword> list = wxCouponPasswordService.findList(wxCouponPassword);
if (phoneSet.size() > list.size()) {
logger.info(ErrorCode.REMAIN_IS_EMPTY.getMessage());
return new ResultData(ErrorCode.REMAIN_IS_EMPTY);
}

wxCouponPresent.setCouponName(wxCoupon.getTitle());
//只需要给一端发就可以了。默认给微信小程序发
wxCouponPresentService.add(wxCouponPresent, list, phoneSet,EnumPayWay.PAY_WAY_WECHAT);
return new ResultData();
}
@ApiOperation("新增接口")
@PostMapping("ttttttt")
@SystemControllerLog(description = "新增")
public ResultData tttttt(@RequestBody WxCouponPresent wxCouponPresent) {
//只需要给一端发就可以了。默认给微信小程序发
wxCouponPresentService.tttttttttttttt();
return new ResultData();
}

}

+ 74
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponSendConfigController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCouponSendConfig;
import com.iformall.enums.EnumCouponSendSendType;
import com.iformall.enums.EnumValidStatus;
import com.iformall.service.WxCouponSendConfigService;
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.*;

import java.util.Date;

@RestController
@RequestMapping("wxCouponSendConfig")
@Api(description = "注劵配置接口")
public class WxCouponSendConfigController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponSendConfigService wxCouponSendConfigService;

@ApiOperation("获取开关")
@GetMapping("get")
@SystemControllerLog(description = "发券开关-获取")
public ResultData getCouponSendConfig(@ModelAttribute WxCouponSendConfig wxCouponSendConfig) {
logger.debug("[" + getIpAddr() + "] WxMallConfigController::getCouponSendConfig");
if (wxCouponSendConfig == null || wxCouponSendConfig.getSendType() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);

wxCouponSendConfig.updateTenantInfo(getTenantInfo());
PageInfo<WxCouponSendConfig> page = wxCouponSendConfigService.listAsPage(wxCouponSendConfig, 1, 1);
if (page.getSize() > 0) {
return new ResultData(page.getList().get(0));
} else {
//配置不存在,添加默认配置(停用)
wxCouponSendConfig.setRemark(EnumCouponSendSendType.getEnum(wxCouponSendConfig.getSendType()).getMessage() + "开关");
wxCouponSendConfig.setValue(1);
wxCouponSendConfigService.saveOrUpdate(wxCouponSendConfig);
return new ResultData(wxCouponSendConfig);
}
}


@PostMapping("update")
@ApiOperation("修改开关")
@SystemControllerLog(description = "发券开关-修改开关")
public ResultData updateCouponSendConfig(@RequestBody WxCouponSendConfig wxCouponSendConfig) {
logger.debug("[" + getIpAddr() + "] WxMallConfigController::updateStopCarConpon");
if (wxCouponSendConfig == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
if (wxCouponSendConfig.getId() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
if (wxCouponSendConfig.getSendType() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
if (wxCouponSendConfig.getValue() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
wxCouponSendConfig.updateTenantInfo(getTenantInfo());
wxCouponSendConfig.setUpdateTime(new Date());
wxCouponSendConfigService.update(wxCouponSendConfig);
return new ResultData();
}




}

+ 175
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponSend;
import com.iformall.domain.vo.WxCouponSendVo;
import com.iformall.enums.EnumCouponSendSendType;
import com.iformall.enums.EnumCouponSendType;
import com.iformall.enums.EnumCouponStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxCouponActionLogService;
import com.iformall.service.WxCouponSendService;
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.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.Objects;

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

@Autowired
private WxCouponSendService wxCouponSendService;
@Autowired
private WxCouponService wxCouponService;
@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),
@ApiImplicitParam(name = "merchantName", value = "商户名,模糊查询", dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "merchantId", value = "商户Id", dataType = "String", paramType = "query"),
})
@SystemControllerLog(description = "注券-列表")
public ResultData list(@ModelAttribute WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponSendController::list");
if (null == wxCouponSend) wxCouponSend = new WxCouponSend();
wxCouponSend.updateTenantInfo(getTenantInfo());

// if (Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSend.getSendType())) {
// if (Objects.nonNull(wxCouponSend.getStatus())) {
// valid = wxCouponSend.getStatus();
// } else {
// wxCouponSend.setStatus(null);
// }
// }
PageInfo<WxCouponSendVo> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("注券-添加配置")
@GetMapping("config/add")
@ApiImplicitParams({
@ApiImplicitParam(name = "beforeDays", value = "提前n天发券", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "sendType", value = "注券类型(生日券=8)", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "注券-添加或更新配置")
public ResultData addConfig(Integer beforeDays, Integer sendType) {
if (!Objects.equals(sendType, EnumCouponSendSendType.BIRTHDAY.getCode())) {
return new ResultData(ErrorCode.COUPON_VALID_NOT_SUPPORTED);
}
try {
wxCouponSendService.saveOrUpdateConfig(beforeDays, sendType, getTenantInfo());
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, e.getMessage());
}
return new ResultData();
}

@ApiOperation("注券-获取配置")
@GetMapping("config/get")
@ApiImplicitParams({
@ApiImplicitParam(name = "sendType", value = "注券类型(生日券=8)", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "注券-获取配置")
public ResultData getConfig(Integer sendType) {
WxCouponSend wxCouponSend = wxCouponSendService.getConfig(sendType, getTenantInfo());
return new ResultData(Objects.isNull(wxCouponSend) ? null : wxCouponSend.getConditions());
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "注券-新增")
public ResultData add(@RequestBody WxCouponSend wxCouponSend) {
logger.debug("[" + getIpAddr() + "] WxCouponSendController::add");
if (null == wxCouponSend) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}

WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId(),getTenantInfo().getTenantId());
if (!EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(wxCoupon.getStatus())) {
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF);
}

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

wxCouponSend.updateTenantInfo(wxCoupon);
wxCouponSend.setTitle(wxCoupon.getTitle());

wxCouponSend.setCreateDate(new Date());
wxCouponSend.setUpdateDate(new Date());

try {
wxCouponSend.setOperatorId(getUserId());
wxCouponSendService.saveOrUpdate(wxCouponSend);
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(), e.getMessage());
}

return new ResultData();
}

// @ApiOperation("根据id更新接口")
// @PostMapping("update")
// @SystemControllerLog(description = "注券-更新")
// public ResultData update(@RequestBody WxCouponSend wxCouponSend) {
// logger.debug("[" + getIpAddr() + "] WxCouponSendController::update");
// wxCouponSend.updateTenantInfo(getTenantInfo());
// wxCouponSendService.saveOrUpdate(wxCouponSend);
// return new ResultData();
// }

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true),
@ApiImplicitParam(name = "sendType", value = "注券类型(会员生日券时必传)", dataType = "int", paramType = "query")
})
@SystemControllerLog(description = "注券-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponSendController::delete");
WxCouponSend wxCouponSend = wxCouponSendService.getById(id,getTenantInfo().getTenantId());
if (wxCouponSend == null) {
return new ResultData(ErrorCode.COUPON_SEND_IS_INVALID);
}
try {
wxCouponSendService.updateInvalid(wxCouponSend);
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(), e.getMessage());
}
return new ResultData();
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "注券-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponSendController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCouponSendService.getById(id,getTenantInfo().getTenantId()));
}


}

+ 92
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxFloatingLayer;
import com.iformall.domain.vo.WxFloatingLayerVO;
import com.iformall.enums.EnumFloatingLayerStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxFloatingLayerService;
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.*;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("wxFloatingLayer")
@Api(description = "首页浮层展示")
public class WxFloatingLayerController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxFloatingLayerService wxFloatingLayerService;

@ApiOperation("分页列表接口")
@GetMapping("/list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "列表")
public ResultData list(@ModelAttribute WxFloatingLayer wxFloatingLayer, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::list");
wxFloatingLayer.updateTenantInfo(getTenantInfo());
wxFloatingLayer.setSortColumns(BaseEntity.SortField.CreateTime_DESC, BaseEntity.SortField.Id_DESC);
final PageInfo<WxFloatingLayerVO> page = wxFloatingLayerService.listAsPage(wxFloatingLayer, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("/add")
@SystemControllerLog(description = "新增")
public ResultData add(@RequestBody WxFloatingLayer wxFloatingLayer) {
logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::add");
wxFloatingLayer.updateTenantInfo(getTenantInfo());
wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_THROW_IN.getCode());
try {
return wxFloatingLayerService.saveOrUpdate(wxFloatingLayer);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
}

@ApiOperation("根据id更新接口")
@PostMapping("/updateStatus")
@SystemControllerLog(description = "id更新")
public ResultData updateStatus(@RequestBody WxFloatingLayer wxFloatingLayer) {
logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::updateStatus");
if (wxFloatingLayer.getId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空");
}
try {
wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_TAKE_OFFF.getCode());
return wxFloatingLayerService.updateStatus(wxFloatingLayer);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "活动-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::findById");
WxFloatingLayer wxFloatingLayer = wxFloatingLayerService.getById(id);
return new ResultData(Result.SUCCESS, "查询成功", wxFloatingLayer);
}

}

+ 113
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxGameController.java View File

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

import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxGame;
import com.iformall.enums.EnumGameStatus;
import com.iformall.service.WxGameService;
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.*;

@RestController
@RequestMapping("wxGame")
@Api(description = "游戏接口")
public class WxGameController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxGameService wxGameService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "游戏-列表")
public ResultData list(@ModelAttribute WxGame wxGame, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxGameController::list");
if (null == wxGame) wxGame = new WxGame();
wxGame.updateTenantInfo(getTenantInfo());
wxGame.setSortColumns(BaseEntity.SortField.Id_DESC);
final PageInfo<WxGame> page = wxGameService.listAsPage(wxGame, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "游戏-新增")
public ResultData add(@RequestBody WxGame wxGame) {
logger.debug("[" + getIpAddr() + "] WxGameController::add");
//Assert.notNull(wxGame.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
if (StringUtils.isBlank(wxGame.getCouponIds())) {
wxGame.setCouponIds(JSONArray.toJSONString(new String[0]));
}
if(wxGame.getPlayCreditLimit() != null && wxGame.getPlayCreditLimit() >= 0){
if(wxGame.getPlayCredit() == null || wxGame.getPlayCredit() <= 0){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"游戏消耗积分不能为空或为0");
}
if(wxGame.getPlayLimit() == null || wxGame.getPlayLimit() == 0){
wxGame.setPlayLimit(-1);
}
}
wxGame.setStatus(EnumGameStatus.STATUS_THROW_IN.getCode());
wxGame.updateTenantInfo(getTenantInfo());
wxGameService.saveOrUpdate(wxGame);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "游戏-更新")
public ResultData update(@RequestBody WxGame wxGame) {
logger.debug("[" + getIpAddr() + "] WxGameController::update");
if (StringUtils.isBlank(wxGame.getCouponIds())) {
wxGame.setCouponIds(JSONArray.toJSONString(new String[0]));
}
if(wxGame.getPlayCreditLimit() != null && wxGame.getPlayCreditLimit() >= 0){
if(wxGame.getPlayCredit() == null || wxGame.getPlayCredit() <= 0){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"游戏消耗积分不能为空或为0");
}
if(wxGame.getPlayLimit() == null || wxGame.getPlayLimit() == 0){
wxGame.setPlayLimit(-1);
}
}
wxGame.updateTenantInfo(getTenantInfo());
wxGameService.saveOrUpdate(wxGame);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "游戏-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxGameController::delete");
wxGameService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "游戏-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxGameController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxGameService.getById(id));
}


}

+ 93
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxGameTemplateController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxGameTemplate;
import com.iformall.service.WxGameTemplateService;
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("wxGameTemplate")
@Api(description = "游戏模板接口")
public class WxGameTemplateController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxGameTemplateService wxGameTemplateService;

@ApiOperation("分页列表接口")
@GetMapping("listPage")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "游戏模板-分页列表")
public ResultData listPage(@ModelAttribute WxGameTemplate wxGameTemplate, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxGameTemplateController::listPage");
if (null == wxGameTemplate) wxGameTemplate = new WxGameTemplate();
final PageInfo<WxGameTemplate> page = wxGameTemplateService.listAsPage(wxGameTemplate, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("列表接口")
@GetMapping("list")
@SystemControllerLog(description = "游戏模板-列表")
public ResultData list(@ModelAttribute WxGameTemplate wxGameTemplate) {
logger.debug("[" + getIpAddr() + "] WxGameTemplateController::list");
if (null == wxGameTemplate) wxGameTemplate = new WxGameTemplate();
final List<WxGameTemplate> page = wxGameTemplateService.getList(wxGameTemplate);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "游戏模板-新增")
public ResultData add(@RequestBody WxGameTemplate wxGameTemplate) {
logger.debug("[" + getIpAddr() + "] WxGameTemplateController::add");
//Assert.notNull(wxGameTemplate.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxGameTemplateService.saveOrUpdate(wxGameTemplate);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "游戏模板-更新")
public ResultData update(@RequestBody WxGameTemplate wxGameTemplate) {
logger.debug("[" + getIpAddr() + "] WxGameTemplateController::update");
wxGameTemplateService.saveOrUpdate(wxGameTemplate);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "游戏模板-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxGameTemplateController::delete");
wxGameTemplateService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "游戏模板-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxGameTemplateController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxGameTemplateService.getById(id));
}


}

+ 73
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxMerchantMicroPayController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.dto.WxOrderReportDto;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxMerchantMicroPayVo;
import com.iformall.enums.EnumOrderStatus;
import com.iformall.enums.EnumOrderType;
import com.iformall.service.MarkingDataReportService;
import io.swagger.annotations.Api;
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.*;


@RestController
@RequestMapping("wxMerchantMicroPay")
@Api(description = "B端收银台相关接口")
public class WxMerchantMicroPayController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private MarkingDataReportService markingDataReportService;

@TenantIgnore
@ApiOperation("获得商场近30日刷卡")
@GetMapping("/listMonth")
@SystemControllerLog(description = "收银台-近30日刷卡列表")
public ResultData listMonth() {
logger.debug("[" + getIpAddr() + "] WxMerchantMicroPayController::listMonth");
TenantEntity tenantEntity = getTenantInfo();
WxOrderReportDto wxOrderReportDto = new WxOrderReportDto();
wxOrderReportDto.updateTenantInfo(tenantEntity);
wxOrderReportDto.setType(EnumOrderType.MICROPAY.getCode());
wxOrderReportDto.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode());
return new ResultData(markingDataReportService.listOrderReportByDate(wxOrderReportDto));
}

@TenantIgnore
@ApiOperation("获商户得近30日刷卡")
@GetMapping("/detail")
@SystemControllerLog(description = "收银台-近30日刷卡列表详情")
public ResultData detail(@RequestParam Long merchantId) {
logger.debug("[" + getIpAddr() + "] WxMerchantMicroPayController::detail");
TenantEntity tenantEntity = getTenantInfo();
WxOrderReportDto wxOrderReportDto = new WxOrderReportDto();
wxOrderReportDto.updateTenantInfo(tenantEntity);
wxOrderReportDto.setMerchantId(merchantId);
return new ResultData(markingDataReportService.listMicroPayOrderReportByDateAndMerchant(wxOrderReportDto));
}

@TenantIgnore
@ApiOperation("获得昨日刷卡列表")
@GetMapping("/listYesterday")
@SystemControllerLog(description = "收银台-获得昨日刷卡列表")
public ResultData listYesterday(@ModelAttribute WxOrderReportDto wxOrderReportDto, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::listYesterday");
TenantEntity tenantEntity = getTenantInfo();
if (wxOrderReportDto == null)
wxOrderReportDto = new WxOrderReportDto();
wxOrderReportDto.updateTenantInfo(tenantEntity);
final PageInfo<WxMerchantMicroPayVo> page = markingDataReportService.listMerchantMicroPayOrderReportByDate(wxOrderReportDto, pageNum, pageSize);
return new ResultData(page);
}

}

+ 85
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxMerchantPowerBillConfigController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxMerchantPowerBillConfig;
import com.iformall.service.WxMerchantPowerBillConfigService;
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.*;


/**
* @author gongbiao
*/
@RestController
@RequestMapping("wxMerchantPowerBillConfig")
@Api(description = "商户电费生成配置")
public class WxMerchantPowerBillConfigController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMerchantPowerBillConfigService wxMerchantPowerBillConfigService;


@ApiOperation("查询数据列表")
@GetMapping("/list")
@SystemControllerLog(description = "查询数据列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData findCouponDataList(@ModelAttribute WxMerchantPowerBillConfig wxMerchantPowerBillConfig, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::list");
wxMerchantPowerBillConfig.updateTenantInfo(getTenantInfo());
wxMerchantPowerBillConfig.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
final PageInfo<WxMerchantPowerBillConfig> page = wxMerchantPowerBillConfigService.listAsPage(wxMerchantPowerBillConfig, pageNum, pageSize);
return new ResultData(page);
}


@ApiOperation("新增")
@PostMapping("/add")
@SystemControllerLog(description = "新增")
public ResultData add(@RequestBody WxMerchantPowerBillConfig wxMerchantPowerBillConfig) {
logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::add");
return wxMerchantPowerBillConfigService.saveOrUpdate(wxMerchantPowerBillConfig);
}

@ApiOperation("更新")
@PostMapping("/update")
@SystemControllerLog(description = "更新")
public ResultData update(@RequestBody WxMerchantPowerBillConfig wxMerchantPowerBillConfig) {
logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::update");
return wxMerchantPowerBillConfigService.saveOrUpdate(wxMerchantPowerBillConfig);
}

@ApiOperation("删除")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::delete");
wxMerchantPowerBillConfigService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "id查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxMerchantPowerBillConfigService.getById(id));
}


}

+ 152
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxMerchantSubsidyController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.WxMerchantSubsidyVo;
import com.iformall.enums.EnumMerchantSubsidyStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxMerchantSubsidyService;
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.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("subsidy")
@Api(description = "商户补贴接口")
public class WxMerchantSubsidyController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxMerchantSubsidyService wxMerchantSubsidyService;

@ApiOperation("补贴记录汇总")
@GetMapping("sum")
@SystemControllerLog(description = "商户-补贴记录-汇总")
public ResultData count(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy) {
String ipStr = getIpAddr();
logger.info("subsidy/sum: " + ipStr + " :" + wxMerchantSubsidy.toString());
if (wxMerchantSubsidy == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
}
wxMerchantSubsidy.updateTenantInfo(getTenantInfo());
if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) {
String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(",");
List<Integer> tmpList = new ArrayList<Integer>();
for(String status: statusAttr) {
tmpList.add(Integer.valueOf(status));
}
if(!tmpList.isEmpty()) {
wxMerchantSubsidy.setStatusS(tmpList);
}
}
List<Map<String, Object>> retMap = wxMerchantSubsidyService.sumForSubsidy(wxMerchantSubsidy);
return new ResultData(retMap);
}

@ApiOperation("补贴记录")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "商户-补贴记录-列表")
public ResultData listMonth(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy, Integer pageNum, Integer pageSize) {
String ipStr = getIpAddr();
logger.info("subsidy/list: " + ipStr + " :" + wxMerchantSubsidy.toString());
if (wxMerchantSubsidy == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
}
wxMerchantSubsidy.updateTenantInfo(getTenantInfo());
if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) {
String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(",");
List<Integer> tmpList = new ArrayList<Integer>();
for(String status: statusAttr) {
tmpList.add(Integer.valueOf(status));
}
if(!tmpList.isEmpty()) {
wxMerchantSubsidy.setStatusS(tmpList);
}
}
wxMerchantSubsidy.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
final PageInfo<WxMerchantSubsidyVo> page = wxMerchantSubsidyService.listAsPage(wxMerchantSubsidy, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("交易列表")
@GetMapping("summary")
@SystemControllerLog(description = "结算-总计")
public ResultData summary(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy) {
logger.debug("[" + getIpAddr() + "] subsidy::summary");
if (null == wxMerchantSubsidy) {
wxMerchantSubsidy = new WxMerchantSubsidyVo();
}
wxMerchantSubsidy.updateTenantInfo(getTenantInfo());
Map<String, Long> data = wxMerchantSubsidyService.summary(wxMerchantSubsidy);
return new ResultData(data);
}

@ApiOperation("更新补贴记录")
@PostMapping("updateSubsidied")
@SystemControllerLog(description = "商户-更新补贴记录")
public ResultData updateSubsidied(@RequestBody WxMerchantSubsidyVo wxMerchantSubsidy) {
String ipStr = getIpAddr();
logger.info("subsidy/update: " + ipStr + " :" + wxMerchantSubsidy.toString());
if (wxMerchantSubsidy == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
}
wxMerchantSubsidy.updateTenantInfo(getTenantInfo());
wxMerchantSubsidy.setStatus(EnumMerchantSubsidyStatus.MANUAL_SUBSIDIED.getCode());
wxMerchantSubsidy.setUpdateDate(new Date());
if(StringUtils.isNotBlank(wxMerchantSubsidy.getIdStr())) {
String [] idArr = wxMerchantSubsidy.getIdStr().split(",");
List<Long> tmpList = new ArrayList<Long>();
for(String id: idArr) {
tmpList.add(Long.valueOf(id));
}
if(!tmpList.isEmpty()) {
wxMerchantSubsidy.setIds(tmpList);
}
}
return wxMerchantSubsidyService.update(wxMerchantSubsidy);
}

@ApiOperation("补贴记录导出")
@GetMapping("/exportData")
@SystemControllerLog(description = "商户-补贴记录-导出")
public void exportData(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy, HttpServletRequest request, HttpServletResponse response) {
logger.info("[" + getIpAddr() + "] subsidy/exportData");
if (wxMerchantSubsidy == null) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件不能为空");
}
wxMerchantSubsidy.updateTenantInfo(getTenantInfo());
if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) {
String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(",");
List<Integer> tmpList = new ArrayList<Integer>();
for(String status: statusAttr) {
tmpList.add(Integer.valueOf(status));
}
if(!tmpList.isEmpty()) {
wxMerchantSubsidy.setStatusS(tmpList);
}
}
wxMerchantSubsidy.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
wxMerchantSubsidyService.exportData(wxMerchantSubsidy, request, response);
}

}

+ 75
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxOpinionController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxOpinion;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxOpinionService;
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("wxOpinion")
@Api(description="投诉建议")
public class WxOpinionController extends BaseController {

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

@Autowired
private WxOpinionService wxOpinionService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)
})
@SystemControllerLog(description = "投诉建议-列表")
public ResultData list(@ModelAttribute WxOpinion record, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxOpinionController::list");
if (null == record) {
record = new WxOpinion();
}
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
final PageInfo<WxOpinion> page = wxOpinionService.listAsPage(record, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据id查询接口")
@GetMapping("/getById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "问券调查--查询")
public ResultData getById(Long id) {
logger.debug("[" + getIpAddr() + "] WxOpinionController::getById");
return new ResultData(wxOpinionService.getById(id));
}


@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "问券调查--更新")
public ResultData update(@RequestBody WxOpinion record) {
logger.debug("[" + getIpAddr() + "] WxOpinionController::update");

record.updateTenantInfo(getTenantInfo());
try {
wxOpinionService.saveOrUpdate(record);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
return new ResultData();
}

}

+ 282
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxOrderController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.dto.OrderSaveDto;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.WxMerchantSubsidyVo;
import com.iformall.domain.vo.WxOrderQueryVo;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.service.*;
import com.iformall.service.order.OrderFactory;
import com.iformall.service.order.entity.WxComposeOrder;

import com.iformall.utils.MaUtil;
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.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("wxOrder")
@Api(description = "订单相关接口")
public class WxOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponChannelService wxCouponChannelService;

@Autowired
private WxOrderService wxOrderService;

@Autowired
private WxPayOrderService wxPayOrderService;

@Autowired
private WxCUserService wxCUserService;

@Autowired
private WxCouponService wxCouponService;
@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
OrderFactory orderFactory;
@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 = "int")
})
@SystemControllerLog(description = "订单管理-列表")
public ResultData list(@ModelAttribute WxOrder wxOrder, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxOrderController::list");
if (null == wxOrder) {
wxOrder = new WxOrder();
}
wxOrder.updateTenantInfo(getTenantInfo());
wxOrder.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<WxOrder> page = wxOrderService.listAsPage(wxOrder, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "订单管理-新增")
public ResultData add(@RequestBody WxOrder wxOrder) {
logger.debug("[" + getIpAddr() + "] WxOrderController::add");
//Assert.notNull(wxOrder.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxOrderService.saveOrUpdate(wxOrder,false);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "订单管理-更新")
public ResultData update(@RequestBody WxOrder wxOrder) {
logger.debug("[" + getIpAddr() + "] WxOrderController::update");
wxOrderService.saveOrUpdate(wxOrder,false);
return new ResultData();
}

// @ApiOperation("根据id删除接口")
// @GetMapping("/del")
// @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
// @SystemControllerLog(description = "订单管理-删除")
// public ResultData delete(Long id) {
// logger.debug("[" + getIpAddr() + "] WxOrderController::delete");
// wxOrderService.deleteById(id);
// return new ResultData(Result.SUCCESS, "删除成功", null);
// }

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "订单管理-id查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxOrderController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxOrderService.getById(id,getTenantInfo().getTenantId()));
}


@ApiOperation("交易列表")
@GetMapping("listOrder")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)
})
@SystemControllerLog(description = "订单管理-交易列表")
public ResultData listOrder(@ModelAttribute WxOrderQueryVo wxOrderQueryVo, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxOrderController::listOrder");
if (null == wxOrderQueryVo) {
wxOrderQueryVo = new WxOrderQueryVo();
}
wxOrderQueryVo.updateTenantInfo(getTenantInfo());
final PageInfo<WxOrder> page = wxOrderService.listOrderAsPage(wxOrderQueryVo, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("交易统计")
@GetMapping("/queryOrderSummary")
@SystemControllerLog(description = "订单管理-交易统计")
public ResultData queryOrderSummary() {
logger.debug("[" + getIpAddr() + "] WxOrderController::queryOrderSummary");

Map<String, Object> data = wxOrderService.queryOrderSummary(getTenantInfo());

return new ResultData(data);
}

@ApiOperation(value = "积分兑换订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\",\"formId\":\"String\"}")
@PostMapping("save")
@SystemControllerLog(description = "订单管理-积分兑换订单")
public ResultData saveOrder(@RequestBody OrderSaveDto orderSaveDto) {
logger.info("OrderSave: " + orderSaveDto);
if (orderSaveDto.getCouponChannelId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId不能为空");
}
WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(orderSaveDto.getCouponChannelId(),getTenantInfo().getTenantId());
ResultData resultData = couponChannelCheck(orderSaveDto, wxCouponChannel);
if (resultData != null) {
return resultData;
}

Long couponId = orderSaveDto.getCouponId() == null ? wxCouponChannel.getCouponId() : orderSaveDto.getCouponId();
if (couponId == null) {
logger.error("couponChannelId或者couponId不能为空");
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId或者couponId不能为空");
}

try {
WxCUserBasicInfo user = wxCUserBasicInfoService.getById(orderSaveDto.getUserId(),wxCouponChannel.getFinalTenantId());
if(null == user) {
logger.error("wxcuser未找到:"+orderSaveDto.getUserId());
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
//用于标记当前操作人为A端用户
user.setOperatorType(EnumUserType.MALLUSER.getCode());
user.setOperatorId(getUserId());
WxOrder order = null;
WxCoupon coupon = wxCouponService.getById(couponId,wxCouponChannel.getTenantId());
if (coupon == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
if (!wxOrderService.checkCouponIsFree(coupon,wxCouponChannel,null)) {
return new ResultData(ErrorCode.COUPON_IS_NOT_FREE);
}
// 免费券
WxComposeOrder composeOrder = orderFactory.getOrderAdapterService(EnumComposeOrder.SINGLE.getCode()).createDBMainOrder(coupon, user, 0, EnumPayWay.PAY_WAY_NOT_UNPAY_CREDIT,EnumPayVersion.NO_VERSION);
order = wxOrderService.saveFreeOrderForCoupon(new Date(),false,composeOrder,user, coupon, 1,
wxCouponChannel, orderSaveDto.getFormId(), null,null,EnumPayWay.PAY_WAY_NOT_UNPAY_CREDIT,EnumPayVersion.NO_VERSION,
EnumOrderShopingType.ONLINE_PURCHASE.getCode(),null,false);
return new ResultData(order);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.ORDER_IS_FAIL, e.getMessage());
}
}

private ResultData couponChannelCheck(@RequestBody OrderSaveDto orderSaveDto, WxCouponChannel wxCouponChannel) {
if (wxCouponChannel == null) {
logger.error("couponChannelId convert error, " + orderSaveDto.getCouponChannelId());
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR);
}

if (wxCouponChannel.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) {
Date now = new Date();
if (wxCouponChannel.getBeginTime().getTime() > now.getTime()) {
logger.error("此券活动未开始:" + orderSaveDto.getCouponChannelId());
return new ResultData(ErrorCode.COUPON_CHANNEL_IS_NOT_STARTED);
}
if (wxCouponChannel.getEndTime().getTime() < now.getTime()) {
logger.error("此券活动已结束:" + orderSaveDto.getCouponChannelId());
return new ResultData(ErrorCode.COUPON_CHANNEL_IS_END);
}
}

if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) {
logger.error("此券已下架:" + orderSaveDto.getCouponChannelId());
return new ResultData(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF);
}
return null;
}

@ApiOperation("查看明细")
@GetMapping("/detail")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "订单管理-id查询")
public ResultData detail(Long id) {
logger.debug("[" + getIpAddr() + "] WxOrderController::detail");
WxOrder order = new WxOrder();
order.setId(id);
order.updateTenantInfo(getTenantInfo());
return new ResultData(Result.SUCCESS, "查询成功", wxOrderService.detailCUserVo(order));
}

@ApiOperation("交易列表")
@GetMapping("summary")
@SystemControllerLog(description = "订单管理-总计")
public ResultData summary(@ModelAttribute WxOrderQueryVo wxOrderQueryVo) {
logger.debug("[" + getIpAddr() + "] WxOrderController::summary");
if (null == wxOrderQueryVo) {
wxOrderQueryVo = new WxOrderQueryVo();
}
wxOrderQueryVo.updateTenantInfo(getTenantInfo());
Map<String, Long> data = wxOrderService.summary(wxOrderQueryVo);
return new ResultData(data);
}

@ApiOperation("导出")
@GetMapping("/exportData")
@SystemControllerLog(description = "导出")
public void exportData(@ModelAttribute WxOrderQueryVo wxOrderQueryVo, HttpServletRequest request, HttpServletResponse response) {
logger.info("[" + getIpAddr() + "] WxOrderController/exportData");
if (null == wxOrderQueryVo) {
wxOrderQueryVo = new WxOrderQueryVo();
}
wxOrderQueryVo.updateTenantInfo(getTenantInfo());
wxOrderService.exportData(wxOrderQueryVo, request, response);
}


@ApiOperation("查看抖音订单状态")
@GetMapping("/ttorderQuery")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "订单管理-id查询")
public ResultData ttorderQuery(Long id) {
logger.debug("[" + getIpAddr() + "] WxOrderController::ttorderQuery");
// WxBatchOrder wxBatchOrder = wxOrderService.getWxBatchOrder(getTenantInfo(), id);
// if(wxBatchOrder == null || !EnumPayWay.PAY_WAY_TT.getCode().equals(wxBatchOrder.getPayVendor())){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "订单未找到或不支持");
// }
return new ResultData(wxPayOrderService.ttorderQuery(getTenantInfo(),id));

}


}

+ 70
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxOrderGroupController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxOrderGroupMarketing;
import com.iformall.service.WxMallService;
import com.iformall.service.WxOrderGroupService;
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.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/orderGroup")
@Api(description = "拼团相关接口")
public class WxOrderGroupController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxOrderGroupService wxOrderGroupService;
@Autowired
WxMallService wxMallService;

@TenantIgnore
@ApiOperation(value = "拼团营销分析")
@GetMapping("queryOrderGroupMarketingList")
@ApiImplicitParams({
@ApiImplicitParam(name = "couponId", value = "couponId", dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "订单管理-拼团营销分析")
public ResultData queryOrderGroupMarketingList(@ModelAttribute WxOrderGroupMarketing wxOrderGroupMarketing, Integer pageNum, Integer pageSize) {
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
wxOrderGroupMarketing.updateTenantInfo(tenantEntity);
final PageInfo<WxOrderGroupMarketing> page = wxOrderGroupService.queryOrderGroupMarketingList(wxOrderGroupMarketing,tenantEntitys, pageNum, pageSize);
return new ResultData(page);
}
@ApiOperation(value = "拼团营销数据导出")
@GetMapping("exportOrderGroupMarketingList")
@ApiImplicitParams({
@ApiImplicitParam(name = "couponId", value = "couponId", dataType = "String", paramType = "query")
})
@SystemControllerLog(description = "营销统计-拼团营销数据导出")
public void exportOrderGroupMarketingList(@ModelAttribute WxOrderGroupMarketing wxOrderGroupMarketing, HttpServletRequest request, HttpServletResponse response) {
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
wxOrderGroupMarketing.updateTenantInfo(tenantEntity);
wxOrderGroupService.exportOrderGroupMarketingList(wxOrderGroupMarketing,tenantEntitys, request, response);
}

}

+ 123
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxPayOrderController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxOrder;
import com.iformall.domain.po.WxPayOrder;
import com.iformall.enums.EnumPayStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxOrderService;
import com.iformall.service.WxPayOrderService;
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.Map;

@RestController
@RequestMapping("wxPayOrder")
@Api(description = "支付订单接口")
public class WxPayOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxOrderService wxOrderService;

@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)})
@SystemControllerLog(description = "支付订单-列表")
public ResultData list(@ModelAttribute WxPayOrder wxPayOrder, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxPayOrderController::list");
if (null == wxPayOrder) wxPayOrder = new WxPayOrder();
wxPayOrder.updateTenantInfo(getTenantInfo());
final PageInfo<WxPayOrder> page = wxPayOrderService.listAsPage(wxPayOrder, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "支付订单-新增")
public ResultData add(@RequestBody WxPayOrder wxPayOrder) {
logger.debug("[" + getIpAddr() + "] WxPayOrderController::add");
//Assert.notNull(wxPayOrder.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxPayOrderService.saveOrUpdate(wxPayOrder);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "支付订单-更新")
public ResultData update(@RequestBody WxPayOrder wxPayOrder) {
logger.debug("[" + getIpAddr() + "] WxPayOrderController::update");
wxPayOrderService.saveOrUpdate(wxPayOrder);
return new ResultData();
}

// @ApiOperation("根据id删除接口")
// @GetMapping("/del")
// @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
// @SystemControllerLog(description = "支付订单-删除")
// public ResultData delete(Long id) {
// logger.debug("[" + getIpAddr() + "] WxPayOrderController::delete");
// wxPayOrderService.deleteById(id);
// return new ResultData(Result.SUCCESS, "删除成功", null);
// }

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "支付订单-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxPayOrderController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxPayOrderService.getById(id,getTenantInfo().getTenantId()));
}

@ApiOperation(value = "更新支付订单状态", notes = "{\"payOrderId\":\"string\",\"orderId\":\"string\",\"status\":integer,\"reason\":\"string\"}")
@PostMapping("/updatePayOrder")
@SystemControllerLog(description = "支付订单-更新支付订单状态")
public ResultData updatePayOrder(@RequestBody Map<String, Object> paramMap) {
logger.info("/api/pay/updatePayOrder" + paramMap.toString());
String payOrderIdStr = (String) paramMap.get("payOrderId");
String orderIdStr = (String) paramMap.get("orderId");
String reasonStr = (String) paramMap.get("reason");
Integer status = (Integer) paramMap.get("status");
if (StringUtils.isBlank(orderIdStr)) {
logger.info("orderId不能为空: " + paramMap.toString());
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空");
}
try {
Long.valueOf(orderIdStr);
} catch (NumberFormatException e) {
logger.error("orderId参数不正确: " + paramMap.toString() + ", e:" + e.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId参数不正确");
}
if (!StringUtils.isBlank(payOrderIdStr)) {
try {
Long.valueOf(payOrderIdStr);
} catch (NumberFormatException e) {
logger.error("payOrderId参数不正确: " + paramMap.toString() + ", e:" + e.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId参数不正确");
}
}
// 免费券直接返回成功
return new ResultData(Result.SUCCESS, "免费券支付状态更新成功");

}
}

+ 67
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxPowerBillAutoConfigController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxPowerBillAutoConfig;
import com.iformall.service.WxPowerBillAutoConfigService;
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.*;


/**
* @author gongbiao
*/
@RestController
@RequestMapping("wxPowerBillAutoConfig")
@Api(description = "电费自动生成配置")
public class WxPowerBillAutoConfigController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxPowerBillAutoConfigService wxPowerBillAutoConfigService;


@ApiOperation("查询数据列表")
@GetMapping("/list")
@SystemControllerLog(description = "查询数据列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData findCouponDataList(@ModelAttribute WxPowerBillAutoConfig wxPowerBillAutoConfig, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::list");
wxPowerBillAutoConfig.updateTenantInfo(getTenantInfo());
wxPowerBillAutoConfig.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
final PageInfo<WxPowerBillAutoConfig> page = wxPowerBillAutoConfigService.listAsPage(wxPowerBillAutoConfig, pageNum, pageSize);
return new ResultData(page);
}


@ApiOperation("修改")
@PostMapping("/modify")
@SystemControllerLog(description = "修改")
public ResultData add(@RequestBody WxPowerBillAutoConfig wxPowerBillAutoConfig) {
logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::modify");
return wxPowerBillAutoConfigService.modify(wxPowerBillAutoConfig);
}


@ApiOperation("得到配置信息")
@GetMapping("/getConfig")
@SystemControllerLog(description = "id查询")
public ResultData getConfig() {
logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::getConfig");
return new ResultData(Result.SUCCESS, "查询成功", wxPowerBillAutoConfigService.getConfig(getTenantInfo()));
}


}

+ 91
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxPrepaymentController.java View File

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


import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxPrepayment;
import com.iformall.domain.po.WxPrepaymentHistory;
import com.iformall.enums.EnumUserType;
import com.iformall.service.WxPrepaymentService;
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.*;


/**
* @author gongbiao
*/
@RestController
@RequestMapping("prepayment")
@Api(description = "预付费")
public class WxPrepaymentController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxPrepaymentService wxPrepaymentService;

@ApiOperation("列表查询")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "预付费-列表查询")
public ResultData list(@ModelAttribute WxPrepayment wxPrepayment, Integer pageNum, Integer pageSize) {
String ipStr = getIpAddr();
logger.info("prepayment/list: " + ipStr);
if (wxPrepayment == null) {
wxPrepayment = new WxPrepayment();
}
final PageInfo<WxPrepayment> page = wxPrepaymentService.listAsPage(wxPrepayment, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("列表查询历史")
@GetMapping("listHistory")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "预付费-列表查询历史")
public ResultData listHistory(@ModelAttribute WxPrepaymentHistory wxPrepaymentHistory, Integer pageNum, Integer pageSize) {
String ipStr = getIpAddr();
logger.info("prepayment/listHistory: " + ipStr);
if (wxPrepaymentHistory == null) {
wxPrepaymentHistory = new WxPrepaymentHistory();
}
final PageInfo<WxPrepaymentHistory> page = wxPrepaymentService.listHistoryAsPage(wxPrepaymentHistory, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("首次充值")
@PostMapping("payFirst")
@SystemControllerLog(description = "预付费-交费")
public ResultData payFirst(@RequestBody WxPrepayment wxPrepayment) {
logger.debug("[" + getIpAddr() + "] prepayment::add");
wxPrepayment.updateTenantInfo(getTenantInfo());
wxPrepayment.setOperationType(EnumUserType.MALLUSER.getCode());
wxPrepayment.setOperator(getUserId());
wxPrepaymentService.payFirst(wxPrepayment);
return new ResultData();
}

@ApiOperation("再次充值")
@PostMapping("payAgain")
@SystemControllerLog(description = "预付费-交费或扣费")
public ResultData payAgain(@RequestBody WxPrepayment wxPrepayment) {
logger.debug("[" + getIpAddr() + "] prepayment::update");
wxPrepayment.updateTenantInfo(getTenantInfo());
wxPrepayment.setOperationType(EnumUserType.MALLUSER.getCode());
wxPrepayment.setOperator(getUserId());
wxPrepaymentService.payAgain(wxPrepayment);
return new ResultData();

}

}

+ 280
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxPressBatchController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.AliBusinessCircleOrder;
import com.iformall.domain.po.WxBusinessCircleOrder;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.WxPressBatch;
import com.iformall.domain.po.WxPressBatchItem;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumCouponChannelStatus;
import com.iformall.enums.EnumCouponChannelType;
import com.iformall.enums.EnumCouponContentType;
import com.iformall.enums.EnumCouponSourceType;
import com.iformall.enums.EnumCouponType;
import com.iformall.enums.EnumRentContractAppStatus;
import com.iformall.service.AliBusinessCircleOrderService;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import com.iformall.service.WxPressBatchService;
import com.iformall.utils.Constant;
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.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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

@Autowired
WxPressBatchService wxPressBatchService;
@Autowired
WxCouponService wxCouponService;
@Autowired
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 WxPressBatch record, Integer pageNum, Integer pageSize) {
if (null == record) {
record = new WxPressBatch();
}
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
final PageInfo<WxPressBatch> page = wxPressBatchService.listAsPage(record, pageNum, pageSize);
return new ResultData(page);
}
@ApiOperation("新增&修改接口")
@PostMapping("saveOrUpdate")
public ResultData saveOrUpdate(@RequestBody WxPressBatch record) {
TenantEntity tenantEntity = getTenantInfo();
record.updateTenantInfo(tenantEntity);
wxPressBatchService.saveOrUpdate(record);
return new ResultData();
}
@ApiOperation("详情接口")
@GetMapping("detail")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)})
public ResultData detail(Long id) {
if (null == id) {
return new ResultData(Result.ERROR,"参数错误");
}
WxPressBatch order = wxPressBatchService.getById(id, getTenantInfo().getTenantId());
return new ResultData(order);
}
@ApiOperation("砍价券接口")
@GetMapping("itemList")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", 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 itemList(Long id, Integer pageNum, Integer pageSize) {
if (null == id) {
return new ResultData(Result.ERROR,"参数错误");
}
TenantEntity tenantEntity = getTenantInfo();
PageInfo<WxPressBatchItem> itemPage = wxPressBatchService.getItemPage(id, tenantEntity.getTenantId(),pageNum,pageSize);
List<WxPressBatchItem> items = itemPage.getList();
if (null != items && items.size() > 0 ) {
List<Long> couponIdList = wxPressBatchService.getItemCouponIdList(id, tenantEntity.getTenantId());
WxCoupon record = new WxCoupon();
record.updateTenantInfo(getTenantInfo());
if (null != couponIdList && couponIdList.size() > 0 ) {
record.setIds(couponIdList);
}else {
record.setId(0L);
}
List<WxCoupon> list = wxCouponService.list(record);
Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>();
if (null != list && list.size() > 0 ) {
for (WxCoupon c : list) {
couponMap.put(c.getId(), c);
}
}
for (WxPressBatchItem pbi : items) {
WxCoupon coupon = couponMap.get(pbi.getCouponId());
pbi.setCoupon(coupon);
}
}
return new ResultData(itemPage);
}
@ApiOperation("删除接口")
@PostMapping("delete")
public ResultData delete(@RequestBody WxPressBatch record) {
if (null == record.getId()) {
return new ResultData(Result.ERROR,"参数错误");
}
wxPressBatchService.deleteBatch(record.getId(), getTenantInfo().getTenantId());
return new ResultData();
}
@ApiOperation("已投放砍价券列表接口")
@GetMapping("couponList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),})
public ResultData couponList(@ModelAttribute WxCoupon record, Integer pageNum, Integer pageSize) {
WxCouponChannel couponChannelQ = new WxCouponChannel();
couponChannelQ.updateTenantInfo(getTenantInfo());
couponChannelQ.setType(EnumCouponType.COUPON_PRESS.getCode());
couponChannelQ.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode());
couponChannelQ.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());
List<Long> couponIds = wxCouponChannelService.findCouponIdList(couponChannelQ);
if (null == record) {
record = new WxCoupon();
}
record.updateTenantInfo(couponChannelQ);
if (null != couponIds && couponIds.size() > 0 ) {
record.setIds(couponIds);
}else {
record.setId(0L);
}
PageInfo<WxCoupon> page = wxCouponService.simplelistAsPage(record, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增items")
@PostMapping("addItems")
public ResultData addItems(@RequestBody WxPressBatch record) {
TenantEntity tenantEntity = getTenantInfo();
record.updateTenantInfo(tenantEntity);
if (null == record.getId()) {
return new ResultData(Result.ERROR,"参数错误");
}
String cidstr = record.getCouponIds();
if (StringUtils.isBlank(cidstr)) {
return new ResultData(Result.ERROR,"参数错误");
}
String[] cids = cidstr.split(",");
if (null == cids || cids.length <= 0 ) {
return new ResultData(Result.ERROR,"请选择砍价券");
}
List<Long> rcids = new ArrayList<Long>();
for (String cid: cids) {
rcids.add(Long.parseLong(cid));
}
//已经存在了的不能再加入
List<Long> arrayCouponIds = wxPressBatchService.getCouponIds(tenantEntity.getTenantId());
if (null != arrayCouponIds && arrayCouponIds.size() > 0 ) {
if (arrayCouponIds.containsAll(rcids)) {
return new ResultData(Result.ERROR,"所选择的券已经加入了一个批次,不能再加");
}
List<Long> extraCouponIds = new ArrayList<Long>();
extraCouponIds.addAll(rcids);
extraCouponIds.removeAll(arrayCouponIds);
List<Long> sameCouponIds = new ArrayList<Long>();
sameCouponIds.addAll(rcids);
sameCouponIds.removeAll(extraCouponIds);
if (sameCouponIds.size() > 0) {
WxCoupon couponQ = new WxCoupon();
couponQ.updateTenantInfo(tenantEntity);
couponQ.setIds(sameCouponIds);
List<WxCoupon> couponList = wxCouponService.list(couponQ);
if (null == couponList || couponList.size() <= 0 ) {
return new ResultData(Result.ERROR,"未查询到这些券");
}
Map<Long,String> couponNameMap = new HashMap<Long,String>();
for (WxCoupon c: couponList) {
couponNameMap.put(c.getId(),c.getTitle());
}
StringBuffer sb = new StringBuffer("已经存在一个批次的券:");
for (Long _cid: sameCouponIds) {
sb.append(couponNameMap.get(_cid)).append(",");
}
return new ResultData(Result.ERROR,sb.toString());
}
}
List<Long> batchCids = wxPressBatchService.getItemCouponIdList(record.getId(), tenantEntity.getTenantId());
if (null != cids && cids.length > 0 ) {
if (null != batchCids && batchCids.size() > 0 ) {
rcids.removeAll(batchCids);
}
WxPressBatch order = wxPressBatchService.getById(record.getId(), tenantEntity.getTenantId());
wxPressBatchService.saveItems(order, rcids);
}
return new ResultData();
}
@ApiOperation("详情接口")
@PostMapping("deleteItem")
public ResultData deleteItem(@RequestBody WxPressBatchItem record) {
if (null == record.getId()) {
return new ResultData(Result.ERROR,"参数错误");
}
wxPressBatchService.deleteItemById(record.getId(), getTenantInfo().getTenantId());
return new ResultData();
}
@ApiOperation("详情接口")
@PostMapping("updateStatus")
public ResultData updateStatus(@RequestBody WxPressBatch record) {
if (null == record.getId() || null == record.getStatus()) {
return new ResultData(Result.ERROR,"参数错误");
}
record.updateTenantInfo(getTenantInfo());
wxPressBatchService.updateStatus(record);
return new ResultData();
}
@ApiOperation("详情接口")
@PostMapping("setRules")
public ResultData setRules(@RequestBody WxPressBatch record) {
if (null == record.getId()) {
return new ResultData(Result.ERROR,"参数错误");
}
WxPressBatch record1 = wxPressBatchService.getById(record.getId(), getTenantInfo().getTenantId());
record1.setPromoterLimitRule(record.getPromoterLimitRule());
record1.setPromoterAllowCount(record.getPromoterAllowCount());
record1.setBargainerAllowCount(record.getBargainerAllowCount());
record1.setBargainerAllowSame(record.getBargainerAllowSame());
wxPressBatchService.saveOrUpdate(record1);
return new ResultData();
}


}

+ 128
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxProfitSharingOrderController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxProfitSharingOrderQueryVo;
import com.iformall.domain.vo.WxProfitSharingOrderVo;
import com.iformall.service.WxProfitSharingOrderService;
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.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("wxProfitSharingOrder")
@Api(description = "微信分账订单接口")
public class WxProfitSharingOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxProfitSharingOrderService wxProfitSharingOrderService;

@TenantIgnore
@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 WxProfitSharingOrderQueryVo order, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::list");
if (null == order) {
order = new WxProfitSharingOrderQueryVo();
}
order.updateTenantInfo(getTenantInfo());
final PageInfo<WxProfitSharingOrderVo> page = wxProfitSharingOrderService.listAsPage(order, pageNum, pageSize);
return new ResultData(page);
}
@TenantIgnore
@ApiOperation("子广场集团券核销分页列表接口")
@GetMapping("groupList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData groupList(@ModelAttribute WxProfitSharingOrderQueryVo order, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::list");
if (null == order) {
order = new WxProfitSharingOrderQueryVo();
}
TenantEntity mallTenantEntity = getTenantInfo();
order.setTenantId(mallTenantEntity.getParentTenantId());
order.setBTenantId(mallTenantEntity.getTenantId());
final PageInfo<WxProfitSharingOrderVo> page = wxProfitSharingOrderService.listAsPage(order, pageNum, pageSize);
return new ResultData(page);
}
@ApiOperation("记录导出")
@GetMapping("/exportData")
@SystemControllerLog(description = "线上自动分账记录-导出")
public void exportData(@ModelAttribute WxProfitSharingOrderQueryVo order, HttpServletRequest request, HttpServletResponse response) {
if (null == order) {
order = new WxProfitSharingOrderQueryVo();
}
wxProfitSharingOrderService.exportData(order, request, response);
}

@TenantIgnore
@ApiOperation("记录导出")
@GetMapping("/exportGroupData")
@SystemControllerLog(description = "线上自动分账记录-导出")
public void exportGroupData(@ModelAttribute WxProfitSharingOrderQueryVo order, HttpServletRequest request, HttpServletResponse response) {
if (null == order) {
order = new WxProfitSharingOrderQueryVo();
}
TenantEntity mallTenantEntity = getTenantInfo();
order.setTenantId(mallTenantEntity.getParentTenantId());
order.setBTenantId(mallTenantEntity.getTenantId());
wxProfitSharingOrderService.exportData(order, request, response);
}
@ApiOperation("交易统计")
@GetMapping("/queryOrderSummary")
@SystemControllerLog(description = "分账订单-交易统计")
public ResultData queryOrderSummary() {
logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::queryOrderSummary");

Map<String, Object> data = wxProfitSharingOrderService.queryOrderSummary(getTenantInfo());

return new ResultData(data);
}


@TenantIgnore
@ApiOperation("分账详情")
@GetMapping("findOrderDetails")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "分账订单-分账详情")
public ResultData findOrderDetails(Long id,String mallTenantId) {
logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::findOrderDetails");
if(StringUtils.isBlank(mallTenantId) || "undefined".equals(mallTenantId)){
mallTenantId = getTenantInfo().getTenantId();
}
return wxProfitSharingOrderService.findOrderDetails(id,mallTenantId);


}


}

+ 87
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxQuestionController.java View File

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

import com.alibaba.fastjson.JSONObject;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxQuestion;
import com.iformall.domain.po.WxQuestionConfig;
import com.iformall.enums.EnumQuestionConfigStatus;
import com.iformall.service.*;
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.*;

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

@RestController
@RequestMapping("wxQuestion")
@Api(description="问券调查")
public class WxQuestionController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxQuestionService wxQuestionService;


@ApiOperation("查寻问券配置")
@GetMapping("getConfig")
@SystemControllerLog(description = "营销-问券调查-配置获取")
public Result getQuestionConfig() {
logger.debug("[" + getIpAddr() + "] WxQuestionController::getQuestionConfig");
WxQuestionConfig wxQuestionConfig = new WxQuestionConfig();
wxQuestionConfig.updateTenantInfo(getTenantInfo());
WxQuestion wxQuestion = new WxQuestion();
wxQuestion.updateTenantInfo(wxQuestionConfig);

List<WxQuestionConfig> list = wxQuestionService.findConfigList(wxQuestionConfig);
if (list.size() > 0) {
list.get(0).setQuestions(wxQuestionService.findList(wxQuestion));
return new ResultData(list.get(0));
}
wxQuestionConfig.setQuestions(wxQuestionService.findList(wxQuestion));
wxQuestionConfig.setQuestionList("");
wxQuestionConfig.setCouponTypeList("");
wxQuestionConfig.setStatus(EnumQuestionConfigStatus.OFF.getCode());
return new ResultData(wxQuestionConfig);
}


@ApiOperation("设置问券配置")
@PostMapping("setConfig")
@SystemControllerLog(description = "营销-问券调查-设置")
public Result setQuestionConfig(@RequestBody WxQuestionConfig wxQuestionConfig) {
logger.debug("[" + getIpAddr() + "] WxQuestionController::setQuestionConfig");
if (wxQuestionConfig == null)
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
if (wxQuestionConfig.getQuestionList() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
if (wxQuestionConfig.getCouponTypeList() == null)
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);

String[] arys1 = wxQuestionConfig.getQuestionList().split(",");
List<Long> qs = new ArrayList<>();
for (int i = 0; i < arys1.length; i++) {
if (!arys1[i].isEmpty())
qs.add(Long.parseLong(arys1[i]));
}
String[] arys2 = wxQuestionConfig.getCouponTypeList().split(",");
List<Long> ct = new ArrayList<>();
for (int i = 0; i < arys2.length; i++) {
if (!arys2[i].isEmpty())
ct.add(Long.parseLong(arys2[i]));
}
wxQuestionConfig.setQuestionList(JSONObject.toJSONString(qs));
wxQuestionConfig.setCouponTypeList(JSONObject.toJSONString(ct));
wxQuestionConfig.updateTenantInfo(getTenantInfo());
wxQuestionService.saveOrUpdateConfig(wxQuestionConfig);
return new ResultData();
}

}

+ 176
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxQuestionOneselfController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxQuestionOneself;
import com.iformall.domain.po.WxQuestionOneselfUser;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumQuestionOneselfStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxQuestionOneselfService;
import com.iformall.service.WxQuestionOneselfUserService;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping("wxQuestionOneself")
@Api(description="问券调查")
public class WxQuestionOneselfController extends BaseController {

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

@Autowired
private WxQuestionOneselfService wxQuestionOneselfService;

@Autowired
private WxQuestionOneselfUserService wxQuestionOneselfUserService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)
})
@SystemControllerLog(description = "问券调查-列表")
public ResultData list(@ModelAttribute WxQuestionOneself record, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::list");
if (null == record) {
record = new WxQuestionOneself();
}
if (record.getStatus() != null && record.getStatus() == -1) {
record.setStatus(null);
}
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Sort_DESC);
final PageInfo<WxQuestionOneself> page = wxQuestionOneselfService.listAsPage(record, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "问券调查-新增")
public ResultData add(@RequestBody WxQuestionOneself record) {
logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::add");

record.updateTenantInfo(getTenantInfo());
try {
wxQuestionOneselfService.saveOrUpdate(record);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}

return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "问券调查--更新")
public ResultData update(@RequestBody WxQuestionOneself record) {
logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::update");

record.updateTenantInfo(getTenantInfo());
try {
wxQuestionOneselfService.saveOrUpdate(record);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("updateStatus")
@SystemControllerLog(description = "问券调查--更新状态")
public ResultData updateStatus(@RequestBody WxQuestionOneself record) {
logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::updateStatus");
if(record == null || record.getStatus() == null || record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(!record.getStatus().equals(EnumQuestionOneselfStatus.STATUS_TAKE_OFFF.getCode())
&& !record.getStatus().equals(EnumQuestionOneselfStatus.INJECT_ONLINE.getCode())) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}
return wxQuestionOneselfService.updateStatus(record);
}

@ApiOperation("根据id查询接口")
@GetMapping("/detailsById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "问券调查--查询")
public ResultData detailsById(Long id) {
logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::detailsById");
return new ResultData(wxQuestionOneselfService.detailsById(id));
}

@ApiOperation("投放到宣传页")
@GetMapping("/sendToCampaign")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "问券调查--投放到宣传页")
public ResultData sendToCampaign(Long id) {
logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::sendToCampaign");
return wxQuestionOneselfService.sendToCampaign(id);
}

@ApiOperation("从宣传页下线")
@GetMapping("offLineCampaign")
@SystemControllerLog(description = "问券调查--从宣传页下线")
public ResultData offLineCampaign(Long id) {
logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::offLineCampaign");
return wxQuestionOneselfService.offLineCampaign(id);
}

@ApiOperation("分页列表接口")
@GetMapping("userList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)
})
@SystemControllerLog(description = "userList-列表")
public ResultData userList(@ModelAttribute WxQuestionOneselfUser record, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::userList");
if (null == record) {
record = new WxQuestionOneselfUser();
}
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
final PageInfo<WxQuestionOneselfUser> page = wxQuestionOneselfUserService.listAsPage(record, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据id查询接口")
@GetMapping("/userDetails")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "问券调查--查询")
public ResultData userDetails(Long id) {
logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::userDetails");
return new ResultData(wxQuestionOneselfUserService.userDetailsById(id));
}

@ApiOperation("导出")
@GetMapping("/exportData")
@SystemControllerLog(description = "导出")
public void exportData(@ModelAttribute WxQuestionOneselfUser record, HttpServletRequest request, HttpServletResponse response) {
logger.info("[" + getIpAddr() + "] WxQuestionOneselfController/exportData");
if (null == record || record.getQuestionId() == null) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
wxQuestionOneselfUserService.exportData(record, request, response);
}

}

+ 84
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxRefundOrderController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.controller.base.BaseController;
import io.swagger.annotations.Api;
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("/refund")
@Api(description = "微信退款订单接口")
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)})
@SystemControllerLog(description = "退款-列表")
public ResultData list(@ModelAttribute WxRefundOrder wxRefundOrder, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxRefundOrderController::list");
if (null == wxRefundOrder) wxRefundOrder = new WxRefundOrder();
final PageInfo<WxRefundOrder> page = wxRefundOrderService.listAsPage(wxRefundOrder, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "退款-新增")
public ResultData add(@RequestBody WxRefundOrder wxRefundOrder) {
logger.debug("[" + getIpAddr() + "] WxRefundOrderController::add");
//Assert.notNull(wxRefundOrder.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxRefundOrderService.saveOrUpdate(wxRefundOrder);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "退款-更新")
public ResultData update(@RequestBody WxRefundOrder wxRefundOrder) {
logger.debug("[" + getIpAddr() + "] WxRefundOrderController::update");
wxRefundOrderService.saveOrUpdate(wxRefundOrder);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "退款-根据id删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxRefundOrderController::delete");
wxRefundOrderService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "退款-id查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxRefundOrderController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxRefundOrderService.getById(id));
}


}

+ 110
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxSubsidyController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.exception.MallinkException;
import com.iformall.utils.PayUtil;
import io.swagger.annotations.Api;
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.WxSubsidy;
import com.iformall.service.WxSubsidyService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.util.Map;

@RestController
@RequestMapping("wxSubsidy")
@Api(description = "商城补贴支付接口")
public class WxSubsidyController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxSubsidyService wxSubsidyService;

// @ApiOperation("补贴扫码支付发起")
// @GetMapping("prePay")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "amount", value = "金额", dataType = "String", paramType = "query", required = true)})
// @SystemControllerLog(description = "商城补贴-补贴扫码支付发起")
// public void subsidyPrepay(String amount, HttpServletResponse response) throws Exception {
// String ipStr = getIpAddr();
// logger.info("subsidyPrepay: " + ipStr + "-" + amount);
// MallUserInfo userInfo = getUser();
// ResultData resultData = wxSubsidyService.createSubsidy(userInfo, ipStr, amount);
// if (resultData.code == 200) {
// String codeUrl = ((Map<String, String>) resultData.data).get("code_url");
// BufferedImage image = PayUtil.getQRCodeImge(codeUrl);
//
// response.setContentType("image/jpeg");
// response.setHeader("Pragma", "no-cache");
// response.setHeader("Cache-Control", "no-cache");
// response.setIntHeader("Expires", -1);
// ImageIO.write(image, "JPEG", response.getOutputStream());
// } else {
// throw new MallinkException(resultData.code, resultData.message);
// }
// }

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "商城补贴-列表")
public ResultData list(@ModelAttribute WxSubsidy wxSubsidy, Integer pageNum, Integer pageSize) {
if (null == wxSubsidy) wxSubsidy = new WxSubsidy();
final PageInfo<WxSubsidy> page = wxSubsidyService.listAsPage(wxSubsidy, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "商城补贴-新增接口")
public ResultData add(@RequestBody WxSubsidy wxSubsidy) {
//Assert.notNull(wxSubsidy.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxSubsidyService.saveOrUpdate(wxSubsidy);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "商城补贴-更新")
public ResultData update(@RequestBody WxSubsidy wxSubsidy) {
wxSubsidyService.saveOrUpdate(wxSubsidy);
return new ResultData();
}

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

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


}

+ 126
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxThirdPartyOrdersController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxThirdPartyOrders;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumThirdOrderType;
import com.iformall.service.WxThirdPartyOrdersService;
import com.iformall.utils.Constant;
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.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
@RequestMapping("thirdCircle")
@Api(description = "订单相关接口")
public class WxThirdPartyOrdersController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxThirdPartyOrdersService wxThirdPartyOrdersOrderService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "-列表")
public ResultData list(@ModelAttribute WxThirdPartyOrders circleOrder, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxThirdPartyOrdersController::list");
if (null == circleOrder) {
circleOrder = new WxThirdPartyOrders();
}
circleOrder.updateTenantInfo(getTenantInfo());
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<WxThirdPartyOrders> page = wxThirdPartyOrdersOrderService.listAsPage(circleOrder, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("统计接口")
@GetMapping("statistics")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "-统计")
public ResultData statistics(@ModelAttribute WxThirdPartyOrders circleOrder) {
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::statistics");
if (null == circleOrder) {
circleOrder = new WxThirdPartyOrders();
}
circleOrder.updateTenantInfo(getTenantInfo());
Integer sumPayAmount = wxThirdPartyOrdersOrderService.sumCirclePayment(circleOrder);
Integer sumRefundAmount = wxThirdPartyOrdersOrderService.sumCircleRefundAmount(circleOrder);
Map resultMap = new HashMap();
resultMap.put("sumPayAmount",sumPayAmount);
resultMap.put("sumRefundAmount",sumRefundAmount);
return new ResultData(resultMap);
}

@ApiOperation("详情接口")
@GetMapping("detail")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true)
})
public ResultData detail(String orderId) {
if (StringUtils.isBlank(orderId) || orderId.equalsIgnoreCase(Constant.UNDEFINED)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
Long id;
try {
id = Long.valueOf(orderId);
} catch (NumberFormatException e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "orderId: " + orderId + ", e: " + e.getMessage());
}

WxThirdPartyOrders order = wxThirdPartyOrdersOrderService.detail(id,getTenantInfo());
return new ResultData(order);
}

@GetMapping("exportData")
@SystemControllerLog(description = "券订单数据-导出数据")
public void exportData(@ModelAttribute WxThirdPartyOrders circleOrder, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxThirdPartyOrdersController::exportData");
if (null == circleOrder) {
circleOrder = new WxThirdPartyOrders();
}
circleOrder.updateTenantInfo(getTenantInfo());
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
circleOrder.setSourceType(EnumThirdOrderType.RMB_PAY.getCode());
wxThirdPartyOrdersOrderService.exportData(circleOrder, request, response);
}

@GetMapping("exportDataVo")
@SystemControllerLog(description = "券订单数据-导出数据")
public void exportDataVo(@ModelAttribute WxThirdPartyOrders circleOrder, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxThirdPartyOrdersController::exportDataVo");
if (null == circleOrder) {
circleOrder = new WxThirdPartyOrders();
}
circleOrder.updateTenantInfo(getTenantInfo());
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
circleOrder.setSourceType(EnumThirdOrderType.CREDIT_PAY.getCode());
wxThirdPartyOrdersOrderService.exportDataVo(circleOrder, request, response);
}

}

+ 107
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxTopicController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.enums.EnumWxTopicStatus;
import com.iformall.enums.EnumWxTopicType;
import com.iformall.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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;

@RestController
@RequestMapping("topic")
@Api(description = "专题相关接口")
public class WxTopicController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private WxTopicService wxTopicService;

@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "专题-列表")
public ResultData list(WxTopic wxTopic, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxTopicController::list");
wxTopic.updateTenantInfo(getTenantInfo());
wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode());
PageInfo<WxTopic> page = wxTopicService.listAsPage(wxTopic, pageNum, pageSize);

//可投放、已上线,时间区间查的是活动开始时间
//已下线、已作为,时间区间查的是活动结束时间

//设置正在上架的专题
Date now = new Date();
page.getList().stream().forEach(cc->{
if (cc.getStatus().equals(EnumWxTopicStatus.VAILD.getCode()) &&
cc.getEndTime()!=null && cc.getBeginTime()!=null &&
now.getTime() >= cc.getBeginTime().getTime() &&
now.getTime() <= cc.getEndTime().getTime()) {
cc.setIsOnline(1);
}
});
return new ResultData(page);
}

@GetMapping("findById")
@SystemControllerLog(description = "专题-获取详情")
public ResultData findById(WxTopic wxTopic) {
logger.debug("[" + getIpAddr() + "] WxTopicController::findById");
wxTopic.updateTenantInfo(getTenantInfo());
WxTopic queryTopic = wxTopicService.findById(wxTopic);
return new ResultData(queryTopic);
}


@PostMapping("saveOrUpdate")
@SystemControllerLog(description = "专题-保存更新")
public ResultData saveOrUpdate(@RequestBody WxTopic wxTopic) {
logger.debug("[" + getIpAddr() + "] WxTopicController::saveOrUpdate");
wxTopic.updateTenantInfo(getTenantInfo());
if(wxTopic.getTopicType() == null){
wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode());
}
return wxTopicService.saveOrUpdate(wxTopic);
}

@GetMapping("findByType")
@SystemControllerLog(description = "专题-获取详情")
public ResultData findByType(Integer topicType) {
logger.debug("[" + getIpAddr() + "] WxTopicController::findByType");
if(topicType == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxTopic wxTopic = new WxTopic();
wxTopic.updateTenantInfo(getTenantInfo());
wxTopic.setTopicType(topicType);
WxTopic queryTopic = wxTopicService.findByType(wxTopic);
return new ResultData(queryTopic);
}

@PostMapping("updateByType")
@SystemControllerLog(description = "专题-保存更新")
public ResultData updateByType(@RequestBody WxTopic wxTopic) {
logger.debug("[" + getIpAddr() + "] WxTopicController::updateByType");
wxTopic.updateTenantInfo(getTenantInfo());
if(wxTopic.getTopicType() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
wxTopic.setName(EnumWxTopicType.getEnum(wxTopic.getTopicType()).getMessage());
if(StringUtils.isBlank(wxTopic.getName())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}
return wxTopicService.saveOrUpdate(wxTopic);
}

}

+ 48
- 0
suimangAdmin/src/main/java/com/iformall/controller/market/WxUserCouponController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.dto.WxUserCouponDto;
import com.iformall.service.WxUserCouponService;
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.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")
@Api(description = "会员卡券查询接口")
public class WxUserCouponController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());


@Autowired
private WxUserCouponService wxUserCouponService;


@ApiOperation("查询用户卡券接口")
@PostMapping("findByStatus")
@SystemControllerLog(description = "会员管理-查询用户卡券接口")
public ResultData findByStatus(@RequestBody WxUserCouponDto wxUserCoupon) {
logger.debug("[" + getIpAddr() + "] WxUserCouponController::findByStatus");
//根据用户id,用户卡券状态查找
if(wxUserCoupon==null||wxUserCoupon.getCUserId()==null||wxUserCoupon.getCouponStatus()==null){
return new ResultData(Result.ERROR,"查询失败");
}
return new ResultData(Result.SUCCESS,"查询成功",wxUserCouponService.findList(getTenantInfo(),wxUserCoupon.getCUserId(),wxUserCoupon.getCouponStatus()));
}




}

+ 198
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/AsyncTask.java View File

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

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxTags;
import com.iformall.domain.vo.CUserBaseInfoT;
import com.iformall.domain.vo.MerchantPoiT;
import com.iformall.service.TtMerchantPoiService;
import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxTagsService;
import org.apache.shiro.session.UnknownSessionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
public class AsyncTask {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
private TtMerchantPoiService ttMerchantPoiService;

@Autowired
private WxTagsService wxTagsService;

@Autowired
StringRedisTemplate stringRedisTemplate;

private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> {
@Override
public Object importHandler(CUserBaseInfoT obj, String name, Object value) {
if (value == null) {
value = "";
}
System.out.println(name + " + " + value.toString());
return super.importHandler(obj, name, value);
}

}

private class PoiExcelHandler extends ExcelDataHandlerDefaultImpl<MerchantPoiT> {
@Override
public Object importHandler(MerchantPoiT obj, String name, Object value) {
if (value == null) {
value = "";
}
System.out.println(name + " + " + value.toString());
return super.importHandler(obj, name, value);
}

}

private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount);
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount);
stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount);
stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount);
if(fail) {
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS);
}
}

@Async
public void importExcelData(File file, MallUserInfo user, String importKey) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"姓名", "性别", "手机号*", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "成长值", "积分"});
IExcelDataHandler<CUserBaseInfoT> handler = new AsyncTask.UserExcelHandler();
handler.setNeedHandlerFields(new String[]{"手机号*"});
params.setNeedVerify(true);

ExcelImportResult<CUserBaseInfoT> datalist = null;

try {
datalist = ExcelImportUtil.importExcelMore(file, CUserBaseInfoT.class, params);
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
logger.error(e.getMessage());
// 删除缓存文件
file.delete();
return;
}
// 删除缓存文件
file.delete();

if(datalist == null) {
logger.error("导入模板失败: 模板数据解析失败");
set_redis_value(importKey, "1", "0", "0", "1", true);
return;
}

List<CUserBaseInfoT> successList = datalist.getList();
List<CUserBaseInfoT> failList = datalist.getFailList();

logger.info("验证通过的数量: " + successList.size());
logger.info("验证未通过的数量: " + failList.size());

int total = successList.size() + failList.size();
int all_success = successList.size();
int all_fail = failList.size();

//添加到redis里
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail);

if(successList.size() > 0) {
WxTags wxTagsQ = new WxTags();
List<WxTags> tagList = wxTagsService.findList(wxTagsQ);

try {
successList.parallelStream().forEach(uBase -> {
try {
wxCUserBasicInfoService.importOneMem(importKey, tagList, uBase, user);
} catch (UnknownSessionException ue) {
logger.error("session :"+ue.getMessage());
}
});
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
e.printStackTrace();
logger.error("导入模板失败:"+e.getMessage());
}
}
}

@Async
public void importExcelPoiData(File file, MallUserInfo user, String importKey) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"服务商POI_ID", "POI名称", "省份", "城市", "地址", "经度", "纬度", "高德ID(非必填)",
"已匹配POI_ID", "已匹配POI名称", "已匹配POI省份", "已匹配POI城市", "已匹配POI地址", "未匹配原因", "其他信息"});
IExcelDataHandler<MerchantPoiT> handler = new AsyncTask.PoiExcelHandler();
handler.setNeedHandlerFields(new String[]{"服务商POI_ID","已匹配POI_ID"});
params.setNeedVerify(true);

ExcelImportResult<MerchantPoiT> datalist = null;

try {
datalist = ExcelImportUtil.importExcelMore(file, MerchantPoiT.class, params);
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
logger.error(e.getMessage());
// 删除缓存文件
file.delete();
return;
}
// 删除缓存文件
file.delete();

if(datalist == null) {
logger.error("导入模板失败: 模板数据解析失败");
set_redis_value(importKey, "1", "0", "0", "1", true);
return;
}

List<MerchantPoiT> successList = datalist.getList();
List<MerchantPoiT> failList = datalist.getFailList();

logger.info("验证通过的数量: " + successList.size());
logger.info("验证未通过的数量: " + failList.size());

int total = successList.size() + failList.size();
int all_success = successList.size();
int all_fail = failList.size();

//添加到redis里
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail);

if(successList.size() > 0) {
try {
successList.parallelStream().forEach(poiBase -> {
try {
ttMerchantPoiService.importOneMem(user,importKey, poiBase);
} catch (UnknownSessionException ue) {
logger.error("session :"+ue.getMessage());
}
});
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
e.printStackTrace();
logger.error("导入模板失败:"+e.getMessage());
}
}
}
}

+ 169
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/BillDailyAsyncTask.java View File

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

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxShop;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxBillDailyVo;
import com.iformall.enums.EnumDelStatus;
import com.iformall.enums.EnumShopStatus;
import com.iformall.mapper.WxShopMapper;
import com.iformall.service.WxBillDailyService;
import org.apache.shiro.session.UnknownSessionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
public class BillDailyAsyncTask {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxBillDailyService wxBillDailyService;

@Autowired
StringRedisTemplate stringRedisTemplate;

@Autowired
WxShopMapper wxShopMapper;

private class BillDailyExcelHandler extends ExcelDataHandlerDefaultImpl<WxBillDailyVo> {
@Override
public Object importHandler(WxBillDailyVo obj, String name, Object value) {
if (value == null) {
value = "";
}
System.out.println(name + " + " + value.toString());
return super.importHandler(obj, name, value);
}

}

private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount);
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount);
stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount);
stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount);
if (fail) {
stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS);
}
}

@Async
public void importExcelData(File file, MallUserInfo user, String importKey) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"});
IExcelDataHandler<WxBillDailyVo> handler = new BillDailyAsyncTask.BillDailyExcelHandler();
handler.setNeedHandlerFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"});
params.setNeedVerify(true);

ExcelImportResult<WxBillDailyVo> datalist = null;

try {
datalist = ExcelImportUtil.importExcelMore(file, WxBillDailyVo.class, params);
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
logger.error(e.getMessage());
// 删除缓存文件
file.delete();
return;
}
// 删除缓存文件
file.delete();

if (datalist == null) {
logger.error("导入模板失败: 模板数据解析失败");
set_redis_value(importKey, "1", "0", "0", "1", true);
return;
}

List<WxBillDailyVo> successList = datalist.getList();
List<WxBillDailyVo> failList = datalist.getFailList();
List<WxBillDailyVo> processList = new ArrayList<>();

int fail = 0;
for (WxBillDailyVo vo : successList) {

//店铺
WxShop shop = new WxShop();
shop.setShopNumber(vo.getShopNumber());
shop.updateTenantInfo(user);
shop.setType(vo.getRentShopType());
shop.setStatus(EnumShopStatus.RENT.getCode());
shop.setIsDel(EnumDelStatus.NOT_DEL.getCode());
WxShop wxShop = wxShopMapper.selectOne(new QueryWrapper(shop));
if (wxShop == null) {
logger.error("店铺不存在", vo.toString());
fail++;
continue;
}

String receivePayStr = vo.getReceivePayStr();
long receivePay = new BigDecimal(receivePayStr).multiply(new BigDecimal(100)).longValue();
if (receivePay <= 0) {
logger.error("实际应收金额小于等于0", vo.toString());
fail++;
continue;
}
String payStr = vo.getPayStr();
long pay = new BigDecimal(payStr).multiply(new BigDecimal(100)).longValue();
if (pay < 0) {
logger.error("实收金额小于0", vo.toString());
fail++;
continue;
}
if (receivePay < pay) {
logger.error("实际应收金额小于实收金额", vo.toString());
fail++;
continue;
}
vo.setReceivePay(receivePay);
vo.setPay(pay);
vo.updateTenantInfo(user);
vo.setShopId(wxShop.getId());
vo.setRentShopType(wxShop.getType());
processList.add(vo);
}
logger.info("验证通过的数量: " + processList.size());
logger.info("验证未通过的数量: " + failList.size());

int all_success = processList.size();
int all_fail = failList.size() + fail;
int total = processList.size() + all_fail;

//添加到redis里
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail);

if (processList.size() > 0) {
try {
processList.parallelStream().forEach(billDaily -> {
try {
//插入数据
wxBillDailyService.insertData(billDaily, importKey, user);
} catch (UnknownSessionException ue) {
logger.error("session :" + ue.getMessage());
}
});
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
e.printStackTrace();
logger.error("导入模板失败:" + e.getMessage());
}
}
}
}

+ 342
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/ImportTemplateTask.java View File

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

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxTags;
import com.iformall.domain.vo.CUserBaseInfoT;
import com.iformall.domain.vo.WxBillExcelTemplate;
import com.iformall.domain.vo.WxBillExcelTemplateOther;
import com.iformall.enums.EnumMerchantStatus;
import com.iformall.mapper.WxMerchantMapper;
import com.iformall.service.WxBillAllService;
import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxTagsService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.session.UnknownSessionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.File;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
* @author gongbiao
*/
@Component
public class ImportTemplateTask {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
private WxTagsService wxTagsService;

@Autowired
StringRedisTemplate stringRedisTemplate;

@Autowired
private WxBillAllService wxBillAllService;

@Autowired
private WxMerchantMapper wxMerchantMapper;


@Async
public void importBillData(File file, MallUserInfo user, String importKey) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"商户名*", "费用类型*", "费用属性*", "费用所属期-开始时间*", "费用所属期-结束时间*", "收款金额(元)*", "收款日期*", "截止缴款日*", "收款方式"});
params.setNeedVerify(true);

ExcelImportResult<WxBillExcelTemplate> datalist = null;

try {
datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplate.class, params);
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
logger.error(e.getMessage());
// 删除缓存文件
file.delete();
return;
}
// 删除缓存文件
file.delete();

if (datalist == null) {
logger.error("导入模板失败: 模板数据解析失败");
set_redis_value(importKey, "1", "0", "0", "1", true);
return;
}

List<WxBillExcelTemplate> successList = datalist.getList();
List<WxBillExcelTemplate> failList = datalist.getFailList();

//此处判断商户是否存在
//1 过滤重复商户名
Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName()))
.map(s -> StringUtils.trim(s.getMerchantName()))
.collect(Collectors.toSet());
//2 查询商户名是否存在
Map<String, WxMerchant> merchantMap = new HashMap<>();
merchantSet.parallelStream().forEach(merchantName -> {
WxMerchant wxMerchantQuery = new WxMerchant();
wxMerchantQuery.updateTenantInfo(user);
wxMerchantQuery.setName(merchantName);
wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode());
WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery));
if (wxMerchant != null) {
merchantMap.put(merchantName, wxMerchant);
}
});
//3 计失败条数
List<WxBillExcelTemplate> billSuccessList = new ArrayList<>();
successList.parallelStream().forEach(s -> {
if (StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType()
&& StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime()
&& null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr())
&& null != s.getPayDate() && null != s.getReceiveDate()) {
WxMerchant wxMerchant = merchantMap.get(s.getMerchantName());
if (wxMerchant != null) {
Long merchantId = wxMerchant.getId();
if (merchantId != null) {
s.setMerchantId(merchantId);
Integer type = wxMerchant.getType();
s.setMerchantType(type);
billSuccessList.add(s);
}
}
}
});
int billSuccessSize = billSuccessList.size();
int successSize = successList.size();
int failSize = failList.size();
int total = successSize + failSize;
int failCount = successSize - billSuccessSize;
int all_success = billSuccessSize;
int all_fail = failSize + failCount;

logger.info("验证通过的数量: " + billSuccessSize);
logger.info("验证未通过的数量: " + failSize);

//添加到redis里
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail);

if (billSuccessSize > 0) {
try {
billSuccessList.stream().forEach(bill -> {
try {
wxBillAllService.importBill(importKey, bill, user);
} catch (UnknownSessionException ue) {
logger.error("session :" + ue.getMessage());
}
});
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
e.printStackTrace();
logger.error("导入模板失败:" + e.getMessage());
}
}
}

public void importBillDataOther(File file, MallUserInfo user, String importKey) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"商户名*", "费用类型*", "费用名称*", "费用所属期-开始时间*", "费用所属期-结束时间*", "实际应收金额(元)*", "收款金额(元)*", "收款日期", "截止缴款日*", "收款方式"});
params.setNeedVerify(true);

ExcelImportResult<WxBillExcelTemplateOther> datalist = null;

try {
datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplateOther.class, params);
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
logger.error(e.getMessage());
// 删除缓存文件
file.delete();
return;
}
// 删除缓存文件
file.delete();

if (datalist == null) {
logger.error("导入模板失败: 模板数据解析失败");
set_redis_value(importKey, "1", "0", "0", "1", true);
return;
}

List<WxBillExcelTemplateOther> successList = datalist.getList();
List<WxBillExcelTemplateOther> failList = datalist.getFailList();

//此处判断商户是否存在
//1 过滤重复商户名
Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName()))
.map(s -> StringUtils.trim(s.getMerchantName()))
.collect(Collectors.toSet());
//2 查询商户名是否存在
Map<String, WxMerchant> merchantMap = new HashMap<>();
merchantSet.parallelStream().forEach(merchantName -> {
WxMerchant wxMerchantQuery = new WxMerchant();
wxMerchantQuery.updateTenantInfo(user);
wxMerchantQuery.setName(merchantName);
wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode());
WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery));
if (wxMerchant != null) {
merchantMap.put(merchantName, wxMerchant);
}
});
//3 计失败条数
List<WxBillExcelTemplateOther> billSuccessList = new ArrayList<>();
successList.parallelStream().forEach(s -> {
boolean flag = StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType()
&& StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime()
&& null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr())
&& null != s.getReceiveDate() && StringUtils.isNotEmpty(s.getReceivePayStr());
if (flag) {
double pay = new BigDecimal(s.getPayStr()).doubleValue();
//付款大于0且付款日期不为空说明是更新账单 或者 付款为0且付款日期为空是新增账单 满足其一即可继续
flag = (pay > 0 && null != s.getPayDate()) || (pay == 0 && null == s.getPayDate());
if (flag) {
WxMerchant wxMerchant = merchantMap.get(s.getMerchantName());
if (wxMerchant != null) {
Long merchantId = wxMerchant.getId();
if (merchantId != null) {
s.setMerchantId(merchantId);
Integer type = wxMerchant.getType();
s.setMerchantType(type);
billSuccessList.add(s);
}
}
}
}
});
int billSuccessSize = billSuccessList.size();
int successSize = successList.size();
int failSize = failList.size();
int total = successSize + failSize;
int failCount = successSize - billSuccessSize;
int all_success = billSuccessSize;
int all_fail = failSize + failCount;

logger.info("验证通过的数量: " + billSuccessSize);
logger.info("验证未通过的数量: " + failSize);

//添加到redis里
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail);

if (billSuccessSize > 0) {
try {
billSuccessList.stream().forEach(bill -> {
try {
wxBillAllService.importBillOther(importKey, bill, user);
} catch (UnknownSessionException ue) {
logger.error("session :" + ue.getMessage());
}
});
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
e.printStackTrace();
logger.error("导入模板失败:" + e.getMessage());
}
}
}

private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> {
@Override
public Object importHandler(CUserBaseInfoT obj, String name, Object value) {
if (value == null) {
value = "";
}
System.out.println(name + " + " + value.toString());
return super.importHandler(obj, name, value);
}

}

private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount);
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount);
stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount);
stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount);
if (fail) {
stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS);
}
}

@Async
public void importMemberData(File file, MallUserInfo user, String importKey) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"姓名", "性别", "手机号*", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值", "积分"});
IExcelDataHandler<CUserBaseInfoT> handler = new ImportTemplateTask.UserExcelHandler();
handler.setNeedHandlerFields(new String[]{"手机号*"});
params.setNeedVerify(true);

ExcelImportResult<CUserBaseInfoT> datalist = null;

try {
datalist = ExcelImportUtil.importExcelMore(file, CUserBaseInfoT.class, params);
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
logger.error(e.getMessage());
// 删除缓存文件
file.delete();
return;
}
// 删除缓存文件
file.delete();

if (datalist == null) {
logger.error("导入模板失败: 模板数据解析失败");
set_redis_value(importKey, "1", "0", "0", "1", true);
return;
}

List<CUserBaseInfoT> successList = datalist.getList();
List<CUserBaseInfoT> failList = datalist.getFailList();

logger.info("验证通过的数量: " + successList.size());
logger.info("验证未通过的数量: " + failList.size());

int total = successList.size() + failList.size();
int all_success = successList.size();
int all_fail = failList.size();

//添加到redis里
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail);

if (successList.size() > 0) {
WxTags wxTagsQ = new WxTags();
List<WxTags> tagList = wxTagsService.findList(wxTagsQ);

try {
successList.parallelStream().forEach(uBase -> {
try {
wxCUserBasicInfoService.importOneMem(importKey, tagList, uBase, user);
} catch (UnknownSessionException ue) {
logger.error("session :" + ue.getMessage());
}
});
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
e.printStackTrace();
logger.error("导入模板失败:" + e.getMessage());
}
}
}


}

+ 192
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/MemCouponController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.EnumCouponChannelStatus;
import com.iformall.enums.EnumCouponChannelType;
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.web.bind.annotation.*;

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

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

@Autowired
private WxCouponChannelService couponChannelService;

@Autowired
private MemCouponFromDspService memCouponFromDspService;

@Autowired
private WxCouponService couponService;

@ApiOperation("已投放券列表接口")
@GetMapping("couponChannelList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "会员券管理-已投放列表")
public ResultData couponChannelList(Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] MemCouponController::list");
WxCouponChannel wxCouponChannel = new WxCouponChannel();
if (null == wxCouponChannel) {
wxCouponChannel = new WxCouponChannel();
}
wxCouponChannel.updateTenantInfo(getTenantInfo());
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_H5.getCode());
wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());


if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){
// String coryColumn = "c."+wxCouponChannel.getSortColumns();
// wxCouponChannel.setSortColumns(coryColumn);
// wxCouponChannel.setSortColumn(null);
}else{
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);
}
final PageInfo<WxCouponChannelVo> page = couponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("已发放券列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "会员券管理-列表")
public ResultData list(@ModelAttribute MemCouponFromDsp memCouponFromDsp, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] MemCouponController::list");
if (null == memCouponFromDsp) {
memCouponFromDsp = new MemCouponFromDsp();
} else {
if (StringUtils.isBlank(memCouponFromDsp.getPhone())) {
memCouponFromDsp.setPhone(null);
}
}
memCouponFromDsp.updateTenantInfo(getTenantInfo());
memCouponFromDsp.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
PageInfo<MemCouponFromDsp> page = memCouponFromDspService.listAsPage(memCouponFromDsp, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("检查用户购买券是否可用")
@PostMapping("checkMemCoupon")
@SystemControllerLog(description = "会员券管理-检查")
public ResultData checkMemCoupon(@RequestBody MemCouponFromDsp memCouponFromDsp) {
logger.debug("[" + getIpAddr() + "] MemCouponController::add");
if (StringUtils.isBlank(memCouponFromDsp.getPhone())) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "phone必填");
}
if (memCouponFromDsp.getCouponChannelId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId必填");
}
memCouponFromDsp.updateTenantInfo(getTenantInfo());
WxCouponChannel couponChannel = couponChannelService.getById(memCouponFromDsp.getCouponChannelId(),getTenantInfo().getTenantId());
if (memCouponFromDsp.getCouponId() == null) {
memCouponFromDsp.setCouponId(couponChannel.getCouponId());
}
// 1. 检查券是否已超限, 无剩余库存
WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),memCouponFromDsp.getTenantId());
if (coupon == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId());
}
MemCouponFromDsp couponQ = new MemCouponFromDsp();
couponQ.updateTenantInfo(memCouponFromDsp);
couponQ.setCouponId(memCouponFromDsp.getCouponId());
couponQ.setStatus(0);
Integer couponCount = memCouponFromDspService.countByInfo(couponQ);
if (coupon.getRemainInventory() <= couponCount) {
return new ResultData(ErrorCode.REMAIN_IS_EMPTY);
}
// 2. 检查此会员是否已超限, 达到券购买限制
couponQ = new MemCouponFromDsp();
couponQ.updateTenantInfo(memCouponFromDsp);
couponQ.setPhone(memCouponFromDsp.getPhone());
couponQ.setCouponId(memCouponFromDsp.getCouponId());
couponCount = memCouponFromDspService.countByInfo(couponQ);
if (coupon.getUseLimitQuantity() <= couponCount) {
return new ResultData(ErrorCode.ORDER_IS_LIMITED);
}
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("add")
@SystemControllerLog(description = "会员券管理-添加")
public ResultData add(@RequestBody MemCouponFromDsp memCouponFromDsp) {
logger.debug("[" + getIpAddr() + "] MemCouponController::add");
if (StringUtils.isBlank(memCouponFromDsp.getPhone())) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "phone必填");
}
if (memCouponFromDsp.getCouponChannelId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId必填");
}
memCouponFromDsp.updateTenantInfo(getTenantInfo());
WxCouponChannel couponChannel = couponChannelService.getById(memCouponFromDsp.getCouponChannelId(),getTenantInfo().getTenantId());
if (memCouponFromDsp.getCouponId() == null) {
memCouponFromDsp.setCouponId(couponChannel.getCouponId());
}
// 1. 检查券是否已超限, 无剩余库存
WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),couponChannel.getTenantId());
if (coupon == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId());
}
MemCouponFromDsp couponQ = new MemCouponFromDsp();
couponQ.updateTenantInfo(memCouponFromDsp);
couponQ.setCouponId(memCouponFromDsp.getCouponId());
couponQ.setStatus(0);
Integer couponCount = memCouponFromDspService.countByInfo(couponQ);
if (coupon.getRemainInventory() <= couponCount) {
return new ResultData(ErrorCode.REMAIN_IS_EMPTY);
}
// 2. 检查此会员是否已超限, 达到券购买限制
couponQ = new MemCouponFromDsp();
couponQ.updateTenantInfo(memCouponFromDsp);
couponQ.setPhone(memCouponFromDsp.getPhone());
couponQ.setCouponId(memCouponFromDsp.getCouponId());
couponCount = memCouponFromDspService.countByInfo(couponQ);
if (coupon.getUseLimitQuantity() <= couponCount) {
return new ResultData(ErrorCode.ORDER_IS_LIMITED);
}
// 3. 保存
memCouponFromDsp.setStatus(0);
memCouponFromDspService.saveOrUpdate(memCouponFromDsp);
return new ResultData();
}

@ApiOperation("根据手机号查询接口")
@GetMapping("/findByPhone")
@ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true)
@SystemControllerLog(description = "会员券管理-根据手机号查询接口")
public ResultData findByPhone(String phone) {
logger.debug("[" + getIpAddr() + "] MemCouponController::findByPhone");
if (StringUtils.isEmpty(phone)) {
return new ResultData(new ArrayList<MemCouponFromDsp>());
}
MemCouponFromDsp memQ = new MemCouponFromDsp();
memQ.updateTenantInfo(getTenantInfo());
memQ.setPhone(phone);
List<MemCouponFromDsp> memCouponFromDsps = memCouponFromDspService.getList(memQ);
return new ResultData(memCouponFromDsps);
}
}

+ 111
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/UserBasicInfoAddressController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("userBasicInfoAddress")
@Api(description = "会员地址相关接口")
public class UserBasicInfoAddressController extends BaseController {

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

@Autowired
private UserBasicInfoAddressService userBasicInfoAddressService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "会员地址-列表")
public ResultData list(@ModelAttribute UserBasicInfoAddress userBasicInfoAddress, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] UserBasicInfoAddressController::list");
if (null == userBasicInfoAddress) {
userBasicInfoAddress = new UserBasicInfoAddress();
}
if(userBasicInfoAddress.getUserId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "用户ID为空");
}
userBasicInfoAddress.undateFinalTenantId(getTenantInfo());
PageInfo<UserBasicInfoAddress> page = userBasicInfoAddressService.listAsPage(userBasicInfoAddress, pageNum, pageSize);
return new ResultData(page);
}

@PostMapping("saveOrUpdate")
@SystemControllerLog(description = "会员地址-保存更新")
public ResultData saveOrUpdate(@RequestBody UserBasicInfoAddress userBasicInfoAddress) {
logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::saveOrUpdate");
if(userBasicInfoAddress == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(userBasicInfoAddress.getUserId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}
userBasicInfoAddress.undateFinalTenantId(getTenantInfo());
userBasicInfoAddressService.saveOrUpdate(userBasicInfoAddress);
return new ResultData();
}

@PostMapping("setUpDefault")
@SystemControllerLog(description = "会员地址-默认")
public ResultData setUpDefault(@RequestBody UserBasicInfoAddress userBasicInfoAddress) {
logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::setUpDefault");
if(userBasicInfoAddress == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(userBasicInfoAddress.getId() == null || userBasicInfoAddress.getUserId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "用户ID或者Id为空");
}
userBasicInfoAddress.undateFinalTenantId(getTenantInfo());
userBasicInfoAddressService.updateDefault(userBasicInfoAddress);
return new ResultData();
}

@ApiOperation("消息模板-删除")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
@SystemControllerLog(description = "消息验证模板-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::delete");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "Id为空");
}
UserBasicInfoAddress userBasicInfoAddress = new UserBasicInfoAddress();
userBasicInfoAddress.setId(id);
userBasicInfoAddress.undateFinalTenantId(getTenantInfo());
userBasicInfoAddressService.deleteById(userBasicInfoAddress);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("消息模板-查询")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true)
@SystemControllerLog(description = "消息验证模板-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::findById");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "Id为空");
}
UserBasicInfoAddress userBasicInfoAddress = new UserBasicInfoAddress();
userBasicInfoAddress.setId(id);
userBasicInfoAddress.undateFinalTenantId(getTenantInfo());
userBasicInfoAddressService.findById(userBasicInfoAddress);
return new ResultData(Result.SUCCESS, "查询成功", null);
}

}

+ 675
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java View File

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

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.dto.WxCUserBasicInfoFilterDto;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.UserTradeRecordVo;
import com.iformall.enums.EnumAssignTagsTrigger;
import com.iformall.enums.EnumCouponOrderStatus;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxCouponMerchantMapper;
import com.iformall.mapper.WxMerchantMapper;
import com.iformall.service.*;
import com.iformall.utils.Constant;
import com.iformall.utils.DateUtils;
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.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

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

@Autowired
private String fmUploadDir;

@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
private WxCUserBasicChildService wxCUserBasicChildService;

@Autowired
private WxCUserTagsService wxCUserTagsService;

@Autowired
private WxCUserCarService wxCUserCarService;

@Autowired
private WxCouponOrderService wxCouponOrderService;

@Autowired
private WxCouponService wxCouponService;

@Autowired
private WxLevelConfigService wxLevelConfigService;

@Autowired
WxCarPayRecordService wxCarPayRecordService;

@Autowired
StringRedisTemplate stringRedisTemplate;

@Autowired
private AsyncTask asyncTask;

@Autowired
private ExcelService excelService;

@Autowired
private WxMerchantMapper wxMerchantMapper;

@Autowired
private WxCreditHistoryService wxCreditHistoryService;
@Autowired
WxCouponMerchantMapper wxCouponMerchantMapper;

private void updateLevelParam(WxCUserBasicInfo info) {
List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantInfo(getTenantInfo());
levelList = levelList.stream()
.sorted(Comparator.comparing(WxLevelConfig::getPoints))
.collect(Collectors.toList());
for (int levelIndex = 0; levelIndex < levelList.size(); levelIndex++) {
WxLevelConfig l = levelList.get(levelIndex);
if(l.getId().equals(info.getLevelId())){
Integer levelStartScore = l.getPoints();
Integer levelEndScore = levelIndex + 1 < levelList.size() ? levelList.get(levelIndex + 1).getPoints() : null;
info.setLevelStartScore(levelStartScore);
info.setLevelEndScore(levelEndScore);
break;
}
}
}

private void setUserInfoLevel(WxCUserBasicInfo info) {

if (info.getPoins() == null || info.getPoins() == 0) {
info.setLevel(WxLevelConfigService.DEFAULT_LEVEL);
} else {
info.setLevel(WxLevelConfigService.DEFAULT_LEVEL);
List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantInfo(getTenantInfo());
for (WxLevelConfig levelConfig : levelList) {
if (info.getPoins() >= levelConfig.getPoints()) {
info.setLevel(levelConfig.getLevel());
}
}
}
}

private void setUserChildren(WxCUserBasicInfo info) {
WxCUserBasicChild uChild = new WxCUserBasicChild();
uChild.setTenantId(info.getFinalTenantId());
uChild.setCUserId(info.getId());
info.setChildrenList(wxCUserBasicChildService.findList(uChild));

}

private void setUserInfoTag(WxCUserBasicInfo info) {

if (info.getTagId() != null) {
WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId(),info.getFinalTenantId());
if (uTag != null && StringUtils.isNotBlank(uTag.getTags())) {
List<Long> ids = JSONObject.parseArray(uTag.getTags(), Long.class);
info.setTagsList(wxCUserTagsService.findTagList(getTenantInfo(), ids));
}
}
}


private void setUserInfoCar(WxCUserBasicInfo info) {
WxCUserCar wxCUserCar = new WxCUserCar();
wxCUserCar.setCUserId(info.getId());
List<WxCUserCar> list = wxCUserCarService.getList(wxCUserCar);
if (list.size() > 0) {
info.setCarList(list.stream().map(p -> p.getCarNumber()).collect(Collectors.toList()));
}

}

private void setUserInfoCarCount(WxCUserBasicInfo info) {
WxCUserCar wxCUserCar = new WxCUserCar();
wxCUserCar.setCUserId(info.getId());
info.setCarCount(wxCUserCarService.countUserCar(wxCUserCar));
}

private void setCreditSumDate(WxCUserBasicInfo info){
WxCreditHistory wxCreditHistory = new WxCreditHistory();
wxCreditHistory.setTenantId(info.getFinalTenantId());
wxCreditHistory.setCUserId(info.getId());
wxCreditHistory.setStartTime(info.getCreditStartTime());
wxCreditHistory.setEndTime(info.getCreditEndTime());
info.setAddCredit(wxCreditHistoryService.getAddCreditSummary(wxCreditHistory));
info.setLesCredit(wxCreditHistoryService.getLesCreditSummary(wxCreditHistory));
}

@TenantIgnore
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "会员管理-列表")
public ResultData list(@ModelAttribute WxCUserBasicInfo wxCUserBasicInfo, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::list");
if (null == wxCUserBasicInfo) {
wxCUserBasicInfo = new WxCUserBasicInfo();
} else {
if (StringUtils.isBlank(wxCUserBasicInfo.getPhone())) {
wxCUserBasicInfo.setPhone(null);
}
if (StringUtils.isBlank(wxCUserBasicInfo.getName())) {
wxCUserBasicInfo.setName(null);
}
if (wxCUserBasicInfo.getLevelId() != null){
updateLevelParam(wxCUserBasicInfo);
}
}
wxCUserBasicInfo.setSortColumns(BaseEntity.SortField.wcubiActiveTime_DESC);
PageInfo<WxCUserBasicInfo> page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageNum, pageSize);

if (page.getSize() > 0) {
for (WxCUserBasicInfo info : page.getList()) {
setUserInfoLevel(info);
setUserInfoCarCount(info);
info.setCreditStartTime(wxCUserBasicInfo.getCreditStartTime());
info.setCreditEndTime(wxCUserBasicInfo.getCreditEndTime());
setCreditSumDate(info);
}
}
return new ResultData(page);
}

private int checkUniquePhone(String phone, TenantEntity tenantEntity) {
WxCUserBasicInfo baseInfoQ = new WxCUserBasicInfo();
baseInfoQ.setPhone(phone);
baseInfoQ.setFinalTenantId(tenantEntity.getFinalTenantId());
return wxCUserBasicInfoService.countUser(baseInfoQ);
}

@TenantIgnore
@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "会员管理-更新")
public ResultData update(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::update");
TenantEntity tenantEntity = getTenantInfo();
WxCUserBasicInfo oldInfo = wxCUserBasicInfoService.getById(wxCUserBasicInfo.getId(),tenantEntity.getFinalTenantId());
if (!oldInfo.getPhone().equals(wxCUserBasicInfo.getPhone())) {
if (checkUniquePhone(wxCUserBasicInfo.getPhone(), tenantEntity) > 0) {
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(), "手机号已存在");
}
}
if(wxCUserBasicInfo.getBirthdate() != null && wxCUserBasicInfo.getBirthdate().after(new Date())){
return new ResultData(ErrorCode.USER_BIRTHDATE_AFTER.getCode(), "出生日期大于当前日期");
}
if (StringUtils.isNotBlank(wxCUserBasicInfo.getTagIds())) {
WxCUserTags record = new WxCUserTags();
record.setUserId(oldInfo.getId());
// record.updateTenantInfo(tenantEntity);
record.setTenantId(oldInfo.getFinalTenantId());
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());
}
wxCUserBasicInfo.setFinalTenantId(tenantEntity.getFinalTenantId());
wxCUserBasicInfoService.update(wxCUserBasicInfo);
wxCUserBasicInfo.updateTenantInfo(oldInfo);
wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT, wxCUserBasicInfo,tenantEntity,null);
return new ResultData();
}

// @ApiOperation("根据id删除接口")
// @GetMapping("/del")
// @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
// @SystemControllerLog(description = "会员管理-删除")
// public ResultData delete(Long id) {
// logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::delete");
// wxCUserBasicInfoService.deleteById(id);
// return new ResultData(Result.SUCCESS, "删除成功", null);
// }

@TenantIgnore
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "会员管理-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::findById");
WxCUserBasicInfo info = wxCUserBasicInfoService.getById(id,getTenantInfo().getFinalTenantId());

if (info == null)
return new ResultData(ErrorCode.USER_IS_EMPTY);
setUserInfoTag(info);
setUserInfoLevel(info);
setUserInfoCar(info);
setUserChildren(info);
return new ResultData(info);
}

@TenantIgnore
@ApiOperation("根据userId查询交易记录接口")
@GetMapping("/findOrderCouponByUserId")
@ApiImplicitParam(name = "userId", value = "userId", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "会员管理-userId查询交易记录")
public ResultData findOrderCouponByUserId(Long userId, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::findOrderCouponByUserId");
WxCouponOrder corder = new WxCouponOrder();
corder.setCUserId(userId);
corder.updateTenantInfo(getTenantInfo());
corder.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
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.getTenantId());
c.setCouponName(coupon.getTitle());
c.setSalePrice(coupon.getPrice());

if(c.getCouponId() != null) {
List<Long> couponIds = new ArrayList<Long>();
couponIds.add(c.getCouponId());
List<Long> merchantIds = wxCouponMerchantMapper.findMerchantByProductIds(corder.getTenantId(), couponIds);
if (null != merchantIds && merchantIds.size() > 0 ) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("ids", merchantIds);
WxMerchant w = wxMerchantMapper.findByTrade(param);
if (w != null) {
c.setMerchantName(w.getName());
}
}
}
}
}
return new ResultData(Result.SUCCESS, "查询成功", page);
}

@TenantIgnore
@ApiOperation("导出根据userId查询交易记录接口")
@GetMapping("/exportOrderCouponByUserId")
@ApiImplicitParam(name = "userId", value = "userId", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "会员管理-userId查询交易记录")
public void exportOrderCouponByUserId(HttpServletRequest request, HttpServletResponse response,Long userId) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::exportOrderCouponByUserId");
WxCouponOrder corder = new WxCouponOrder();
corder.setCUserId(userId);
corder.updateTenantInfo(getTenantInfo());
corder.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
PageInfo<WxCouponOrder> page = wxCouponOrderService.listAsPage(corder, 1, Integer.MAX_VALUE);
//if (page.getSize() > 0) {
List<WxCouponOrder> list = page.getList();
for (WxCouponOrder c : list) {
WxCoupon coupon = wxCouponService.getById(c.getCouponId(),c.getTenantId());
c.setCouponName(coupon.getTitle());
c.setSalePrice(coupon.getPrice());
}

List<UserTradeRecordVo> datalist = new ArrayList<>();
for (WxCouponOrder wxCouponOrder:list) {
UserTradeRecordVo userTradeRecordVo = new UserTradeRecordVo();
userTradeRecordVo.setCouponName(wxCouponOrder.getCouponName());
BigDecimal b = new BigDecimal(wxCouponOrder.getSalePrice());
userTradeRecordVo.setPrice(b.divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP).toString());
b = new BigDecimal(wxCouponOrder.getCouponPrice());
userTradeRecordVo.setSale(b.divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP).toString());
userTradeRecordVo.setStatus(EnumCouponOrderStatus.getEnum(wxCouponOrder.getCouponOrderStatus()).getMessage());
userTradeRecordVo.setTradeTime(DateUtils.formatDateTime(wxCouponOrder.getCreateDate()));
datalist.add(userTradeRecordVo);
}
excelService.exportExcel(datalist, null, "会员交易记录", UserTradeRecordVo.class, "会员交易记录.xlsx", response, false);
//}
}

@TenantIgnore
@ApiOperation("会员记录导出总数")
@GetMapping("/exportDataCount")
@SystemControllerLog(description = "会员管理-会员记录导出总数")
public ResultData exportDataCount(@ModelAttribute WxCUserBasicInfo basicInfo) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::exportDataCount");
if(basicInfo == null) {
basicInfo = new WxCUserBasicInfo();
} else {
if (StringUtils.isBlank(basicInfo.getPhone())) {
basicInfo.setPhone(null);
}
if (StringUtils.isBlank(basicInfo.getName())) {
basicInfo.setName(null);
}
}
TenantEntity tenantInfo = getTenantInfo();
basicInfo.setTenantId(tenantInfo.getTenantId());
basicInfo.setFinalTenantId(tenantInfo.getFinalTenantId());
int exportDataCount = wxCUserBasicInfoService.exportDataCount(basicInfo);
return new ResultData(exportDataCount);


}

@TenantIgnore
@ApiOperation("会员记录导出")
@GetMapping("/exportData")
@SystemControllerLog(description = "会员管理-会员记录导出")
public void exportData(@ModelAttribute WxCUserBasicInfo basicInfo, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::exportData");
if(basicInfo == null) {
basicInfo = new WxCUserBasicInfo();
} else {
if (StringUtils.isBlank(basicInfo.getPhone())) {
basicInfo.setPhone(null);
}
if (StringUtils.isBlank(basicInfo.getName())) {
basicInfo.setName(null);
}
}
TenantEntity tenantInfo = getTenantInfo();
basicInfo.setTenantId(tenantInfo.getTenantId());
basicInfo.setFinalTenantId(tenantInfo.getFinalTenantId());
wxCUserBasicInfoService.exportData(basicInfo, request, response);
}

@TenantIgnore
@RequestMapping("/exportTemplate")
@SystemControllerLog(description = "会员管理-导出模板")
public void exportTemplate(HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::exportTemplate");

wxCUserBasicInfoService.exportTemplate(request, response);

}

private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount);
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount);
stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount);
stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount);
if(fail) {
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS);
}
}

@TenantIgnore
@PostMapping(value = "/importTemplate", consumes = "multipart/*")
@SystemControllerLog(description = "会员管理-导入数据")
public ResultData importTemplate(@RequestParam("file") MultipartFile mFile) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::importTemplate");
if (mFile.isEmpty()) {
throw new MallinkException(Result.ERROR, "上传文件不能为空");
}
//得到当前用户ID
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = Constant.importMemPrev + userId;

//查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入
Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount");
if (allCount) {
return new ResultData(Result.SUCCESS, "模板正在导入");
}

stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + "");
stringRedisTemplate.expire(importKey,30,TimeUnit.MINUTES);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "");

String fpath = fmUploadDir;
File targetFile = new File(fpath);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
String fileName = "1.xlsx";
int dot = mFile.getOriginalFilename().lastIndexOf('.');
fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length());

File lFile = new File(fpath + File.separator + fileName);

FileOutputStream fos = null;
BufferedInputStream fs = null;
try {
fos = new FileOutputStream(lFile);
fs = (BufferedInputStream) mFile.getInputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fs.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
fos.close();
fs.close();
} catch (Exception e) {
stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
}
}
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
}
}
}

asyncTask.importExcelData(lFile, user, importKey);

return new ResultData(Result.SUCCESS, "模板正在导入");
}

@TenantIgnore
@GetMapping("/queryTemplateCount")
@SystemControllerLog(description = "会员管理-导入数据查询")
public ResultData queryTemplateCount() {
String importKey = Constant.importMemPrev + getUser().getId();
Map entries = stringRedisTemplate.opsForHash().entries(importKey);
logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>1");
if (entries.size() < 4) {
entries.clear();
return new ResultData(Result.SUCCESS, "ok", entries);
}
String allCount = entries.get("allCount").toString();
String allSuccessCount = entries.get("allSuccessCount").toString();
String processCount = entries.get("processCount").toString();
String failCount = entries.get("failCount").toString();

if (StringUtils.isNotBlank(failCount) && allCount.equals(failCount)) {//stringRedisTemplate.expire(userId,1,TimeUnit.SECONDS);
logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>2");
//完全失败
stringRedisTemplate.opsForHash().delete(importKey, "allCount");
stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount");
stringRedisTemplate.opsForHash().delete(importKey, "processCount");
stringRedisTemplate.opsForHash().delete(importKey, "failCount");
return new ResultData(ErrorCode.MEM_IMPORT_ERR);
}
//导入完成
if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(processCount)) {
ResultData ok = new ResultData(Result.SUCCESS, "ok", entries);
stringRedisTemplate.opsForHash().delete(importKey, "allCount");
stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount");
stringRedisTemplate.opsForHash().delete(importKey, "processCount");
stringRedisTemplate.opsForHash().delete(importKey, "failCount");
return ok;
}
return new ResultData(Result.SUCCESS, "查询成功", entries);
}

@TenantIgnore
@ApiOperation("进出场车辆分页列表接口")
@GetMapping("carPayList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "endDate", value = "结束时间", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "isPay", value = "是否缴费 1是", dataType = "int", paramType = "query")
})
@SystemControllerLog(description = "会员管理-进出场车辆分页列表")
public ResultData carPayList(@ModelAttribute WxCarPayRecord record, Integer pageNum, Integer pageSize){
record.updateTenantInfo(getTenantInfo());
return new ResultData(wxCarPayRecordService.findCarPayListByPage(record,pageNum,pageSize));
}

@TenantIgnore
@ApiOperation("停车会员记录导出")
@GetMapping("/exportCarPayData")
@ApiImplicitParams({
@ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "endDate", value = "结束时间", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "isPay", value = "是否缴费 1是", dataType = "int", paramType = "query")
})
@SystemControllerLog(description = "会员管理-停车会员记录导出")
public void exportCarPayData(@ModelAttribute WxCarPayRecord record,HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::exportData");
record.updateTenantInfo(getTenantInfo());
wxCUserBasicInfoService.exportCarPayData(record, request, response);

}

@TenantIgnore
@ApiOperation("根据手机号查询接口")
@GetMapping("/findByPhone")
@ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true)
@SystemControllerLog(description = "会员管理-根据手机号查询接口")
public ResultData findByPhone(String phone) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::findByPhone");
if (StringUtils.isEmpty(phone)) {
return new ResultData(new ArrayList<WxCUserBasicInfo>());
}
List<WxCUserBasicInfo> wxCUserBasicInfoList = wxCUserBasicInfoService.findByPhone(getTenantInfo(),phone);
WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo();
if (wxCUserBasicInfoList != null && wxCUserBasicInfoList.size() > 0) {
wxCUserBasicInfo = wxCUserBasicInfoList.get(0);
}
return new ResultData(wxCUserBasicInfo);
}

@TenantIgnore
@ApiOperation("获取会员过滤器")
@GetMapping("/listFilter")
@SystemControllerLog(description = "会员管理-获取会员过滤器")
public ResultData listFilter() {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::listFilter");
return new ResultData(wxCUserBasicInfoService.listFilters(getTenantInfo()));
}

@TenantIgnore
@ApiOperation("会员过滤器获取数量")
@PostMapping("/countByFilter")
@SystemControllerLog(description = "会员管理-会员过滤器获取数量")
public ResultData countByFilter(@RequestBody List<WxCUserBasicInfoFilterDto> filterList) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::listFilter");
return new ResultData(wxCUserBasicInfoService.countByFilter(getTenantInfo(),filterList));
}

@TenantIgnore
@ApiOperation("获取会员过滤器")
@PostMapping("/listByFilter")
@SystemControllerLog(description = "会员管理-会员过滤器获取")
public ResultData listByFilter(@RequestParam List<WxCUserBasicInfoFilterDto> filterList) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::listFilter");
return new ResultData(wxCUserBasicInfoService.listByFilter(getTenantInfo(),filterList));
}

@TenantIgnore
@ApiOperation("根据ID锁定")
@PostMapping("/updateStatus")
@SystemControllerLog(description = "会员管理-根据ID锁定")
public ResultData updateStatus(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::updateStatus");
if (null == wxCUserBasicInfo.getId()) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "id不能为空");
}
if (null == wxCUserBasicInfo.getStatus()) {

}
return wxCUserBasicInfoService.updateStatus(wxCUserBasicInfo);
}

@TenantIgnore
@ApiOperation("根据手机号迁移")
@PostMapping("/cuserOldToNew")
@SystemControllerLog(description = "会员管理-迁移数据")
public ResultData cuserOldToNew(@RequestBody Map<String,String> map) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::cuserOldToNew");
TenantEntity tenantInfo = getTenantInfo();
if(StringUtils.isBlank(tenantInfo.getTenantId())){
return new ResultData(ErrorCode.SYS_AUTH_ERROR);
}
String oldCuserPhone = (String) map.get("oldCuserPhone");
String newCuserPhone = (String) map.get("newCuserPhone");
if(StringUtils.isNotBlank(oldCuserPhone) && StringUtils.isNotBlank(newCuserPhone)){
WxCUserBasicInfo oldCuser = wxCUserBasicInfoService.findInfoByPhone(tenantInfo, oldCuserPhone);
WxCUserBasicInfo newCuser = wxCUserBasicInfoService.findInfoByPhone(tenantInfo, newCuserPhone);
if(null != oldCuser && null != newCuser){
if(!oldCuserPhone.equals(newCuserPhone)){
wxCUserBasicInfoService.cuserOldToNew(oldCuser.getId(),newCuser.getId(),tenantInfo);
return new ResultData();
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"同一个用户");
}
}else{
return new ResultData(ErrorCode.USER_IS_EMPTY);
}
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
}

}

+ 82
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserCarController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
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;

@TenantIgnore
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "停车-列表")
public ResultData list(@ModelAttribute WxCUserCar wxCUserCar, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCUserCarController::list");
if (null == wxCUserCar) wxCUserCar = new WxCUserCar();
wxCUserCar.updateTenantInfo(getTenantInfo());
final PageInfo<WxCUserCar> page = wxCUserCarService.listAsPage(wxCUserCar, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "停车-新增")
public ResultData add(@RequestBody WxCUserCar wxCUserCar) {
logger.debug("[" + getIpAddr() + "] WxCUserCarController::add");
//Assert.notNull(wxCUserCar.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCUserCarService.saveOrUpdate(wxCUserCar);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "停车-更新")
public ResultData update(@RequestBody WxCUserCar wxCUserCar) {
logger.debug("[" + getIpAddr() + "] WxCUserCarController::update");
wxCUserCarService.saveOrUpdate(wxCUserCar);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "停车-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCUserCarController::delete");
wxCUserCarService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "停车-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCUserCarController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCUserCarService.getById(id));
}


}

+ 81
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.controller.base.BaseController;
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)})
@SystemControllerLog(description = "用户管理-列表")
public ResultData list(@ModelAttribute WxCUser wxCUser, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCUserController::list");
if (null == wxCUser) wxCUser = new WxCUser();
final PageInfo<WxCUser> page = wxCUserService.listAsPage(wxCUser, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "用户管理-新增")
public ResultData add(@RequestBody WxCUser wxCUser) {
logger.debug("[" + getIpAddr() + "] WxCUserController::add");
//Assert.notNull(wxCUser.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCUserService.saveOrUpdate(wxCUser);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "用户管理-更新")
public ResultData update(@RequestBody WxCUser wxCUser) {
logger.debug("[" + getIpAddr() + "] WxCUserController::update");
wxCUserService.saveOrUpdate(wxCUser);
return new ResultData();
}

// @ApiOperation("根据id删除接口")
// @GetMapping("/del")
// @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
// @SystemControllerLog(description = "用户管理-删除")
// public ResultData delete(Long id) {
// logger.debug("[" + getIpAddr() + "] WxCUserController::delete");
// wxCUserService.deleteById(id);
// return new ResultData(Result.SUCCESS, "删除成功", null);
// }

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "用户管理-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCUserController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCUserService.getById(id,getTenantInfo().getTenantId()));
}


}

+ 444
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserDataController.java View File

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

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 com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.dto.MarkingCouponDataReportDto;
import com.iformall.domain.po.WxCouponOrder;
import com.iformall.domain.po.WxUserVisit;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumAppPlat;
import com.iformall.service.*;
import com.iformall.service.cuser.CUserServiceFactory;
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 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 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 CUserServiceFactory cuserFactory;
@Autowired
private WxUserVisitService wxUserVisitService;
@Autowired
private WxCouponOrderService wxCouponOrderService;
@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;
@Autowired
private WxMallService wxMallService;

@TenantIgnore
@GetMapping("findUserCountData")
@ApiOperation("查询用户数量接口")
@SystemControllerLog(description = "会员首页-报表数据-查询用户数量接口")
public ResultData findUserCountData(Integer plat) {
logger.debug("[" + getIpAddr() + "] WxCUserDataController::findUserCountData");
if(plat == null){
plat = EnumAppPlat.WX.getCode();
}
TenantEntity tenantEntity = getTenantInfo();
WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto();
dto.updateTenantInfo(tenantEntity);
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_YEAR, -29);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
dto.setStartTime(c.getTime());
List<UserStructureVo> list = cuserFactory.getCUserService(EnumAppPlat.getByCode(plat)).findCountData(dto);
Map<String,Long> countDate = new HashMap<>();
for (UserStructureVo vo:list) {
countDate.put(vo.getName(),vo.getCount());
}

long todayCount = 0;
long yesterdayCount = 0;
long dayOfWeekCount = 0;
List<UserStructureVo> weekVos = new ArrayList<>();//周会员数
List<UserStructureVo> monthVos = new ArrayList<>();//周会员数

for (int i = 29, sortNum = 0; i >= 0; i--) {
c.clear();
c.setTime(new Date());
c.add(Calendar.DAY_OF_YEAR, -i);
UserStructureVo vo = new UserStructureVo();
vo.setName(new SimpleDateFormat("MM/dd").format(c.getTime()));
vo.setSortNum(sortNum++);
vo.setCount(countDate.get(vo.getName())==null?0:countDate.get(vo.getName()));
if (i <= 7) {
UserStructureVo vow = new UserStructureVo();
vow.setSortNum(vo.getSortNum());
vow.setName(vo.getName());
vow.setCount(vo.getCount());

if (i == 1) {
yesterdayCount = vow.getCount();
}
if (i == 0) {
todayCount = vow.getCount();
}
if (i == 7) {
dayOfWeekCount = vow.getCount();
} else {
weekVos.add(vow);
}
}
monthVos.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());
}
String weekPercentage = "--";
if (dayOfWeekCount > 0) {
Long count = todayCount - dayOfWeekCount;
weekPercentage = nf.format(count.doubleValue() / new Double(dayOfWeekCount).doubleValue());
}
Map<String, Object> map = new HashMap<>();
map.put("weekVos", weekVos);//周用户增加数列表
map.put("monthVos", monthVos);//月用户增加数列表
map.put("dayPercentage", dayPercentage);//日环比
map.put("weekPercentage", weekPercentage);//周同比

return new ResultData(map);
}

@TenantIgnore
@GetMapping("findUserAddCount")
@ApiOperation("查询用户增长 总数,今日,近一周")
@SystemControllerLog(description = "会员首页-报表数据-查询用户增长")
public ResultData findUserAddCount(Integer plat) {
logger.debug("[" + getIpAddr() + "] WxCUserDataController::findUserAddCount");
if(plat == null){
plat = EnumAppPlat.WX.getCode();
}
TenantEntity tenantEntity = getTenantInfo();
WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto();
dto.updateTenantInfo(tenantEntity);
long allCount = cuserFactory.getCUserService(EnumAppPlat.getByCode(plat)).findCount(dto);
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
dto.setStartTime(c.getTime());
long todayCount = cuserFactory.getCUserService(EnumAppPlat.getByCode(plat)).findCount(dto);
c.add(Calendar.DAY_OF_YEAR, -7);
dto.setStartTime(c.getTime());
long weekCount = cuserFactory.getCUserService(EnumAppPlat.getByCode(plat)).findCount(dto);

Map<String, Object> map = new HashMap<>();
map.put("allCount", allCount);// 用户总数
map.put("todayCount", todayCount);// 今日新增用户
map.put("weekCount", weekCount);// 近一周新增用户
return new ResultData(map);
}

@TenantIgnore
@GetMapping("findBasicUserAddCount")
@ApiOperation("查询会员增长 总数,今日,近一周")
@SystemControllerLog(description = "会员首页-报表数据-查询会员增长")
public ResultData findBasicUserAddCount() {
logger.debug("[" + getIpAddr() + "] WxCUserDataController::findBasicUserAddCount");
TenantEntity tenantEntity = getTenantInfo();
WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto();
dto.updateTenantInfo(tenantEntity);
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);
dto.setStartTime(c.getTime());
long todayCount = wxCUserBasicInfoService.findCount(dto);
c.add(Calendar.DAY_OF_YEAR, -7);
dto.setStartTime(c.getTime());
long weekCount = wxCUserBasicInfoService.findCount(dto);;

Map<String, Object> map = new HashMap<>();
map.put("allCount", allCount);// 会员总数
map.put("todayCount", todayCount);// 今日新增会员
map.put("weekCount", weekCount);// 近一周新增会员
return new ResultData(map);
}

@TenantIgnore
@ApiOperation("查询用户活跃量")
@GetMapping("findUserVisitData")
@SystemControllerLog(description = "会员首页-报表数据-查询用户活跃量")
public ResultData findUserVisitData() {
logger.debug("[" + getIpAddr() + "] WxCUserDataController::findUserVisitData");
TenantEntity tenantEntity = getTenantInfo();
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, -28);
Date startTime = c.getTime();
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("tenantId", tenantEntity.getTenantId());
if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) {
params.put("parentTenantId", tenantEntity.getParentTenantId());
}
MarkingCouponDataReportDto markingCouponDataReportDto = new MarkingCouponDataReportDto();
markingCouponDataReportDto.updateTenantInfo(tenantEntity);
markingCouponDataReportDto.setStartTime(startTime);
markingCouponDataReportDto.setEndTime(endTime);
List<TouchUsersReportVo> list = wxUserVisitService.touchUsersReportList(markingCouponDataReportDto);
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

long yesterdayCount = 0;//昨天活跃数
long beforeYesterdayCount = 0;//前天活跃数
long dayOfWeekCount = 0;//上周周x数
for (int i = 29, sortNum = 0; 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(sortNum++);
if (dateMap.get(dayStr) != null) {
TouchUsersReportVo rv = dateMap.get(dayStr);
Long l = new Long((long) rv.getUv());
vo.setCount(l);
} else {
vo.setCount(0);
}

if (i <= 7) {
UserStructureVo vow = new UserStructureVo();
vow.setName(vo.getName());
vow.setSortNum(vo.getSortNum());
vow.setCount(vo.getCount());

if (i == 0) {
yesterdayCount = vow.getCount();
}
if (i == 1) {
beforeYesterdayCount = vow.getCount();
}
if (i == 7) {
dayOfWeekCount = vow.getCount();
} else {
weekVos.add(vow);
}

}
monthVos.add(vo);
}

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());
}
String weekPercentage = "--";
if (dayOfWeekCount > 0) {
Long count = yesterdayCount - dayOfWeekCount;
weekPercentage = nf.format(count.doubleValue() / new Double(dayOfWeekCount).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);
}

@TenantIgnore
@ApiOperation("查询微信用户活跃数量 昨日活跃,近一周活跃,近一月活跃")
@GetMapping("findUserVisitCount")
@SystemControllerLog(description = "会员首页-报表数据-查询微信用户活跃数量")
public ResultData findUserVisitCount() {
logger.debug("[" + getIpAddr() + "] WxCUserDataController::findUserVisitCount");
TenantEntity tenantEntity = getTenantInfo();
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);
WxUserVisit userVisit = new WxUserVisit();
userVisit.updateTenantInfo(tenantEntity);
userVisit.setStartTime(c.getTime());
//昨日活跃数
long yesterdayCount = wxUserVisitService.queryVisitUv(userVisit);
//近一周活跃
c.add(Calendar.DAY_OF_YEAR, -6);
userVisit.setStartTime(c.getTime());
long weekCount = wxUserVisitService.queryVisitUv(userVisit);
//近一月活跃
c.add(Calendar.DAY_OF_YEAR, -22);
userVisit.setStartTime(c.getTime());
long monthCount = wxUserVisitService.queryVisitUv(userVisit);

Map<String, Object> mapVo = new HashMap<>();
mapVo.put("yesterdayCount", yesterdayCount);//昨日活跃数
mapVo.put("weekCount", weekCount);//周活跃数总数
mapVo.put("monthCount", monthCount);//近一个月活跃数
return new ResultData(mapVo);
}

@TenantIgnore
@ApiOperation("查询用户消费金额")
@GetMapping("findUserAmountData")
@SystemControllerLog(description = "会员首页-报表数据-查询用户消费金额")
public ResultData findUserAmountData() {
logger.debug("[" + getIpAddr() + "] WxCUserDataController::findUserAmountData");
TenantEntity tenantEntity = getTenantInfo();
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 eTime = c.getTime();//明天0点

c.add(Calendar.DAY_OF_YEAR, -30);
Date sTime = c.getTime();
List<CUserDateAmountVo> datas = wxCouponOrderService.queryPriceTotalGroup(tenantEntity, 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
List<UserStructureVo> weekVos = new ArrayList<>();//周消费金额
List<UserStructureVo> monthVos = new ArrayList<>();//周消费金额
for (int i = 29, sortNum = 0; i >= 0; i--) {
c.clear();
c.setTime(today);
c.add(Calendar.DAY_OF_YEAR, -i);
String dateStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
UserStructureVo vo = new UserStructureVo();
vo.setName(new SimpleDateFormat("MM/dd").format(c.getTime()));
vo.setSortNum(sortNum++);
if (dataMap.get(dateStr) != null) {
int price = dataMap.get(dateStr);
vo.setPrice(price);
} else {
vo.setPrice(0);
}
if (i <= 7) {
UserStructureVo vow = new UserStructureVo();
vow.setName(vo.getName());
vow.setSortNum(vo.getSortNum());
vow.setPrice(vo.getPrice());

if (i == 0) {
todayCount = vow.getPrice();
}
if (i == 1) {
yesterdayCount = vow.getPrice();
}
if (i == 7) {
dayOfWeekCount = vow.getPrice();
} else {
weekVos.add(vow);
}
}
monthVos.add(vo);
}

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());
}
String weekPercentage = "--";
if (dayOfWeekCount > 0) {
Integer count = todayCount - dayOfWeekCount;
weekPercentage = nf.format(count.doubleValue() / new Double(dayOfWeekCount).doubleValue());
}
Map<String, Object> map = new HashMap<>();
map.put("todayCount", todayCount);//今日
map.put("dayPercentage", dayPercentage);//日环比
map.put("weekPercentage", weekPercentage); //周同比
map.put("weekVos", weekVos);//一周金额列表
map.put("monthVos", monthVos);//一月金额列表
return new ResultData(map);
}

@TenantIgnore
@ApiOperation("查询用户消费金额 今日,周,月")
@GetMapping("findUserConsumeAmount")
@SystemControllerLog(description = "会员首页-报表数据-查询用户消费金额")
public ResultData findUserConsumeAmount() {
logger.debug("[" + getIpAddr() + "] WxCUserDataController::findUserConsumeAmount");
TenantEntity tenantEntity = getTenantInfo();
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
WxCouponOrder wxCouponOrder = new WxCouponOrder();
wxCouponOrder.updateTenantInfo(tenantEntity);
wxCouponOrder.setStartTime(c.getTime());
//今日消费金额
int todayCount = wxCouponOrderService.queryPriceTotal(wxCouponOrder);
//周交易金额
c.add(Calendar.DAY_OF_YEAR, -7);
wxCouponOrder.setStartTime(c.getTime());
int weekCount = wxCouponOrderService.queryPriceTotal(wxCouponOrder);
//月交易金额
c.add(Calendar.DAY_OF_YEAR, -22);
wxCouponOrder.setStartTime(c.getTime());
int monthCount = wxCouponOrderService.queryPriceTotal(wxCouponOrder);

Map<String, Object> map = new HashMap<>();
DecimalFormat df = new DecimalFormat("0.00");
map.put("todayCount", df.format((float) todayCount / 100));//今日消费金额
map.put("weekCount", df.format((float) weekCount / 100));//近一周消费金额
map.put("monthCount", df.format((float) monthCount / 100));//近一个月消费金额数
return new ResultData(map);
}


}




+ 79
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserFromController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCUserFrom;
import com.iformall.domain.vo.WxCUserFromVo;
import com.iformall.enums.EnumCUserFrom;
import com.iformall.service.WxCUserFromService;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

@Autowired
private WxCUserFromService wxCUserFromService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "分享-列表")
public ResultData list(@ModelAttribute WxCUserFrom wxCUserFrom, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCUserCarController::list");
if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom();
wxCUserFrom.updateTenantInfo(getTenantInfo());
final PageInfo<WxCUserFrom> page = wxCUserFromService.listAsPage(wxCUserFrom, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据id查询接口")
@GetMapping("/visits")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "分享-列表")
public ResultData visits(@ModelAttribute WxCUserFromVo wxCUserFromVo,Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCUserCarController::findById");
if (null == wxCUserFromVo) wxCUserFromVo = new WxCUserFromVo();
if(wxCUserFromVo.getFromType() == null){
wxCUserFromVo.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode());
}
wxCUserFromVo.updateTenantInfo(getTenantInfo());
final PageInfo<WxCUserFromVo> page = wxCUserFromService.listAsVisitsPage(wxCUserFromVo, pageNum, pageSize);
return new ResultData(page);
}

@GetMapping("/exportData")
@SystemControllerLog(description = "导出数据")
public void exportData(@ModelAttribute WxCUserFrom wxCUserFrom, HttpServletRequest request, HttpServletResponse response) {
if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom();
wxCUserFrom.updateTenantInfo(getTenantInfo());
wxCUserFromService.exportData(request, response, wxCUserFrom);
}

@GetMapping("/exportDataVisits")
@SystemControllerLog(description = "导出数据")
public void exportDataVisits(@ModelAttribute WxCUserFromVo wxCUserFromVo, HttpServletRequest request, HttpServletResponse response) {
if (null == wxCUserFromVo) wxCUserFromVo = new WxCUserFromVo();
wxCUserFromVo.updateTenantInfo(getTenantInfo());
if(wxCUserFromVo.getFromType() == null){
wxCUserFromVo.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode());
}
wxCUserFromService.exportDataVisits(request, response, wxCUserFromVo);
}


}

+ 80
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/WxCUserTagsController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
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)})
@SystemControllerLog(description = "会员首页-标签-列表")
public ResultData list(@ModelAttribute WxCUserTags wxCUserTags, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCUserTagsController::list");
if (null == wxCUserTags) wxCUserTags = new WxCUserTags();
wxCUserTags.setTenantId(getTenantInfo().getFinalTenantId());
final PageInfo<WxCUserTags> page = wxCUserTagsService.listAsPage(wxCUserTags, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "会员首页-标签-新增")
public ResultData add(@RequestBody WxCUserTags wxCUserTags) {
logger.debug("[" + getIpAddr() + "] WxCUserTagsController::add");
//Assert.notNull(wxCUserTags.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxCUserTagsService.saveOrUpdate(wxCUserTags);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "会员首页-标签-更新")
public ResultData update(@RequestBody WxCUserTags wxCUserTags) {
logger.debug("[" + getIpAddr() + "] WxCUserTagsController::update");
wxCUserTagsService.saveOrUpdate(wxCUserTags);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "会员首页-标签-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCUserTagsController::delete");
wxCUserTagsService.deleteById(id,getTenantInfo().getFinalTenantId());
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "会员首页-标签-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCUserTagsController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCUserTagsService.getById(id,getTenantInfo().getFinalTenantId()));
}


}

+ 200
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java View File

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxCreditHistory;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.MerchantCreditRankingVo;
import com.iformall.domain.vo.WxCreditHistoryVo;
import com.iformall.enums.EnumMerchantStatus;
import com.iformall.enums.EnumScoreType;
import com.iformall.enums.EnumUserType;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxCreditHistoryService;
import com.iformall.service.WxMerchantService;
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;
import java.util.Objects;

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

@Autowired
WxCreditHistoryService wxCreditHistoryService;

@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)})
@SystemControllerLog(description = "积分历史-列表")
public ResultData list(@ModelAttribute WxCreditHistory wxCreditHistory, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::list");
if (null == wxCreditHistory) wxCreditHistory = new WxCreditHistory();
TenantEntity tenantInfo = getTenantInfo();
wxCreditHistory.updateTenantInfo(tenantInfo);
final PageInfo<WxCreditHistoryVo> page = wxCreditHistoryService.listAsPageMore(wxCreditHistory, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据商户ID和消费金额获取所增加积分 取data里credit的值")
@GetMapping("findByMerchantIdAndSpend")
@ApiImplicitParams({
@ApiImplicitParam(name = "merchantId", value = "商户ID", dataType = "long", paramType = "query", required = true),
@ApiImplicitParam(name = "spend", value = "消费金额", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "userId", value = "会员Id", dataType = "long", paramType = "query", required = true)})
@SystemControllerLog(description = "积分历史-根据商户ID和消费金额获取所增加积分")
public ResultData findByMerchantIdAndSpend(Long merchantId, String spendStr,Long userId) {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::findByMerchantIdAndSpend");
if(Objects.isNull(merchantId)|| StringUtils.isEmpty(spendStr)||Objects.isNull(userId)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ;
}

try {
Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId) ;
return new ResultData(result);
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(),e.getMessage());
} catch (Exception e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,e.getMessage());
}
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "积分历史-新增接口")
public ResultData add(@RequestBody WxCreditHistory wxCreditHistory) {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::add");
MallUserInfo user = getUser();

wxCreditHistory.setTenantId(user.getFinalTenantId());
wxCreditHistory.setFinalTenantId(user.getFinalTenantId());
wxCreditHistory.setOperatorId(user.getId());

wxCreditHistory.setOperatorType(EnumUserType.MALLUSER.getCode());
String desc = "";
if(wxCreditHistory.getCreditType().equals(EnumScoreType.SPEND_CREDIT.getCode())){
WxMerchant byId = wxMerchantService.getById(wxCreditHistory.getMerchantId());
desc = "管理端手动积分:消费商户["+byId.getName()+"] 消费金额["+wxCreditHistory.getSpendStr()+"元]";
}else if(wxCreditHistory.getCreditType().equals(EnumScoreType.REDUCE_CREDIT.getCode())){
desc = "管理端手动扣减积分";
if(StringUtils.isNotBlank(wxCreditHistory.getChangePurpose())){
desc = desc + "["+wxCreditHistory.getChangePurpose()+"]";
}
}else{
desc = "管理端("+user.getUsername()+")操作未知积分来源";
}
wxCreditHistory.setChangePurpose(desc);
try {
wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),getTenantInfo()) ;
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory,getTenantInfo().getTenantId());
return new ResultData(Result.SUCCESS, "操作成功", credit);
} catch (MallinkException e) {
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "积分历史-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCreditHistoryService.getById(id,getTenantInfo().getFinalTenantId()));
}

/**
* 根据A端设置的【每自然年末扣除前N年用户积分】规则,扣减用户积分
*
* @return
*/
public ResultData clearCreditByYear() {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::clearCreditByYear");
wxCreditHistoryService.clearCreditByYear();
return new ResultData(Result.SUCCESS);
}

@GetMapping("exportData")
@SystemControllerLog(description = "积分历史-导出数据")
public void exportData(@ModelAttribute WxCreditHistory wxCreditHistory, HttpServletRequest request, HttpServletResponse response) {
wxCreditHistory.setTenantId(getTenantInfo().getFinalTenantId());
wxCreditHistory.setFinalTenantId(getTenantInfo().getFinalTenantId());
wxCreditHistoryService.exportData(request, response, wxCreditHistory);
}

@ApiOperation("积分统计概览")
@GetMapping("getCreditSummary")
@SystemControllerLog(description = "积分历史-积分统计概览")
public ResultData getCreditSummary(@ModelAttribute WxCreditHistory wxCreditHistory) {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::getCreditSummary");
TenantEntity tenantInfo = getTenantInfo();
wxCreditHistory.updateTenantInfo(tenantInfo);
return wxCreditHistoryService.getCreditSummary(wxCreditHistory);
}


@ApiOperation("积分清零计划")
@PostMapping("clearCreditByYear")
@SystemControllerLog(description = "积分清零计划")
@TenantIgnore
public ResultData clearCreditByYear(@RequestBody WxCreditHistory wxCreditHistory) {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::clearCreditByYear");
if(wxCreditHistory == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ;
}
if(StringUtils.isBlank(wxCreditHistory.getFinalTenantId())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ;
}
wxCreditHistoryService.clearCreditByYear(wxCreditHistory);
return new ResultData(Result.SUCCESS);
}

@ApiOperation("积分清零计划 刷新商圈积分")
@PostMapping("syncClearCredit")
@SystemControllerLog(description = "刷新商圈积分")
@TenantIgnore
public ResultData syncClearCredit() {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::syncClearCredit");
wxCreditHistoryService.syncClearCredit(getTenantInfo());
return new ResultData(Result.SUCCESS);
}

@ApiOperation("门店排行榜")
@GetMapping("merchantCreditRanking")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "、-列表")
public ResultData merchantCreditRanking(@ModelAttribute WxCreditHistory wxCreditHistory, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::merchantCreditRanking");
if (null == wxCreditHistory) wxCreditHistory = new WxCreditHistory();
TenantEntity tenantInfo = getTenantInfo();
wxCreditHistory.updateTenantInfo(tenantInfo);
final PageInfo<MerchantCreditRankingVo> page = wxCreditHistoryService.listAsPageMcrv(wxCreditHistory, pageNum, pageSize);
return new ResultData(page);
}

}

+ 114
- 0
suimangAdmin/src/main/java/com/iformall/controller/mem/WxLevelConfigController.java View File

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity;
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.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.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;

import java.util.List;

@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)})
@SystemControllerLog(description = "会员等级权益-列表")
public ResultData list(@ModelAttribute WxLevelConfig wxLevelConfig, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::list");
if (null == wxLevelConfig) wxLevelConfig = new WxLevelConfig();
wxLevelConfig.updateTenantInfo(getTenantInfo());
wxLevelConfig.setSortColumns(BaseEntity.SortField.Points_ASC);
final PageInfo<WxLevelConfig> page = wxLevelConfigService.listAsPage(wxLevelConfig, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "会员等级权益-新增")
public ResultData add(@RequestBody List<WxLevelConfig> levelConfigs) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add");
try {
if (StringUtils.isNotBlank(getTenantInfo().getParentTenantId())) {
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "子广场用户无此权限");
}
wxLevelConfigService.batchSave(getTenantInfo(), levelConfigs);
} catch (Exception e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.DB_FAIL);
}
return new ResultData();
}

@ApiOperation("更改会员权益")
@PostMapping("updateCapabilities")
@SystemControllerLog(description = "会员等级权益-更改会员权益")
public ResultData updateCapabilities(@RequestBody List<WxLevelConfig> levelConfigs) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add");
try {
if (StringUtils.isNotBlank(getTenantInfo().getParentTenantId())) {
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "子广场用户无此权限");
}
wxLevelConfigService.batchUpdateCapabilities(getTenantInfo(), levelConfigs);
} catch (Exception e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.DB_FAIL);
}
return new ResultData();
}

@ApiOperation("根据id删除接口")
@PostMapping("/del")
@SystemControllerLog(description = "会员等级权益-删除")
public ResultData delete(@RequestBody WxLevelConfig wxLevelConfig) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::delete");
if(wxLevelConfig.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if (StringUtils.isNotBlank(getTenantInfo().getParentTenantId())) {
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "子广场用户无此权限");
}
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)
@SystemControllerLog(description = "会员等级权益-获取")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxLevelConfigService.getById(id));
}

}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save