release # Conflicts: # mallinkService/src/main/java/com/iformall/common/ErrorCode.javarelease_toaliyun_real
| @@ -1,42 +0,0 @@ | |||
| pipeline { | |||
| agent any | |||
| stages { | |||
| stage('检出') { | |||
| steps { | |||
| checkout([$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]], | |||
| userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]]) | |||
| } | |||
| } | |||
| stage('构建') { | |||
| steps { | |||
| sh 'mvn -version' | |||
| echo '构建中...' | |||
| sh 'mvn -U clean package -Dmaven.test.skip=true' | |||
| echo '构建完成.' | |||
| archiveArtifacts(artifacts: '**/target/*.jar', fingerprint: true) | |||
| } | |||
| } | |||
| stage('测试') { | |||
| steps { | |||
| echo '单元测试中...' | |||
| echo '单元测试完成.' | |||
| writeFile(file: 'TEST-demo.junit4.AppTest.xml', text: ''' | |||
| <testsuite name="demo.junit4.AppTest" time="0.053" tests="3" errors="0" skipped="0" failures="0"> | |||
| <properties> | |||
| </properties> | |||
| <testcase name="testApp" classname="demo.junit4.AppTest" time="0.003"/> | |||
| <testcase name="test1" classname="demo.junit4.AppTest" time="0"/> | |||
| <testcase name="test2" classname="demo.junit4.AppTest" time="0"/> | |||
| </testsuite> | |||
| ''') | |||
| junit '*.xml' | |||
| } | |||
| } | |||
| stage('部署') { | |||
| steps { | |||
| echo '部署中...' | |||
| echo '部署完成' | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -13,8 +13,8 @@ | |||
| <artifactId>mallinkAdmin</artifactId> | |||
| <properties> | |||
| <weixin-java-mp.version>3.3.0</weixin-java-mp.version> | |||
| <weixin-java-open.version>3.3.0</weixin-java-open.version> | |||
| <weixin-java-mp.version>3.6.0</weixin-java-mp.version> | |||
| <weixin-java-open.version>3.6.0</weixin-java-open.version> | |||
| </properties> | |||
| <dependencies> | |||
| @@ -49,7 +49,7 @@ | |||
| <dependency> | |||
| <groupId>org.flywaydb</groupId> | |||
| <artifactId>flyway-core</artifactId> | |||
| <version>5.1.4</version> | |||
| <version>5.2.4</version> | |||
| </dependency> | |||
| </dependencies> | |||
| @@ -1,11 +0,0 @@ | |||
| package com.iformall.advice; | |||
| import org.springframework.web.bind.annotation.ControllerAdvice; | |||
| import org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice; | |||
| @ControllerAdvice | |||
| public class JsonpAdvice extends AbstractJsonpResponseBodyAdvice { | |||
| public JsonpAdvice() { | |||
| super("callback"); | |||
| } | |||
| } | |||
| @@ -167,10 +167,10 @@ public class ShiroConfig { | |||
| } | |||
| @Bean | |||
| public SecurityManager securityManager(@Qualifier("myRetryLimitCredentialsMatcher") MyRetryLimitCredentialsMatcher matcher) { | |||
| public SecurityManager securityManager() { | |||
| DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); | |||
| //设置realm. | |||
| securityManager.setRealm(myShiroRealm(matcher)); | |||
| securityManager.setRealm(myShiroRealm()); | |||
| // 自定义缓存实现 使用redis | |||
| //securityManager.setCacheManager(cacheManager()); | |||
| // 自定义session管理 使用redis | |||
| @@ -179,9 +179,9 @@ public class ShiroConfig { | |||
| } | |||
| @Bean | |||
| public MyShiroRealm myShiroRealm(MyRetryLimitCredentialsMatcher matcher) { | |||
| public MyShiroRealm myShiroRealm() { | |||
| MyShiroRealm myShiroRealm = new MyShiroRealm(); | |||
| myShiroRealm.setCredentialsMatcher(matcher); | |||
| myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher()); | |||
| return myShiroRealm; | |||
| } | |||
| @@ -194,7 +194,6 @@ public class ShiroConfig { | |||
| * | |||
| * @return | |||
| */ | |||
| @Bean(name = "myRetryLimitCredentialsMatcher") | |||
| public MyRetryLimitCredentialsMatcher hashedCredentialsMatcher() { | |||
| MyRetryLimitCredentialsMatcher hashedCredentialsMatcher = new MyRetryLimitCredentialsMatcher(); | |||
| @@ -76,7 +76,7 @@ public class WebConfig implements WebMvcConfigurer { | |||
| * | |||
| * @return | |||
| */ | |||
| @Bean | |||
| @Bean("myCharacterEncodingFilter") | |||
| public Filter characterEncodingFilter() { | |||
| CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); | |||
| characterEncodingFilter.setEncoding("UTF-8"); | |||
| @@ -1,9 +1,9 @@ | |||
| package com.iformall.config; | |||
| import me.chanjar.weixin.mp.api.WxMpConfigStorage; | |||
| import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage; | |||
| 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; | |||
| @@ -23,9 +23,8 @@ public class WechatMpConfig { | |||
| return wxMpService; | |||
| } | |||
| @Bean | |||
| public WxMpConfigStorage wxConfigProvider(){ | |||
| WxMpInMemoryConfigStorage wxConfigProvider = new WxMpInMemoryConfigStorage(); | |||
| WxMpDefaultConfigImpl wxConfigProvider = new WxMpDefaultConfigImpl(); | |||
| wxConfigProvider.setAppId(wechatWebProperties.getAppId()); | |||
| wxConfigProvider.setSecret(wechatWebProperties.getSecret()); | |||
| return wxConfigProvider; | |||
| @@ -0,0 +1,188 @@ | |||
| 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()); | |||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||
| final PageInfo<WxCouponChannelVo> page = couponChannelService.listPageCVo(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()); | |||
| if (memCouponFromDsp.getCouponId() == null) { | |||
| memCouponFromDsp.setCouponId(couponChannel.getCouponId()); | |||
| } | |||
| // 1. 检查券是否已超限, 无剩余库存 | |||
| WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId()); | |||
| if (coupon == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId()); | |||
| } | |||
| MemCouponFromDsp couponQ = new MemCouponFromDsp() {{ | |||
| updateTenantInfo(memCouponFromDsp); | |||
| setCouponId(memCouponFromDsp.getCouponId()); | |||
| setStatus(0); | |||
| }}; | |||
| Integer couponCount = memCouponFromDspService.countByInfo(couponQ); | |||
| if (coupon.getRemainInventory() <= couponCount) { | |||
| return new ResultData(ErrorCode.REMAIN_IS_EMPTY); | |||
| } | |||
| // 2. 检查此会员是否已超限, 达到券购买限制 | |||
| couponQ = new MemCouponFromDsp() {{ | |||
| updateTenantInfo(memCouponFromDsp); | |||
| setPhone(memCouponFromDsp.getPhone()); | |||
| 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()); | |||
| if (memCouponFromDsp.getCouponId() == null) { | |||
| memCouponFromDsp.setCouponId(couponChannel.getCouponId()); | |||
| } | |||
| // 1. 检查券是否已超限, 无剩余库存 | |||
| WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId()); | |||
| if (coupon == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId()); | |||
| } | |||
| MemCouponFromDsp couponQ = new MemCouponFromDsp() {{ | |||
| updateTenantInfo(memCouponFromDsp); | |||
| setCouponId(memCouponFromDsp.getCouponId()); | |||
| setStatus(0); | |||
| }}; | |||
| Integer couponCount = memCouponFromDspService.countByInfo(couponQ); | |||
| if (coupon.getRemainInventory() <= couponCount) { | |||
| return new ResultData(ErrorCode.REMAIN_IS_EMPTY); | |||
| } | |||
| // 2. 检查此会员是否已超限, 达到券购买限制 | |||
| couponQ = new MemCouponFromDsp() {{ | |||
| updateTenantInfo(memCouponFromDsp); | |||
| setPhone(memCouponFromDsp.getPhone()); | |||
| 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() {{ | |||
| updateTenantInfo(getTenantInfo()); | |||
| setPhone(phone); | |||
| }}; | |||
| List<MemCouponFromDsp> memCouponFromDsps = memCouponFromDspService.getList(memQ); | |||
| return new ResultData(memCouponFromDsps); | |||
| } | |||
| } | |||
| @@ -4,8 +4,8 @@ spring: | |||
| # JDBC | |||
| datasource: | |||
| url: jdbc:mysql://127.0.0.1:3306/mallinkDev?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true&allowMultiQueries=true | |||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | |||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | |||
| username: root | |||
| password: root | |||
| type: com.alibaba.druid.pool.DruidDataSource | |||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||
| filters: stat | |||
| @@ -26,9 +26,9 @@ spring: | |||
| #date-format: yyyy-MM-dd HH:mm:ss | |||
| # REDIS | |||
| redis: | |||
| host: 202.165.179.86 | |||
| host: 127.0.0.1 | |||
| port: 6379 | |||
| password: ENC(xPFDlgd6v8zUhJMbcKc0KmmQiqs9qHtk) | |||
| password: test123 | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 1 | |||
| @@ -73,7 +73,7 @@ spring: | |||
| publisher-returns: false | |||
| virtual-host: / | |||
| flyway: | |||
| enabled: true | |||
| enabled: false | |||
| aws: | |||
| clientRegion: cn-northwest-1 | |||
| @@ -92,9 +92,9 @@ wechat: | |||
| componentToken: "formall2018" | |||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||
| redis: | |||
| host: 202.165.179.86 | |||
| host: 127.0.0.1 | |||
| port: 6379 | |||
| password: ENC(xPFDlgd6v8zUhJMbcKc0KmmQiqs9qHtk) | |||
| password: | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 2 | |||
| @@ -0,0 +1,29 @@ | |||
| INSERT INTO `mall_permission` (`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) | |||
| VALUES | |||
| (686, 'h5投放', 606, 'Y', NULL, 1, NULL, NULL, 'sendweb', null, 0, 686); | |||
| DROP TABLE IF EXISTS `mall_sale_type` ; | |||
| CREATE TABLE `mall_sale_type` ( | |||
| `id` bigint(64) NOT NULL, | |||
| `name` varchar(32) DEFAULT NULL COMMENT '销售类型', | |||
| `type` tinyint(2) DEFAULT NULL COMMENT '资源类型1:尊享全能版 2:尊享营销版 3.速享版', | |||
| `period` tinyint(2) DEFAULT NULL COMMENT '有效期(单位月)', | |||
| `menus` json DEFAULT NULL COMMENT '菜单列表', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE `id_UNIQUE` USING BTREE (`id`) comment '' | |||
| ) ENGINE=`InnoDB` ROW_FORMAT=DYNAMIC COMMENT='系统销售表' CHECKSUM=0 DELAY_KEY_WRITE=0; | |||
| INSERT INTO `mall_sale_type` | |||
| (`id`,`name`, `type`, `period`, `menus`) | |||
| VALUES | |||
| (1, '尊享全能版', 1, 12, | |||
| '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 101, 102, 103, 104, 105, 106, 107, 108, 201, 202, 203, 204, 205, 206, 211, 212, 221, 222, 251, 299, 300, 301, 302, 303, 304, 305, 306, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 651, 661, 662, 663, 671, 672, 673,674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 711, 712, 713, 901, 902, 903, 931, 932, 951, 952, 961, 962,963, 965, 966, 967, 968, 1001, 1002, 1003, 1004]' | |||
| ), | |||
| (2, '尊享营销版', 2, 12, | |||
| '[1, 2, 4, 5, 6, 7, 8, 9, 10, 50, 101, 102, 103, 104, 105, 106, 107, 201, 202, 203, 204, 205, 211, 212, 221, 222, 251, 409, 410, 411, 416, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 651, 661, 662, 663, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 711, 712, 713, 901, 902, 903, 931, 932, 951, 961]' | |||
| ), | |||
| (3, '速享版', 3, 1, | |||
| '[2, 4, 5, 6, 7, 10, 50, 201, 202, 205, 211, 212, 221, 222, 251, 409, 410, 411, 416, 501, 502, 503, 504, 505, 506, 507, 508, 511, 512, 513, 521, 522, 523, 531, 532, 533, 591, 592, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 641, 642, 643, 644, 645, 651, 661, 662, 663, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 711, 712, 713, 901, 902, 903, 931, 932]' | |||
| ) | |||
| ; | |||
| @@ -14,10 +14,7 @@ import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.car.DaHuaUtil; | |||
| import com.iformall.utils.car.ETCPUtil; | |||
| import com.iformall.utils.car.ShangAnUtil; | |||
| import com.iformall.utils.car.TJDUtil; | |||
| import com.iformall.utils.car.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -598,6 +595,8 @@ public class WxCarController extends BaseController { | |||
| return tjdCarStopFee(paramMap, park); | |||
| } else if (park.getVendorType().equals(EnumCarVendor.CAR_DAHUA.getCode())) { | |||
| return dahuaCarStopFee(paramMap, park); | |||
| } else if (park.getVendorType().equals(EnumCarVendor.CAR_BOLINK.getCode())) { | |||
| return bolinkCarStopFee(paramMap, park); | |||
| } | |||
| return new ResultData(ErrorCode.CAR_VENDOR_NOT_SUPPORT.getCode(), "停车费获取失败"); | |||
| } | |||
| @@ -696,6 +695,27 @@ public class WxCarController extends BaseController { | |||
| return businessId; | |||
| } | |||
| private ResultData bolinkCarStopFee(@RequestBody Map<String, String> paramMap, WxPark park) { | |||
| String carNumber = paramMap.get("carNumber"); | |||
| if (StringUtils.isBlank(carNumber)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "carNumber为空"); | |||
| } | |||
| String params = park.getVendorParams(); | |||
| JSONObject objParams = JSON.parseObject(params); | |||
| String url = objParams.getString(BoLinkUtil.BOLINK_URL); | |||
| String comid = objParams.getString(BoLinkUtil.BOLINK_COMID); | |||
| String unionId = objParams.getString(BoLinkUtil.BOLINK_UNION_ID); | |||
| String key = objParams.getString(BoLinkUtil.BOLINK_KEY); | |||
| String ret = BoLinkUtil.getStopFee(url, comid, unionId, key, carNumber); | |||
| JSONObject retObj = JSON.parseObject(ret); | |||
| JSONObject dataObj = retObj.getJSONObject(BoLinkUtil.BOLINK_DATA); | |||
| if (dataObj.getIntValue(BoLinkUtil.BOLINK_STATE) == BoLinkUtil.BOLINK_SUCCESS) { | |||
| return new ResultData(dataObj); | |||
| } else { | |||
| return new ResultData(ErrorCode.BOLINK_STOP_FEE_FAIL); | |||
| } | |||
| } | |||
| /** | |||
| * 优免券领取 | |||
| * 优免券不可退 | |||
| @@ -56,15 +56,16 @@ public class WxCardPayController extends BaseController { | |||
| @ApiOperation(value = "C端扫B端储值卡支付订单", notes = "params:{\"cardId\":\"String\",\"merchantId\":\"String\",\"totalFee\":\"String(元)\"}") | |||
| @PostMapping("order_create") | |||
| public ResultData saveCardPayOrder(@RequestBody Map<String, String> paramMap, HttpServletRequest request) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("saveCardPayOrder: " + ipStr + " :" + paramMap.toString()); | |||
| WxCUser user = getUser(); | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(user.getId()); | |||
| if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | |||
| logger.error(ErrorCode.MEMBER_IS_LOCKED.getMessage()); | |||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||
| } | |||
| String ipStr = getIpAddr(); | |||
| logger.info("saveCardPayOrder: " + ipStr + " :" + paramMap.toString()); | |||
| String cardIdStr = paramMap.get("cardId"); | |||
| String merchantStr = paramMap.get("merchantId"); | |||
| String totalFeeStr = paramMap.get("totalFee"); | |||
| @@ -169,7 +170,7 @@ public class WxCardPayController extends BaseController { | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData cardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend, Integer pageNum, Integer pageSize) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("saveCardPayOrder: " + ipStr + " :" + wxCardSpend.toString()); | |||
| logger.info("list: " + ipStr + " :" + wxCardSpend.toString()); | |||
| if (wxCardSpend == null) wxCardSpend = new WxCardSpendVo(); | |||
| wxCardSpend.updateTenantInfo(getTenantInfo()); | |||
| wxCardSpend.setOwnerId(getUserId()); | |||
| @@ -3,13 +3,16 @@ package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCardCVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.enums.EnumCouponChannelActivityStatus; | |||
| import com.iformall.enums.EnumCouponOrderStatus; | |||
| import com.iformall.enums.EnumCouponOrderValidStatus; | |||
| import com.iformall.service.MemCouponFromDspService; | |||
| import com.iformall.service.WxCouponOrderService; | |||
| import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.Api; | |||
| @@ -34,6 +37,9 @@ public class WxCouponOrderController extends BaseController { | |||
| @Autowired | |||
| private WxCouponOrderService wxCouponOrderService; | |||
| @Autowired | |||
| private MemCouponFromDspService memCouponFromDspService; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @@ -231,4 +237,13 @@ public class WxCouponOrderController extends BaseController { | |||
| return wxCouponOrderService.queryCardStatus(wxCouponOrder); | |||
| } | |||
| @ApiOperation(value = "检查H5券码是否都已注入") | |||
| @GetMapping("checkH5CouponOrder") | |||
| public ResultData checkH5CouponOrder() { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| WxCUser user = getUser(); | |||
| memCouponFromDspService.couponOrderFromDsp(tenantEntity, user.getPhone()); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -92,6 +92,9 @@ public class WxUserGrantController extends BaseController { | |||
| @Autowired | |||
| WxCreditHistoryService wxCreditHistoryService; | |||
| @Autowired | |||
| private MemCouponFromDspService memCouponFromDspService; | |||
| /** | |||
| * 微信消息服务验证 | |||
| * | |||
| @@ -530,8 +533,10 @@ public class WxUserGrantController extends BaseController { | |||
| // 首次授权, 增加成长值及积分 | |||
| // 成长值 | |||
| user.setScore(user.getScore() + wxScoreRulesService.addScore(EnumScoreType.WECHAT_PHONE, user)); | |||
| //增加积分 | |||
| // 增加积分 | |||
| wxCUserService.addCredit(user, EnumScoreType.WECHAT_PHONE); | |||
| // 外部注券 | |||
| memCouponFromDspService.couponOrderFromDsp(tenantEntity, phoneNoInfo.getPhoneNumber()); | |||
| } | |||
| resultMap.put("msg", "授权手机成功!"); | |||
| @@ -13,8 +13,8 @@ | |||
| <artifactId>mallinkCallback</artifactId> | |||
| <properties> | |||
| <weixin-java-mp.version>3.3.0</weixin-java-mp.version> | |||
| <weixin-java-open.version>3.3.0</weixin-java-open.version> | |||
| <weixin-java-mp.version>3.6.0</weixin-java-mp.version> | |||
| <weixin-java-open.version>3.6.0</weixin-java-open.version> | |||
| </properties> | |||
| <dependencies> | |||
| @@ -160,10 +160,10 @@ public class ShiroConfig { | |||
| } | |||
| @Bean | |||
| public SecurityManager securityManager(@Qualifier("myRetryLimitCredentialsMatcher") MyRetryLimitCredentialsMatcher matcher) { | |||
| public SecurityManager securityManager() { | |||
| DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); | |||
| //设置realm. | |||
| securityManager.setRealm(myShiroRealm(matcher)); | |||
| securityManager.setRealm(myShiroRealm()); | |||
| // 自定义缓存实现 使用redis | |||
| //securityManager.setCacheManager(cacheManager()); | |||
| // 自定义session管理 使用redis | |||
| @@ -172,9 +172,9 @@ public class ShiroConfig { | |||
| } | |||
| @Bean | |||
| public MyShiroRealm myShiroRealm(MyRetryLimitCredentialsMatcher matcher) { | |||
| public MyShiroRealm myShiroRealm() { | |||
| MyShiroRealm myShiroRealm = new MyShiroRealm(); | |||
| myShiroRealm.setCredentialsMatcher(matcher); | |||
| myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher()); | |||
| return myShiroRealm; | |||
| } | |||
| @@ -187,7 +187,6 @@ public class ShiroConfig { | |||
| * | |||
| * @return | |||
| */ | |||
| @Bean(name = "myRetryLimitCredentialsMatcher") | |||
| public MyRetryLimitCredentialsMatcher hashedCredentialsMatcher() { | |||
| MyRetryLimitCredentialsMatcher hashedCredentialsMatcher = new MyRetryLimitCredentialsMatcher(); | |||
| @@ -39,7 +39,7 @@ public class WebConfig implements WebMvcConfigurer { | |||
| @Autowired | |||
| private RequestInterceptor requestInterceptor; | |||
| @Bean | |||
| @Bean("myRequestMappingHandlerAdapter") | |||
| public RequestMappingHandlerAdapter requestMappingHandlerAdapter() { | |||
| RequestMappingHandlerAdapter adapter = new RequestMappingHandlerAdapter(); | |||
| @@ -114,7 +114,7 @@ public class WebConfig implements WebMvcConfigurer { | |||
| * | |||
| * @return | |||
| */ | |||
| @Bean | |||
| @Bean("myCharacterEncodingFilter") | |||
| public Filter characterEncodingFilter() { | |||
| CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); | |||
| characterEncodingFilter.setEncoding("UTF-8"); | |||
| @@ -1,33 +0,0 @@ | |||
| package com.iformall.config; | |||
| import me.chanjar.weixin.mp.api.WxMpConfigStorage; | |||
| import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage; | |||
| import me.chanjar.weixin.mp.api.WxMpService; | |||
| import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; | |||
| 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; | |||
| } | |||
| @Bean | |||
| public WxMpConfigStorage wxConfigProvider(){ | |||
| WxMpInMemoryConfigStorage wxConfigProvider = new WxMpInMemoryConfigStorage(); | |||
| wxConfigProvider.setAppId(wechatWebProperties.getAppId()); | |||
| wxConfigProvider.setSecret(wechatWebProperties.getSecret()); | |||
| return wxConfigProvider; | |||
| } | |||
| } | |||
| @@ -1,59 +0,0 @@ | |||
| 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); | |||
| } | |||
| } | |||
| @@ -13,9 +13,7 @@ import com.iformall.enums.EnumBoxRegisterStatus; | |||
| import com.iformall.service.kw.KwBoxCmdHistoryService; | |||
| import com.iformall.service.kw.KwBoxService; | |||
| import com.iformall.utils.HashUtil; | |||
| import com.iformall.utils.Utility; | |||
| import com.sun.crypto.provider.HmacSHA1; | |||
| import io.netty.util.internal.StringUtil; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -117,6 +117,5 @@ fm: | |||
| logging: | |||
| level: | |||
| tk.mybatis: debug | |||
| com.iformall: debug | |||
| path: ./logs/admin | |||
| @@ -25,8 +25,8 @@ public class MsgReSendSchedule { | |||
| @Autowired | |||
| private MqBaseProducer mqBaseProducer; | |||
| //@Scheduled(cron = "0 */1 * * * *?") // 每5分钟检查一次 | |||
| @Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| @Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次 | |||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| public void msgReSend() { | |||
| logger.info("消息重发开始..."); | |||
| //消息重发 | |||
| @@ -157,8 +157,11 @@ public enum ErrorCode{ | |||
| TJD_DEDUCE_FEE_FAIL(2063, "TJD停车费抵扣失败"), | |||
| SHANGAN_COUPON_FAIL(2065, "优惠券失败"), | |||
| SHANGAN_CMD_FAIL(2066, "优惠券失败"), | |||
| SHANGAN_CMD_FAIL(2066, "尚安网络异常"), | |||
| BOLINK_SIGN_ERR(2068, "泊链签名错误"), | |||
| BOLINK_STOP_FEE_FAIL(2069, "泊链停车费获取失败"), | |||
| BOLINK_CMD_FAIL(2066, "泊链网络异常"), | |||
| /** | |||
| * 游戏 | |||
| @@ -0,0 +1,35 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.*; | |||
| @TableName(value = "mem_coupon_from_dsp") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class MemCouponFromDsp extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="手机号",name="phone") | |||
| private String phone; | |||
| @io.swagger.annotations.ApiModelProperty(value="投放ID",name="couponChannelId") | |||
| private Long couponChannelId; | |||
| @io.swagger.annotations.ApiModelProperty(value="券ID",name="couponId") | |||
| private Long couponId; | |||
| @io.swagger.annotations.ApiModelProperty(value="券码ID",name="couponOrderId") | |||
| private Long couponOrderId; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="状态:0-初始;1-已领券;",name="status") | |||
| private Integer status; | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.IdType; | |||
| import com.baomidou.mybatisplus.annotation.TableId; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.Date; | |||
| /** | |||
| * 系统用户Token | |||
| * | |||
| * @author Stormeye | |||
| */ | |||
| @Data | |||
| @TableName("sys_user_token") | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class SysUserToken extends BaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="用户ID",name="userId") | |||
| @TableId(type = IdType.INPUT) | |||
| private Long userId; | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="token",name="token") | |||
| private String token; | |||
| @io.swagger.annotations.ApiModelProperty(value="过期时间",name="expireTime") | |||
| private Date expireTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | |||
| private Date updateTime; | |||
| } | |||
| @@ -72,4 +72,7 @@ public class WxCreditHistoryVo extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "小票号", name = "ticketNumber") | |||
| private String ticketNumber; | |||
| @io.swagger.annotations.ApiModelProperty(value = "兑换用途", name = "changePurpose") | |||
| private String changePurpose; | |||
| } | |||
| @@ -5,12 +5,13 @@ package com.iformall.enums; | |||
| */ | |||
| public enum EnumCarVendor { | |||
| // 1-ETCP, 2-TJD | |||
| // 1-ETCP, 2-TJD停简单 3-Dahua大华, 4-ShangAn尚安, 5-BoLink泊链 | |||
| CAR_NOTFOUND(0, "无"), | |||
| CAR_ETCP(1, "ETCP"), | |||
| CAR_TJD(2, "TJD"), | |||
| CAR_DAHUA(3, "DAHUA"), | |||
| CAR_SHANGAN(4, "ShangAn"), | |||
| CAR_BOLINK(5, "BoLink"), | |||
| ; | |||
| public static EnumCarVendor getEnum(Integer code) { | |||
| @@ -13,7 +13,8 @@ public enum EnumCouponChannelType { | |||
| COUPON_CHANNEL_ID_PRESS(6, "砍价频道"), | |||
| COUPON_CHANNEL_ID_ORDER_GROUP(7, "拼团频道"), | |||
| COUPON_CHANNEL_ID_TOPIC(8, "专题"), | |||
| COUPON_CHANNEL_ID_CREDIT(50, "积分商城") | |||
| COUPON_CHANNEL_ID_CREDIT(50, "积分商城"), | |||
| COUPON_CHANNEL_ID_H5(100, "DSP的H5页面"), | |||
| ; | |||
| public static EnumCouponChannelType getEnum(Integer code) { | |||
| @@ -0,0 +1,37 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumCouponDspStatus { | |||
| //0:已接收,1:已注入 | |||
| RECEIVED(0, "已接收"), | |||
| SENT_CO(1, "已注入") | |||
| ; | |||
| public static EnumCouponDspStatus getEnum(Integer code) { | |||
| for (EnumCouponDspStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumCouponDspStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.iformall.mapper; | |||
| import java.util.*; | |||
| import com.iformall.common.CommonMapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.iformall.domain.po.MemCouponFromDsp; | |||
| public interface MemCouponFromDspMapper extends CommonMapper<MemCouponFromDsp, Long> { | |||
| List<MemCouponFromDsp> findList(MemCouponFromDsp memCouponFromDsp); | |||
| } | |||
| @@ -0,0 +1,19 @@ | |||
| package com.iformall.mapper; | |||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
| import com.iformall.domain.po.SysUserToken; | |||
| import org.apache.ibatis.annotations.Mapper; | |||
| /** | |||
| * 系统用户Token | |||
| * | |||
| * @author Stormeye Wu | |||
| */ | |||
| @Mapper | |||
| public interface SysUserTokenMapper extends BaseMapper<SysUserToken> { | |||
| SysUserToken queryByToken(String token); | |||
| SysUserToken queryByUserId(long userId); | |||
| } | |||
| @@ -9,10 +9,9 @@ import com.iformall.service.WxMsgRecordService; | |||
| import com.iformall.utils.JsonUtil; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.amqp.core.AmqpTemplate; | |||
| import org.springframework.amqp.core.Message; | |||
| import org.springframework.amqp.rabbit.core.RabbitTemplate; | |||
| import org.springframework.amqp.rabbit.support.CorrelationData; | |||
| import org.springframework.amqp.rabbit.connection.CorrelationData; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Profile; | |||
| import org.springframework.stereotype.Service; | |||
| @@ -0,0 +1,67 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.MemCouponFromDsp; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import java.util.List; | |||
| public interface MemCouponFromDspService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<MemCouponFromDsp> listAsPage(MemCouponFromDsp record, Integer pageIndex, Integer pageSize); | |||
| List<MemCouponFromDsp> getList(MemCouponFromDsp record); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| MemCouponFromDsp getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(MemCouponFromDsp record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| /** | |||
| * countByInfo | |||
| * @param record | |||
| * @return | |||
| */ | |||
| Integer countByInfo(MemCouponFromDsp record); | |||
| /** | |||
| * 注券 | |||
| * @param record | |||
| * @return | |||
| */ | |||
| Integer couponOrder(MemCouponFromDsp record); | |||
| /** | |||
| * 注券 | |||
| * @param tenantEntity | |||
| * @param phone | |||
| * @return | |||
| */ | |||
| void couponOrderFromDsp(TenantEntity tenantEntity, String phone); | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package com.iformall.service; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.SysUserToken; | |||
| /** | |||
| * 用户Token | |||
| * | |||
| * @author Stormeye | |||
| */ | |||
| public interface SysUserTokenService { | |||
| /** | |||
| * 生成token | |||
| * @param userId 用户ID | |||
| */ | |||
| SysUserToken createToken(long userId, String tenantId); | |||
| /** | |||
| * 退出,修改token值 | |||
| * @param userId 用户ID | |||
| */ | |||
| void logout(long userId); | |||
| SysUserToken queryByToken(String token); | |||
| SysUserToken queryByUserId(long userId); | |||
| MallUserInfo queryUser(Long userId); | |||
| } | |||
| @@ -205,4 +205,10 @@ public interface WxOrderService { | |||
| void exportData(WxOrderQueryVo wxOrderQueryVo, HttpServletRequest request, HttpServletResponse response); | |||
| /** | |||
| * H5支付后, 券再注入 | |||
| */ | |||
| Long saveOuterOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, String formId, Long couponPasswordId); | |||
| } | |||
| @@ -0,0 +1,143 @@ | |||
| package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.MemCouponFromDsp; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumCouponDspStatus; | |||
| import com.iformall.enums.EnumUserType; | |||
| import com.iformall.mapper.MemCouponFromDspMapper; | |||
| import com.iformall.mapper.WxCouponMapper; | |||
| import com.iformall.service.MemCouponFromDspService; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.WxOrderService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.IdWorker; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Service | |||
| public class MemCouponFromDspServiceImpl implements MemCouponFromDspService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private MemCouponFromDspMapper memCouponFromDspMapper; | |||
| @Autowired | |||
| private WxCouponMapper couponMapper; | |||
| @Autowired | |||
| private WxOrderService wxOrderService; | |||
| @Autowired | |||
| private WxCUserService wxCUserService; | |||
| @Override | |||
| public PageInfo<MemCouponFromDsp> listAsPage(MemCouponFromDsp record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> memCouponFromDspMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public List<MemCouponFromDsp> getList(MemCouponFromDsp record) { | |||
| return memCouponFromDspMapper.findList(record); | |||
| } | |||
| @Override | |||
| public MemCouponFromDsp getById(Long id) { | |||
| return memCouponFromDspMapper.selectById(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(MemCouponFromDsp record) { | |||
| Date curDate = new Date(); | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateDate(curDate); | |||
| record.setUpdateDate(curDate); | |||
| memCouponFromDspMapper.insert(record); | |||
| } else { | |||
| record.setUpdateDate(curDate); | |||
| memCouponFromDspMapper.updateById(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| memCouponFromDspMapper.deleteById(id); | |||
| } | |||
| @Override | |||
| public Integer countByInfo(MemCouponFromDsp record) { | |||
| return memCouponFromDspMapper.selectCount(new QueryWrapper<>(record)); | |||
| } | |||
| @Override | |||
| public Integer couponOrder(MemCouponFromDsp record) { | |||
| // 获取C端用户 | |||
| WxCUser user = wxCUserService.getByObject(new WxCUser() {{ | |||
| updateTenantInfo(record); | |||
| setPhone(record.getPhone()); | |||
| }}); | |||
| if (user == null) { | |||
| return -1; | |||
| } | |||
| //用于标记当前操作人为A端用户 | |||
| user.setOperatorType(EnumUserType.MALLUSER.getCode()); | |||
| user.setOperatorId(user.getId()); | |||
| // 手机是否有未注的券 | |||
| MemCouponFromDsp memQ = new MemCouponFromDsp() {{ | |||
| updateTenantInfo(record); | |||
| setPhone(record.getPhone()); | |||
| setStatus(EnumCouponDspStatus.RECEIVED.getCode()); | |||
| }}; | |||
| List<MemCouponFromDsp> couponFromDsps = memCouponFromDspMapper.findList(memQ); | |||
| for (MemCouponFromDsp memCouponFromDsp: couponFromDsps) { | |||
| // 注入券码, 无论此券是有价还是免费 | |||
| WxCoupon coupon = couponMapper.selectById(memCouponFromDsp.getCouponId()); | |||
| if (coupon != null) { | |||
| try { | |||
| Long couponOrderId = wxOrderService.saveOuterOrderForCoupon(user, coupon, memCouponFromDsp.getCouponChannelId(), null, null); | |||
| if (couponOrderId != null) { | |||
| MemCouponFromDsp updateRecord = new MemCouponFromDsp(); | |||
| updateRecord.updateTenantInfo(memCouponFromDsp); | |||
| updateRecord.setId(memCouponFromDsp.getId()); | |||
| updateRecord.setCouponOrderId(couponOrderId); | |||
| updateRecord.setStatus(EnumCouponDspStatus.SENT_CO.getCode()); | |||
| updateRecord.setUpdateDate(new Date()); | |||
| memCouponFromDspMapper.updateById(updateRecord); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| continue; | |||
| } | |||
| } | |||
| } | |||
| return 0; | |||
| } | |||
| @Override | |||
| public void couponOrderFromDsp(TenantEntity tenantEntity, String phone) { | |||
| List<MemCouponFromDsp> couponFromDsps = getList( new MemCouponFromDsp() {{ | |||
| updateTenantInfo(tenantEntity); | |||
| setPhone(phone); | |||
| }}); | |||
| for(MemCouponFromDsp memCouponFromDsp: couponFromDsps ){ | |||
| couponOrder(memCouponFromDsp); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,89 @@ | |||
| package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.SysUserToken; | |||
| import com.iformall.mapper.MallUserInfoMapper; | |||
| import com.iformall.mapper.SysUserTokenMapper; | |||
| import com.iformall.service.SysUserTokenService; | |||
| import com.iformall.utils.Constant; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.Date; | |||
| import java.util.UUID; | |||
| @Service("sysUserTokenService") | |||
| public class SysUserTokenServiceImpl implements SysUserTokenService { | |||
| @Autowired | |||
| SysUserTokenMapper sysUserTokenMapper; | |||
| @Autowired | |||
| MallUserInfoMapper mallUserInfoMapper; | |||
| @Override | |||
| public SysUserToken createToken(long userId, String tenantId) { | |||
| //生成一个token | |||
| String token = UUID.randomUUID().toString(); | |||
| //当前时间 | |||
| Date now = new Date(); | |||
| //过期时间 | |||
| Date expireTime = new Date(now.getTime() + Constant.EXPIRE); | |||
| //判断是否生成过token | |||
| SysUserToken q = new SysUserToken(); | |||
| q.setUserId(userId); | |||
| q.setTenantId(tenantId); | |||
| SysUserToken tokenEntity = sysUserTokenMapper.selectOne(new QueryWrapper<>(q)); | |||
| if(tokenEntity == null){ | |||
| tokenEntity = new SysUserToken(); | |||
| tokenEntity.setUserId(userId); | |||
| tokenEntity.setTenantId(tenantId); | |||
| tokenEntity.setToken(token); | |||
| tokenEntity.setUpdateTime(now); | |||
| tokenEntity.setExpireTime(expireTime); | |||
| //保存token | |||
| sysUserTokenMapper.insert(tokenEntity); | |||
| }else{ | |||
| tokenEntity.setToken(token); | |||
| tokenEntity.setUpdateTime(now); | |||
| tokenEntity.setExpireTime(expireTime); | |||
| //更新token | |||
| sysUserTokenMapper.updateById(tokenEntity); | |||
| } | |||
| return tokenEntity; | |||
| } | |||
| @Override | |||
| public void logout(long userId) { | |||
| //生成一个token | |||
| String token = UUID.randomUUID().toString(); | |||
| //修改token | |||
| SysUserToken tokenEntity = new SysUserToken(); | |||
| tokenEntity.setUserId(userId); | |||
| tokenEntity.setToken(token); | |||
| sysUserTokenMapper.updateById(tokenEntity); | |||
| } | |||
| @Override | |||
| public SysUserToken queryByToken(String token) { | |||
| return sysUserTokenMapper.queryByToken(token); | |||
| } | |||
| @Override | |||
| public SysUserToken queryByUserId(long userId) { | |||
| return sysUserTokenMapper.queryByUserId(userId); | |||
| } | |||
| @Override | |||
| public MallUserInfo queryUser(Long userId) { | |||
| return mallUserInfoMapper.selectById(userId); | |||
| } | |||
| } | |||
| @@ -75,6 +75,9 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| @Autowired | |||
| WxCouponPasswordService couponPasswordService; | |||
| @Autowired | |||
| WxPayAccountMapper payAccountMapper; | |||
| @Autowired | |||
| @Qualifier("couponChannelRedisTemplate") | |||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> cdRedisTemplate; | |||
| @@ -267,22 +270,37 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| List<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | |||
| //有价券判断商户是否配置了分账账号 | |||
| if (record.getSalePrice() != null && record.getSalePrice() > 0) { | |||
| StringBuffer sb = new StringBuffer(); | |||
| boolean flag = false; | |||
| for (int i = 0, size = merchantParamList.size(); i < size; i++) { | |||
| JSONObject jsonObject = merchantParamList.get(i); | |||
| Long id = jsonObject.getLong("id"); | |||
| WxMerchant wxMerchant = new WxMerchant(); | |||
| wxMerchant.setId(id); | |||
| WxMerchant merchant = wxMerchantMapper.queryMerchantByMerchantIdOfSharingReceiver(wxMerchant); | |||
| if (merchant.getId() == null) { | |||
| flag = true; | |||
| sb.append("[").append(merchant.getName()).append("]"); | |||
| boolean share = false; | |||
| WxPayAccount payQ = new WxPayAccount() {{ | |||
| updateTenantInfo(record); | |||
| }}; | |||
| try { | |||
| WxPayAccount payAccount = payAccountMapper.selectOne(new QueryWrapper<>(payQ)); | |||
| if (payAccount != null) { | |||
| share = payAccount.checkShare(); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| if (flag) { | |||
| String message = sb.toString(); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "商户:" + message + "还未配置分账账户"); | |||
| if (share) { | |||
| StringBuffer sb = new StringBuffer(); | |||
| boolean flag = false; | |||
| for (int i = 0, size = merchantParamList.size(); i < size; i++) { | |||
| JSONObject jsonObject = merchantParamList.get(i); | |||
| Long id = jsonObject.getLong("id"); | |||
| WxMerchant wxMerchant = new WxMerchant(); | |||
| wxMerchant.setId(id); | |||
| WxMerchant merchant = wxMerchantMapper.queryMerchantByMerchantIdOfSharingReceiver(wxMerchant); | |||
| if (merchant.getId() == null) { | |||
| flag = true; | |||
| sb.append("[").append(merchant.getName()).append("]"); | |||
| } | |||
| } | |||
| if (flag) { | |||
| String message = sb.toString(); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "商户:" + message + "还未配置分账账户"); | |||
| } | |||
| } | |||
| } | |||
| @@ -856,6 +856,90 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| return couponOrder; | |||
| } | |||
| /** | |||
| * 创建 couponOrder | |||
| * | |||
| * @param user | |||
| * @param order | |||
| * @param coupon | |||
| */ | |||
| private WxCouponOrder createCouponOrderForOuter(WxOrder order, WxCUser user, WxCoupon coupon, Long couponPasswordId) { | |||
| Date curr = new Date(); | |||
| Date valid_date = null; | |||
| int limit_days = Constant.WX_LIMIT_DAYS; | |||
| if (coupon.getValidType().equals(EnumValidStatus.VALID_RANGE.getCode())) { | |||
| valid_date = coupon.getValidEndDate(); | |||
| } else { | |||
| limit_days = coupon.getValidDays(); | |||
| valid_date = DateUtils.getTimeAfterDays(limit_days, curr); | |||
| } | |||
| boolean isCard = false; | |||
| // 检查是否是储值卡 | |||
| if (coupon.getType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { | |||
| isCard = true; | |||
| } | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| WxCouponOrder couponOrder = new WxCouponOrder(); | |||
| couponOrder.setId(idWorker.nextId()); | |||
| couponOrder.updateTenantInfo(order); | |||
| couponOrder.setCouponId(order.getProductId()); | |||
| couponOrder.setCouponType(coupon.getType()); | |||
| couponOrder.setCUserId(user.getId()); | |||
| couponOrder.setOwnerId(user.getId()); | |||
| couponOrder.setAutoRefund(coupon.getAutoRefund()); | |||
| couponOrder.setOrderId(order.getOrderNumber()); | |||
| couponOrder.setExpiredTime(valid_date); | |||
| if (!isCard) { | |||
| couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } else { | |||
| couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.CARD_USING.getCode()); | |||
| } | |||
| couponOrder.setCreateDate(curr); | |||
| couponOrder.setUpdateDate(curr); | |||
| couponOrder.setCouponPrice(order.getPayment()); | |||
| wxCouponOrderMapper.insert(couponOrder); | |||
| /// 储值卡信息添加 | |||
| if (isCard) { | |||
| WxPayOrder payOrder = null; | |||
| Integer fee = 0; | |||
| WxCardInfo cardInfo = new WxCardInfo(); | |||
| cardInfo.setId(couponOrder.getId()); | |||
| cardInfo.updateTenantInfo(order); | |||
| cardInfo.setCouponId(order.getProductId()); | |||
| cardInfo.setAmount(coupon.getPrice()); | |||
| cardInfo.setSaleAmount(coupon.getSalePrice()); | |||
| cardInfo.setRemainingAmount(coupon.getPrice()); | |||
| // 不论有价免费卡, 钱是线下支付, 所以不设分账 | |||
| cardInfo.setShareFeeAmount(0); | |||
| cardInfo.setRemainingShareFeeAmount(0); | |||
| cardInfo.setRateAmount(0); | |||
| if (coupon.getPasswordSupport().equals(EnumCouponPasswordSupport.SUPPORTED.getCode())) { | |||
| WxCouponPassword updateCPwd = new WxCouponPassword(); | |||
| updateCPwd.setId(couponPasswordId); | |||
| updateCPwd.setCardId(cardInfo.getId()); | |||
| updateCPwd.setStatus(EnumCouponPasswordStatus.USED.getCode()); | |||
| couponPasswordMapper.updateById(updateCPwd); | |||
| } | |||
| cardInfo.setServiceFeeAmount(fee); | |||
| cardInfo.setCreateDate(curr); | |||
| cardInfo.setUpdateDate(curr); | |||
| cardInfo.setSupportTransfer(coupon.getSupportTransfer()); | |||
| //检查卡是否下架,如果是,不可转赠 | |||
| WxCouponChannel wxCouponChannel = wxCouponChannelMapper.selectById(order.getCouponChannelId()); | |||
| if (wxCouponChannel != null && wxCouponChannel.getStatus().equals(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode())) { | |||
| cardInfo.setSupportTransfer(EnumCouponTransfer.NO.getCode()); | |||
| } | |||
| wxCardInfoMapper.insert(cardInfo); | |||
| } | |||
| return couponOrder; | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public WxCouponOrder sendFreeCouponToUser(Long userId, Long couponId, WxCouponSendVo wxCouponSendVo) { | |||
| @@ -1617,6 +1701,56 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| return record; | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public Long saveOuterOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, String formId, Long couponPasswordId) { | |||
| // 1. check user info and coupon info | |||
| userCouponMerchantCheck(user, coupon); | |||
| if (coupon.checkIsCreditCoupon()) { | |||
| //若用户剩余积分比积分售价低则不能支付 | |||
| if (user.getCredit() == null || user.getCredit() < coupon.getCreditPrice()) { | |||
| throw new MallinkException(ErrorCode.CREDIT_NOT_ENOUGH); | |||
| } | |||
| } | |||
| // 2. 减库存操作 | |||
| String couponIdStr = String.valueOf(coupon.getId()); | |||
| stockReduce(user, coupon, couponIdStr); | |||
| // 3. 当积分券或者积分停车券时 则进行积分支付 | |||
| Integer orderType; | |||
| if (coupon.checkIsCreditCoupon()) { | |||
| creditPay(user, coupon); | |||
| orderType = EnumOrderType.CREDIT.getCode(); | |||
| } else { | |||
| orderType = EnumOrderType.COUPON.getCode(); | |||
| } | |||
| // 4. 保存Order | |||
| WxOrder record = new WxOrder(); | |||
| record.setCouponChannelId(couponChannelId); | |||
| record.setType(orderType); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(0); | |||
| record.setFormId(formId); | |||
| record.setOrderGroupId(0L); | |||
| try { | |||
| saveFreeOrder(record, user, coupon); | |||
| } catch (Exception e) { | |||
| logger.error("下订单:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); | |||
| } | |||
| // 5. 创建couponOrder | |||
| try { | |||
| WxCouponOrder couponOrder = createCouponOrderForOuter(record, user, coupon, couponPasswordId); | |||
| return couponOrder.getId(); | |||
| } catch (Exception e) { | |||
| logger.error("couponOrder失败:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); | |||
| } | |||
| } | |||
| /** | |||
| * 保存订单-免费 | |||
| * | |||
| @@ -132,10 +132,15 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| //添加分账账户 | |||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| if (StringUtils.isNotBlank(appInfo.getParentAppId())) { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| } else { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| } | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||
| @@ -150,6 +155,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| try { | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||
| logger.info(response); | |||
| } catch (Exception e) { | |||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage() + e.getMessage()); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED, e.getMessage()); | |||
| @@ -278,10 +284,15 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| } else { | |||
| //删除分账账户从微信服务器 | |||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| if (StringUtils.isNotBlank(appInfo.getParentAppId())) { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| } else { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| } | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||
| @@ -431,6 +431,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| WxRentContract updateRentContract = new WxRentContract(); | |||
| updateRentContract.setId(record.getRentContractId()); | |||
| updateRentContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); | |||
| if(wxRentContract.getStatus().equals(EnumRentContractStatus.SUPPLE.getCode())){ | |||
| updateRentContract.setStatus(EnumRentContractStatus.SUPPLE.getCode()); | |||
| } | |||
| wxRentContractMapper.updateStatus(updateRentContract); | |||
| logger.info("id:{},启动审批流成功,是否补录:{}", record.getRentContractId().toString(), record.getMerchantId() != null); | |||
| } | |||
| @@ -1760,10 +1760,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| public void updatePropertyPreviewBill(WxRentContract record) { | |||
| //合并合同-更新物业账单 | |||
| if (record.getOperationType().equals(EnumContractOperationType.WHOLE.getCode())) { | |||
| //查签约 | |||
| WxPropertyContract wxPropertyContract = new WxPropertyContract(); | |||
| wxPropertyContract.setRentContractId(record.getId()); | |||
| wxPropertyContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); | |||
| WxPropertyContract propertyContract = wxPropertyContractMapper.selectOne(new QueryWrapper(wxPropertyContract)); | |||
| //查补录 | |||
| if(propertyContract==null){ | |||
| wxPropertyContract.setStatus(EnumRentContractStatus.SUPPLE.getCode()); | |||
| propertyContract = wxPropertyContractMapper.selectOne(new QueryWrapper(wxPropertyContract)); | |||
| } | |||
| if (propertyContract != null) { | |||
| propertyContract.setMerchantId(record.getMerchantId()); | |||
| wxPropertyContractMapper.updateById(propertyContract); | |||
| @@ -109,7 +109,7 @@ public class FmOpenInRedisDBConfigStorage extends WxOpenInMemoryConfigStorage { | |||
| } | |||
| @Override | |||
| public void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds) { | |||
| public void updateComponentAccessToken(String componentAccessToken, int expiresInSeconds) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.setex(this.componentAccessTokenKey, expiresInSeconds - 200, componentAccessToken); | |||
| @@ -2,7 +2,7 @@ package com.iformall.utils; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | |||
| import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; | |||
| import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; | |||
| import com.iformall.common.FmHttpClientBuilder; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -10,7 +10,7 @@ import org.apache.commons.lang3.StringUtils; | |||
| public class MaUtil { | |||
| static public WxMaService getWeappService(WxAppinfo appinfo) { | |||
| WxMaInMemoryConfig config = new WxMaInMemoryConfig(); | |||
| WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); | |||
| config.setAppid(appinfo.getAppId()); | |||
| config.setSecret(appinfo.getSecret()); | |||
| config.setToken(appinfo.getToken()); | |||
| @@ -0,0 +1,205 @@ | |||
| package com.iformall.utils.car; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.exception.MallinkException; | |||
| import org.apache.http.Consts; | |||
| import org.apache.http.HttpEntity; | |||
| import org.apache.http.HttpResponse; | |||
| import org.apache.http.client.methods.HttpPost; | |||
| import org.apache.http.entity.StringEntity; | |||
| import org.apache.http.impl.client.CloseableHttpClient; | |||
| import org.apache.http.impl.client.HttpClients; | |||
| import org.apache.http.message.BasicHeader; | |||
| import org.apache.http.protocol.HTTP; | |||
| import org.apache.http.util.EntityUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import java.io.IOException; | |||
| import java.security.MessageDigest; | |||
| import java.security.NoSuchAlgorithmException; | |||
| import java.util.Base64; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| /** | |||
| * 尚安停车 | |||
| */ | |||
| public class BoLinkUtil { | |||
| private final static Logger logger = LoggerFactory.getLogger(BoLinkUtil.class); | |||
| public static final String BOLINK_URL = "url"; | |||
| public static final String BOLINK_COMID = "comid"; | |||
| public static final String BOLINK_UNION_ID = "union_id"; | |||
| public static final String BOLINK_KEY = "key"; | |||
| public static final String BOLINK_CAR_NUMBER = "car_number"; | |||
| public static final String URL = "https://yun.bolink.club/zld/queryorderprice"; | |||
| public static final String COMID = "30536"; | |||
| public static final String UNION_ID = "200389"; | |||
| public static final String KEY = "Y29PZH9KDT1V7Y1E"; | |||
| public static final String PARK_NUM = "京88888"; | |||
| public static final String BOLINK_DATA = "data"; | |||
| public static final String BOLINK_STATE = "state"; | |||
| public static final int BOLINK_SUCCESS = 1; | |||
| public static final int BOLINK_FAIL = 0; | |||
| public static final String BOLINK_ERROR = "errmsg"; | |||
| public static void main(String[] args) throws Exception { | |||
| String carNumber = "京88888"; | |||
| String result = getStopFee(URL, COMID, UNION_ID, KEY, carNumber); | |||
| } | |||
| /** | |||
| * md5算法 | |||
| * @param data | |||
| * @return | |||
| * @throws NoSuchAlgorithmException | |||
| */ | |||
| public static String md5(String data) throws NoSuchAlgorithmException { | |||
| MessageDigest md = MessageDigest.getInstance("MD5"); | |||
| md.update(data.getBytes()); | |||
| StringBuffer buf = new StringBuffer(); | |||
| byte[] bits = md.digest(); | |||
| for(int i=0;i<bits.length;i++){ | |||
| int a = bits[i]; | |||
| if(a<0) a+=256; | |||
| if(a<16) buf.append("0"); | |||
| buf.append(Integer.toHexString(a)); | |||
| } | |||
| return buf.toString(); | |||
| } | |||
| /** | |||
| * 签名 | |||
| * @param key | |||
| * @param dataStr | |||
| * @return | |||
| * @throws NoSuchAlgorithmException | |||
| */ | |||
| public static String getSign(String key, String dataStr) throws NoSuchAlgorithmException { | |||
| StringBuilder sb = new StringBuilder(); | |||
| sb.append(dataStr).append(BOLINK_KEY).append("=").append(key); | |||
| logger.debug(sb.toString()); | |||
| String signValue = md5(sb.toString()).toUpperCase(); | |||
| logger.debug("sign: " + signValue); | |||
| return signValue; | |||
| } | |||
| public static boolean checkRespFailed(String resp) { | |||
| if(resp.startsWith("<html>") || resp.startsWith("<!DOCTYPE html>")) { | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| public static String getStopFee(String url, String comid, String unionId, String key, String carNumber) { | |||
| Map<String, String> params = new HashMap<>(); | |||
| params.put(BOLINK_COMID, comid); | |||
| params.put(BOLINK_UNION_ID, unionId); | |||
| params.put(BOLINK_CAR_NUMBER, carNumber); | |||
| try { | |||
| String sign = getSign(key, JSON.toJSONString(params)); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| try { | |||
| String result = Proc(url, key, params); | |||
| if(result == null) { | |||
| throw new MallinkException(ErrorCode.BOLINK_CMD_FAIL); | |||
| } | |||
| if(checkRespFailed(result)) { | |||
| throw new MallinkException(ErrorCode.BOLINK_CMD_FAIL); | |||
| } | |||
| return result; | |||
| } catch (Exception e) { | |||
| return null; | |||
| } | |||
| } | |||
| private static String Proc(String url, String key, Map<String, String> paramMap) { | |||
| CloseableHttpClient httpClient = HttpClients.createDefault(); | |||
| HttpPost httpPost = new HttpPost(url); | |||
| httpPost.addHeader("Accept-Encoding", "UTF-8"); | |||
| StringBuilder sb = new StringBuilder(); | |||
| String sign = null; | |||
| try{ | |||
| String dataStr = JSON.toJSONString(paramMap); | |||
| sb.append("{\"data\":").append(dataStr); | |||
| sign = getSign(key, dataStr); | |||
| sb.append(",\"sign\":\"").append(sign).append("\"}"); | |||
| }catch(NoSuchAlgorithmException e) { | |||
| logger.error(e.getLocalizedMessage()); | |||
| } | |||
| String bodyStr = sb.toString(); | |||
| logger.info(bodyStr); | |||
| final Base64.Encoder encoder = Base64.getEncoder(); | |||
| final Base64.Decoder decoder = Base64.getDecoder(); | |||
| try { | |||
| byte[] bodyByte = bodyStr.getBytes("UTF-8"); | |||
| String encodeStr = encoder.encodeToString(bodyByte); | |||
| StringEntity se = new StringEntity(encodeStr, Consts.UTF_8); | |||
| se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"UTF-8")); | |||
| httpPost.setEntity(se); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| HttpResponse response = null; | |||
| try { | |||
| response = httpClient.execute(httpPost); | |||
| } catch (Exception e) { | |||
| logger.error(e.getLocalizedMessage()); | |||
| } | |||
| String result = null; | |||
| //打印StatusLine | |||
| logger.debug("StatusLine: " + response.getStatusLine()); | |||
| try{ | |||
| //获取实体 | |||
| HttpEntity httpEntity= response.getEntity(); | |||
| String encodeResStr = EntityUtils.toString(httpEntity, "UTF-8"); | |||
| result = new String(decoder.decode(encodeResStr), "UTF-8"); | |||
| logger.debug(result); | |||
| // {"data":{"errmsg":"查询价格返回超时,请联系车场管理员","state":0,"plate_number":"京88888"},"sign":"DE81DCA41E6C1ACA978906F998A7BC1D"} | |||
| } catch (Exception e) { | |||
| logger.error(e.getLocalizedMessage()); | |||
| } | |||
| try { //关闭流并释放资源 | |||
| httpClient.close(); | |||
| } catch (IOException e) { | |||
| logger.error(e.getLocalizedMessage()); | |||
| } | |||
| JSONObject resultObj = JSON.parseObject(result); | |||
| String resSign = resultObj.getString("sign"); | |||
| if (!resSign.equals(sign)) { | |||
| logger.error("data sign: " + resSign); | |||
| throw new MallinkException(ErrorCode.BOLINK_SIGN_ERR); | |||
| } | |||
| return result; | |||
| } | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.MemCouponFromDspMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.MemCouponFromDsp"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="phone" jdbcType="VARCHAR" property="phone" /> | |||
| <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId" /> | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||
| <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`phone`,`coupon_channel_id`,`coupon_id`,`coupon_order_id`,`create_date`,`update_date`,`status` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != phone "> | |||
| and `phone` = #{phone} | |||
| </if> | |||
| <if test=" null != couponChannelId "> | |||
| and `coupon_channel_id` = #{couponChannelId} | |||
| </if> | |||
| <if test=" null != couponId "> | |||
| and `coupon_id` = #{couponId} | |||
| </if> | |||
| <if test=" null != couponOrderId "> | |||
| and `coupon_order_id` = #{couponOrderId} | |||
| </if> | |||
| <if test=" null != createDate "> | |||
| and `create_date` = #{createDate} | |||
| </if> | |||
| <if test=" null != updateDate "> | |||
| and `update_date` = #{updateDate} | |||
| </if> | |||
| <if test=" null != status "> | |||
| and `status` = #{status} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.MemCouponFromDsp" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from mem_coupon_from_dsp | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||
| @@ -0,0 +1,11 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.SysUserTokenMapper"> | |||
| <select id="queryByToken" resultType="com.iformall.domain.po.SysUserToken"> | |||
| select * from sys_user_token where token = #{value} | |||
| </select> | |||
| <select id="queryByUserId" resultType="com.iformall.domain.po.SysUserToken"> | |||
| select * from sys_user_token where user_id = #{value} | |||
| </select> | |||
| </mapper> | |||
| @@ -832,11 +832,11 @@ | |||
| wc.tenant_id,wc.`type`,wc.`cover_img`,wc.`cover_picture`,wc.`detail_picture`,wc.`title`,wc.`sub_title`,wc.`sale_price`,wc.`use_price`,wc.`use_limit_quantity`,wc.`send_type`, | |||
| wc.`valid_type`,wc.`valid_start_date`,wc.`valid_end_date`,wc.`valid_days`,wc.`detail`,wc.`price`,wc.`unit`,wc.`remain_inventory`,wc.`inventory`, | |||
| wc.`remark`,wc.`status`,wc.`create_date`,wc.`update_date`,wc.`business`,wc.`sub_business`,wc.`support_transfer`,wc.`subsidy_num`,wc.`subsidy_type`, | |||
| wc.`press_limit_num`, wc.`press_limit_hours`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions` | |||
| ,wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture,wc.id as couponId from wx_coupon_channel ct left join | |||
| wx_coupon wc on wc.id = ct.coupon_id | |||
| where ct.`sub_target_id` = #{id} | |||
| and ct.status = 0 | |||
| wc.`press_limit_num`, wc.`press_limit_hours`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`, | |||
| wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture,wc.id as couponId | |||
| from wx_coupon_channel ct | |||
| left join wx_coupon wc on wc.id = ct.coupon_id | |||
| where ct.`sub_target_id` = #{id} and ct.status = 0 | |||
| </select> | |||
| <select id="findCouponModel" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon"> | |||
| @@ -154,7 +154,8 @@ | |||
| case when credit.operator_type=4 then (select name from mall_user_info where id=credit.operator_id) | |||
| when credit.operator_type=3 then (select name from wx_merchant_b_user where id=credit.operator_id) | |||
| when credit.operator_type=1 then (select nick_name from wx_c_user where id=credit.operator_id) | |||
| else '' end operator | |||
| else '' end operator, | |||
| credit.change_purpose changePurpose | |||
| FROM | |||
| wx_c_user_basic_info basic | |||
| INNER JOIN wx_credit_history credit ON basic.id = credit.c_user_id | |||
| @@ -13,8 +13,8 @@ | |||
| <artifactId>mallinkSysAdmin</artifactId> | |||
| <properties> | |||
| <weixin-java-mp.version>3.3.0</weixin-java-mp.version> | |||
| <weixin-java-open.version>3.3.0</weixin-java-open.version> | |||
| <weixin-java-mp.version>3.6.0</weixin-java-mp.version> | |||
| <weixin-java-open.version>3.6.0</weixin-java-open.version> | |||
| </properties> | |||
| <dependencies> | |||
| @@ -1,11 +0,0 @@ | |||
| package com.iformall.advice; | |||
| import org.springframework.web.bind.annotation.ControllerAdvice; | |||
| import org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice; | |||
| @ControllerAdvice | |||
| public class JsonpAdvice extends AbstractJsonpResponseBodyAdvice { | |||
| public JsonpAdvice() { | |||
| super("callback"); | |||
| } | |||
| } | |||
| @@ -1,33 +0,0 @@ | |||
| package com.iformall.config; | |||
| import me.chanjar.weixin.mp.api.WxMpConfigStorage; | |||
| import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage; | |||
| import me.chanjar.weixin.mp.api.WxMpService; | |||
| import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; | |||
| 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; | |||
| } | |||
| @Bean | |||
| public WxMpConfigStorage wxConfigProvider(){ | |||
| WxMpInMemoryConfigStorage wxConfigProvider = new WxMpInMemoryConfigStorage(); | |||
| wxConfigProvider.setAppId(wechatWebProperties.getAppId()); | |||
| wxConfigProvider.setSecret(wechatWebProperties.getSecret()); | |||
| return wxConfigProvider; | |||
| } | |||
| } | |||
| @@ -1,59 +0,0 @@ | |||
| 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); | |||
| } | |||
| } | |||
| @@ -27,16 +27,16 @@ | |||
| <parent> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-parent</artifactId> | |||
| <version>2.0.9.RELEASE</version> | |||
| <version>2.1.8.RELEASE</version> | |||
| <relativePath/> | |||
| </parent> | |||
| <properties> | |||
| <weixin-java-common.version>3.3.0</weixin-java-common.version> | |||
| <weixin-java-mp.version>3.3.0</weixin-java-mp.version> | |||
| <weixin-java-miniapp.version>3.3.0</weixin-java-miniapp.version> | |||
| <weixin-java-pay.version>3.3.0</weixin-java-pay.version> | |||
| <weixin-java-open.version>3.3.0</weixin-java-open.version> | |||
| <weixin-java-common.version>3.6.0</weixin-java-common.version> | |||
| <weixin-java-mp.version>3.6.0</weixin-java-mp.version> | |||
| <weixin-java-miniapp.version>3.6.0</weixin-java-miniapp.version> | |||
| <weixin-java-pay.version>3.6.0</weixin-java-pay.version> | |||
| <weixin-java-open.version>3.6.0</weixin-java-open.version> | |||
| <quartz.version>2.3.0</quartz.version> | |||
| </properties> | |||
| @@ -240,6 +240,11 @@ | |||
| <!-- <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> | |||
| @@ -286,7 +291,7 @@ | |||
| <dependency> | |||
| <groupId>cn.afterturn</groupId> | |||
| <artifactId>easypoi-spring-boot-starter</artifactId> | |||
| <version>4.0.0</version> | |||
| <version>4.1.2</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> | |||