| @@ -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 '部署完成' | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -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"); | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -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]' | |||
| ) | |||
| ; | |||
| @@ -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,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; | |||
| @@ -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; | |||
| } | |||
| @@ -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"); | |||
| @@ -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"> | |||
| @@ -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"); | |||
| } | |||
| } | |||
| @@ -27,7 +27,7 @@ | |||
| <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> | |||
| @@ -44,12 +44,14 @@ | |||
| <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> | |||
| @@ -240,6 +242,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 +293,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 --> | |||