From d87cd066de1e52cdbf39754fb79eacf7452fad36 Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Tue, 16 Jan 2024 22:30:49 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BA=91=E5=9B=9E=E8=B0=83=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E6=8E=A5=E5=8F=A3=E4=B8=8E=E7=AD=96=E7=95=A5=E8=B0=83?= =?UTF-8?q?=E7=94=A8;=E8=BD=AE=E6=92=AD=E5=9B=BE;=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=B0=83=E6=95=B4;=E7=99=BD=E5=90=8D?= =?UTF-8?q?=E5=8D=95=E8=B7=AF=E5=BE=84=E8=AF=B7=E6=B1=82=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?;=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E6=A0=A1=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/cloudDb/core/dto/CloudStoreDto.java | 51 ++++++ .../handler/CloudDataImportHandler.java | 18 ++ .../cloudDb/handler/CloudStoreHandler.java | 64 +++++++ .../cpop/core/annontation/SignatureCheck.java | 15 ++ .../annontation/SimpleSignatureCheck.java | 15 ++ .../core/aspect/SignatureCheckAspect.java | 148 ++++++++++++++++ .../aspect/SimpleSignatureCheckAspect.java | 138 +++++++++++++++ .../cpop/core/base/entity/CpopSignBase.java | 33 ++++ .../java/com/cpop/core/utils/RsaUtils.java | 47 ++++- .../src/main/resources/mapper/CoreMapper.xml | 3 + .../com/cpop/generator/CpopGenerator.java | 6 +- .../business/bo/CardTemplateUnionBo.java | 135 +++++++++++++++ .../backstage/CardTemplateController.java | 15 ++ .../backstage/EasyLearnController.java | 5 +- .../jambox/business/entity/CardTemplate.java | 16 +- .../business/service/CardTemplateService.java | 13 +- .../service/EasyLearnOrderService.java | 6 +- .../service/impl/CardTemplateServiceImpl.java | 45 ++++- .../impl/EasyLearnOrderServiceImpl.java | 8 +- .../src/main/resources/application-dev.yml | 9 +- .../mall/web/CpopMallWebApplicationTests.java | 4 +- .../com/cpop/mall/business/bo/CarouselBo.java | 55 ++++++ .../BackstageCarouselController.java | 132 ++++++++++++++ .../mini/MiniProductController.java | 23 +++ .../cpop/mall/business/entity/Carousel.java | 74 ++++++++ .../mall/business/mapper/CarouselMapper.java | 14 ++ .../business/service/CarouselService.java | 41 +++++ .../service/impl/CarouselServiceImpl.java | 79 +++++++++ .../service/impl/ProductServiceImpl.java | 12 +- .../cpop/mall/business/vo/CarouselListVo.java | 41 +++++ .../cpop/mall/business/vo/CarouselPageVo.java | 54 ++++++ .../mall/business/vo/ProductSimpleVo.java | 25 +++ .../main/resources/mapper/CarouselMapper.xml | 7 + .../src/main/resources/application-dev.yml | 4 +- .../java/com/cpop/oam/web/CpopApiTests.java | 12 +- .../java/com/cpop/oam/web/CpopCoreTests.java | 35 +++- .../com/cpop/oam/web/CpopDataSyncTests.java | 62 +++++++ .../com/cpop/oam/web/CpopImportTests.java | 4 +- Cpop-Oam/pom.xml | 4 - .../oam/business/bo/CloudUnionCallbackBo.java | 163 ++++++++++++++++++ .../controller/backstage/WxPayController.java | 1 - .../callback/CloudCallbackController.java | 42 +++++ .../service/impl/BusinessServiceImpl.java | 6 +- .../service/impl/DataImportServiceImpl.java | 21 +-- .../service/impl/TaskServiceImpl.java | 2 +- .../framework/enums/CloudCallbackEnums.java | 50 ++++++ .../strategy/cloud/CloudCallbackStrategy.java | 19 ++ .../CloudDataImportCallbackStrategy.java | 43 +++++ ...CloudSyncBrandOrStoreCallbackStrategy.java | 84 +++++++++ Cpop-System/pom.xml | 4 + .../com/cpop/system/business/bo/StoreBo.java | 60 +++++++ .../cpop/system/business/bo/StoreRenewBo.java | 5 +- .../business/controller/StoreController.java | 15 ++ .../controller/SysCommonController.java | 1 + .../cpop/system/business/entity/Store.java | 4 +- .../system/business/service/StoreService.java | 9 + .../service/impl/StoreRenewServiceImpl.java | 26 ++- .../service/impl/StoreServiceImpl.java | 33 +++- .../cpop/system/business/vo/StorePageVo.java | 6 + 59 files changed, 1966 insertions(+), 100 deletions(-) create mode 100644 Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudStoreDto.java create mode 100644 Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudDataImportHandler.java create mode 100644 Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudStoreHandler.java create mode 100644 Cpop-Core/src/main/java/com/cpop/core/annontation/SignatureCheck.java create mode 100644 Cpop-Core/src/main/java/com/cpop/core/annontation/SimpleSignatureCheck.java create mode 100644 Cpop-Core/src/main/java/com/cpop/core/aspect/SignatureCheckAspect.java create mode 100644 Cpop-Core/src/main/java/com/cpop/core/aspect/SimpleSignatureCheckAspect.java create mode 100644 Cpop-Core/src/main/java/com/cpop/core/base/entity/CpopSignBase.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/bo/CarouselBo.java create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageCarouselController.java create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/entity/Carousel.java create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/mapper/CarouselMapper.java create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/service/CarouselService.java create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/CarouselServiceImpl.java create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/vo/CarouselListVo.java create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/vo/CarouselPageVo.java create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductSimpleVo.java create mode 100644 Cpop-Mall/src/main/resources/mapper/CarouselMapper.xml create mode 100644 Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/bo/CloudUnionCallbackBo.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/controller/callback/CloudCallbackController.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/framework/enums/CloudCallbackEnums.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudCallbackStrategy.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudDataImportCallbackStrategy.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudSyncBrandOrStoreCallbackStrategy.java create mode 100644 Cpop-System/src/main/java/com/cpop/system/business/bo/StoreBo.java diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudStoreDto.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudStoreDto.java new file mode 100644 index 0000000..652c48b --- /dev/null +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudStoreDto.java @@ -0,0 +1,51 @@ +package com.cpop.api.cloudDb.core.dto; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-15 11:18 + */ +@Data +@Accessors(chain = true) +public class CloudStoreDto { + + /** + * 云校区id + */ + @SerializedName("storeId") + private String storeCloudId; + + /** + * 云品牌id + */ + @SerializedName("brandId") + private String brandCloudId; + + /** + * 云校区名 + */ + @SerializedName("name") + private String storeName; + + /** + * 负责人 + */ + @SerializedName("principalName") + private String personCharge; + + /** + * 手机号 + */ + private String phone; + + /** + * 云校区id + */ + @SerializedName("address") + private String storeAddr; + +} diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudDataImportHandler.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudDataImportHandler.java new file mode 100644 index 0000000..f26fe45 --- /dev/null +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudDataImportHandler.java @@ -0,0 +1,18 @@ +package com.cpop.api.cloudDb.handler; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +/** + * 数据导入 + * @author DB + * @version 1.0.0 + * @since 2024-01-14 11:38 + */ +@Component +public class CloudDataImportHandler { + + @Autowired + private RestTemplate restTemplate; +} diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudStoreHandler.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudStoreHandler.java new file mode 100644 index 0000000..25420ad --- /dev/null +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudStoreHandler.java @@ -0,0 +1,64 @@ +package com.cpop.api.cloudDb.handler; + +import com.alibaba.fastjson.JSONObject; +import com.cpop.api.cloudDb.core.constant.CloudDbUrl; +import com.cpop.api.cloudDb.core.dto.CloudOrderDto; +import com.cpop.api.cloudDb.core.dto.CloudStoreDto; +import com.cpop.common.utils.StringUtils; +import com.cpop.core.base.entity.ExtendPage; +import com.cpop.core.base.exception.UtilException; +import com.mybatisflex.core.paginate.Page; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 云校区工具类 + * @author DB + * @version 1.0.0 + * @since 2024-01-15 11:16 + */ +@Component +public class CloudStoreHandler { + + @Autowired + private RestTemplate restTemplate; + + /** + * 更新校区 + * @author DB + * @since 2024/1/15 + * @param dto 入参 + */ + public void updateStore(CloudStoreDto dto) { + JSONObject jsonBody = new JSONObject(); + jsonBody.put("_type", "storeEdit"); + //云校区id + jsonBody.put("storeId", dto.getStoreCloudId()); + if (StringUtils.isNotBlank(dto.getBrandCloudId())) { + jsonBody.put("brandId", dto.getBrandCloudId()); + } + if (StringUtils.isNotBlank(dto.getStoreName())) { + jsonBody.put("name", dto.getStoreName()); + } + if (StringUtils.isNotBlank(dto.getPersonCharge())) { + jsonBody.put("principalName", dto.getPersonCharge()); + } + if (StringUtils.isNotBlank(dto.getPhone())) { + jsonBody.put("phone", dto.getPhone()); + } + if (StringUtils.isNotBlank(dto.getStoreAddr())) { + jsonBody.put("address", dto.getStoreAddr()); + } + JSONObject jsonObject = restTemplate.postForObject(CloudDbUrl.COMMON_CARD_URL, jsonBody, JSONObject.class); + if (jsonObject != null) { + if (!jsonObject.getBoolean("success")) { + throw new UtilException(jsonObject.getString("error")); + } + } + } +} diff --git a/Cpop-Core/src/main/java/com/cpop/core/annontation/SignatureCheck.java b/Cpop-Core/src/main/java/com/cpop/core/annontation/SignatureCheck.java new file mode 100644 index 0000000..84a1249 --- /dev/null +++ b/Cpop-Core/src/main/java/com/cpop/core/annontation/SignatureCheck.java @@ -0,0 +1,15 @@ +package com.cpop.core.annontation; + +import java.lang.annotation.*; + +/** + * @author: DB + * @Date: 2023/08/08/9:49 + * @Description: 自定义签名校验 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SignatureCheck { + +} diff --git a/Cpop-Core/src/main/java/com/cpop/core/annontation/SimpleSignatureCheck.java b/Cpop-Core/src/main/java/com/cpop/core/annontation/SimpleSignatureCheck.java new file mode 100644 index 0000000..e95d734 --- /dev/null +++ b/Cpop-Core/src/main/java/com/cpop/core/annontation/SimpleSignatureCheck.java @@ -0,0 +1,15 @@ +package com.cpop.core.annontation; + +import java.lang.annotation.*; + +/** + * 简易校验签名 + * @author DB + * @version 1.0.0 + * @since 2024-01-16 10:31 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SimpleSignatureCheck { +} diff --git a/Cpop-Core/src/main/java/com/cpop/core/aspect/SignatureCheckAspect.java b/Cpop-Core/src/main/java/com/cpop/core/aspect/SignatureCheckAspect.java new file mode 100644 index 0000000..20b7b73 --- /dev/null +++ b/Cpop-Core/src/main/java/com/cpop/core/aspect/SignatureCheckAspect.java @@ -0,0 +1,148 @@ +package com.cpop.core.aspect; + +import com.cpop.common.utils.StringUtils; +import com.cpop.core.base.R; +import com.cpop.core.base.exception.ServiceException; +import com.cpop.core.base.exception.UtilException; +import com.cpop.core.utils.RsaUtils; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.DigestUtils; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; + +import javax.servlet.http.HttpServletRequest; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.Key; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 自定义前面校验 + * @author DB + * @version 1.0.0 + * @since 2024-01-16 10:01 + */ +@Aspect +@Component +@Slf4j +public class SignatureCheckAspect { + + @Autowired + private RsaUtils rsaUtils; + + private static final Map APP_IDS = new HashMap() {{ + //数币 + put("1688842965582499840", new String[]{"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmsFHkB4iIdVSgaz8u8QG66wiZupgSbu2T/ml/kdPm2vemsKgvEqUqp1gR6ulfHcPF8otjVbjiE8q8oR70XfxFIREbomTUmpsOzurLFrAmVhyvu6/tY23/txjQoeeH/tlCy7Lq/TL1AqPKyBcGzsQ4yInpIgRWpXz7fmJCTRw07tyE+4lpXBqiaLdWrkkGG00LnHQAOfcUoXf0TdxFPSfRHiBikfbkmgeVoU66RGlUEXU2esTY2nYGvFn+FqWsNkGEnn2YxIqgbQQ1zNX33+FWBlba1WdQtc8mTJAleaPGXmFnQiEMb55b7xVPjyyCWt6aRwl97KQgtCmfsoPZUWwQQIDAQAB", "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCawUeQHiIh1VKBrPy7xAbrrCJm6mBJu7ZP+aX+R0+ba96awqC8SpSqnWBHq6V8dw8Xyi2NVuOITyryhHvRd/EUhERuiZNSamw7O6ssWsCZWHK+7r+1jbf+3GNCh54f+2ULLsur9MvUCo8rIFwbOxDjIiekiBFalfPt+YkJNHDTu3IT7iWlcGqJot1auSQYbTQucdAA59xShd/RN3EU9J9EeIGKR9uSaB5WhTrpEaVQRdTZ6xNjadga8Wf4Wpaw2QYSefZjEiqBtBDXM1fff4VYGVtrVZ1C1zyZMkCV5o8ZeYWdCIQxvnlvvFU+PLIJa3ppHCX3spCC0KZ+yg9lRbBBAgMBAAECggEAdstPp+25vccHYsvr5icAOQEWF3JrH66csJ+vMJaFIYWYh6xHvsJxhNbyBZJZokWyrExi01CTsRs0mJ3iflVYFqvB7ChnkqhnFMElERNJLW2cB702JKP5TgbXm0aHt30/f2oYppNvtAG3DR/2FGEvAWxCiiZ5S9Q4P8GB1DMROTZBpYQgVlN9vOxqgcy8SsJyruy0xsEP3RIKko9UQ7Y9y/b6TbNOJDx/ZpC9KcOUmI8Or73IMdG1ZucumzHNO3dS2XKL7qeTQ8AWMwwAk2ZsCRx9g05QLiW3+7ZrpmOMwI3wCeJOoxhUQKijCXI3B8Rh1cU++CMk4LdyPOe78PYEEQKBgQDnyOL69Ck6+xe1EJ2HAEDPla5ujCexv6ctYvSernhI6OsMVCWa1D5rCqzC4L0IvRW7/m5lUSWlSzpfIGhSGc+PNyIaYsyYMbaIV5e8LKRp8SxUDrTA4IfYmxoXdYyq2l0PSkBPKMJ2ZyWlRoGGEC432IsiY+GBaznvHwIYFvkYHwKBgQCq7DkJYT6du/bQ2uoZv6hYYIGTY4A9TzjJ0Kp5O00BUz5zNpgBUfb1SmuISHwGyN1hOWFntR0uwfj/BUDvtG0b07k1Xz+4UWXsDqtS6eEnvUR6q/i2yWWGjCMS74t61FZopV6AxHneJV2S6Tt26MFK0VbrCwXaiYg/3tMYgC2rnwKBgF0kfRIby/XHsV8xrhvyHhlNLSt/ZvQm8Cds/KBHvE6QSuRJbFMrt2mMgKBPb6dzVKiXNgXA9j/WWz6e500W0jHbFflEerMuRwvDJ1aXGfr4z7d3sWtQz0ZcDcAfnMeLuJnMXMtytbKfAKHKE4KsPeZzPnYzbQt063MMIutLUA5BAoGBAIduFONxwgOJY8+pJcSxL9qW3RTDymDJ3N1MEUdtzV43b0wq/dZN87f396xMgrl9fqwCo0NhJnZeC8VFjGZiN/HMmPvJNNv+4xtfpDBWUKkENrZcfP2YJnGtqDzgwUvZ432XSoINK+LxCGvXkd5uHnoB1TT3zvOR9ftluy22onlRAoGBAKkIZmwW/2H/86ILrCDyARK4obULB4op8IyrunZ+lH14DksxbL7fmTsSbLyRX7oD/QvGJIuc0EDkgONztsAn5vrETv8Z6RqyKdoZZI3sAQWIBc0om6nH2zqJDIs+mep96DOg/jJAcgiVhyIoFP91IvHY7pvKwy5MTttdZLvvS2XB"}); + }}; + + @Pointcut("@annotation(com.cpop.core.annontation.SignatureCheck)") + public void signatureCheck() {} + + /** + * 前置通知 + * @author DB + * @since 2024/1/16 + * @param joinPoint 切入点 + */ + @Before(value = "signatureCheck()") + public void beforePointcut(JoinPoint joinPoint) throws IllegalAccessException { + //获取RequestAttributes + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + //从获取RequestAttributes中获取HttpServletRequest的信息 + assert requestAttributes != null; + HttpServletRequest request = (HttpServletRequest) requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST); + assert request != null; + Object object = joinPoint.getArgs()[0]; + //验签拼接字段 + List signString = new ArrayList(); + //获取父类(公共类必传属性) + Field[] fatherFields = object.getClass().getSuperclass().getDeclaredFields(); + String signature = null; + String appId = null; + for (Field field : fatherFields) { + field.setAccessible(true); + if (StringUtils.equals("signature", field.getName())) { + signature = (String) field.get(object); + continue; + } + if (StringUtils.equals("appId", field.getName())) { + String[] strings = APP_IDS.get((String) field.get(object)); + if (null == strings){ + throw new ServiceException("appId匹配失败,请核实appId"); + } + appId = strings[0]; + } + signString.add(field.getName() + "=" + field.get(object)); + } + if (null == signature){ + throw new ServiceException("签名不存在,请核实签名"); + //return ResultDTO.fail("签名不存在,请核实签名"); + } + //可能为空参 + Field[] fields = object.getClass().getDeclaredFields(); + if (fields.length > 0) { + for (Field field : fields) { + field.setAccessible(true); + if(null == field.get(object)){ + signString.add(field.getName() + "="); + } else { + signString.add(field.getName() + "=" + field.get(object)); + } + } + } + //按照字母排序 + String sign = signString.stream().sorted().collect(Collectors.joining("&")) + appId; + String md5DigestAsHex = DigestUtils.md5DigestAsHex(sign.getBytes()); + if (!StringUtils.equals(md5DigestAsHex,signature)){ + throw new ServiceException("签名匹配失败,请核实签名"); + } + } + + /** + * 环绕通知,不做处理 + * @author DB + * @since 2024/1/16 + * @param joinPoint 请求 + * @return Object + */ + @Around("signatureCheck()") + public Object aroundPointcut(ProceedingJoinPoint joinPoint) throws Throwable { + return joinPoint.proceed(joinPoint.getArgs()); + } + + /** + * 异常通知:目标方法发生异常的时候执行以下代码,此时返回通知不会再触发 + * value 属性:绑定通知的切入点表达式。可以关联切入点声明,也可以直接设置切入点表达式 + * pointcut 属性:绑定通知的切入点表达式,优先级高于 value,默认为 "" + * throwing 属性:与方法中的异常参数名称一致, + * + * @param ex:捕获的异常对象,名称与 throwing 属性值一致 + */ + @AfterThrowing(pointcut = "signatureCheck()", throwing = "ex") + public Object aspectAfterThrowing(JoinPoint jp, Exception ex) { + String methodName = jp.getSignature().getName(); + if (ex instanceof ServiceException) { + log.error("【异常通知】" + methodName + "方法算术异常(ArithmeticException):" + ex.getMessage()); + return R.fail(ex.getMessage()); + } else { + log.error("【异常通知】" + methodName + "方法异常:" + ex.getMessage()); + return R.fail("签名不合法"); + } + } + +} diff --git a/Cpop-Core/src/main/java/com/cpop/core/aspect/SimpleSignatureCheckAspect.java b/Cpop-Core/src/main/java/com/cpop/core/aspect/SimpleSignatureCheckAspect.java new file mode 100644 index 0000000..18ee66b --- /dev/null +++ b/Cpop-Core/src/main/java/com/cpop/core/aspect/SimpleSignatureCheckAspect.java @@ -0,0 +1,138 @@ +package com.cpop.core.aspect; + +import com.cpop.common.utils.StringUtils; +import com.cpop.core.base.R; +import com.cpop.core.base.exception.ServiceException; +import com.cpop.core.base.exception.UtilException; +import com.cpop.core.utils.RsaUtils; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.DigestUtils; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; + +import javax.servlet.http.HttpServletRequest; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.nio.charset.StandardCharsets; +import java.security.Key; +import java.util.HashMap; +import java.util.Map; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-16 10:31 + */ +@Aspect +@Component +@Slf4j +public class SimpleSignatureCheckAspect { + + @Autowired + private RsaUtils rsaUtils; + + private static final Map APP_IDS = new HashMap() {{ + //果酱内部 + put("1747095325571944448", new String[]{"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkPn6JRxgY3/cxyeEQ3xETlI6tcsq4d2GGrgD2pnQ8Db2vaSCEu3k4cV92/HjmoggA09A7cepurO6xeFwya9C8c1YD4UHJQ13MPlKIskDmoc/ZUyklVQKVp60pvi/BpuhECt6LksHu9Yz2ECUBiFXDd2Pgju41Oiu6joIJylWdbUkhTesOs/XnPCUjWw2kQzhpcmoMZwlgneuvGXO72OhI2FD5QTHA00UbnbtzM3hk9cQNRxak+sNzKkv4AOZy5uTjHXVdYcUUwDc7XbuWN/E40tzbyWmoZSuXPt80vOk+KgCEOK+sfPy6YPgxAYh4NOk59qA4x1ZaYSJsLRNo1c/OwIDAQAB", + "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCQ+folHGBjf9zHJ4RDfEROUjq1yyrh3YYauAPamdDwNva9pIIS7eThxX3b8eOaiCADT0Dtx6m6s7rF4XDJr0LxzVgPhQclDXcw+UoiyQOahz9lTKSVVApWnrSm+L8Gm6EQK3ouSwe71jPYQJQGIVcN3Y+CO7jU6K7qOggnKVZ1tSSFN6w6z9ec8JSNbDaRDOGlyagxnCWCd668Zc7vY6EjYUPlBMcDTRRudu3MzeGT1xA1HFqT6w3MqS/gA5nLm5OMddV1hxRTANztdu5Y38TjS3NvJaahlK5c+3zS86T4qAIQ4r6x8/Lpg+DEBiHg06Tn2oDjHVlphImwtE2jVz87AgMBAAECggEABg36jWw29lDTtpmG446gB6lVfFwkyVQIEruWpZ2A5VdWTKs/J205/tfRnsrmV4DR3XGE46lQBFUXOsZkgHfKUvDheZxzpO+AB9KRbwx4Ew8M7b0aroXY/K8aGlMPH0aGnndCXgaSJx0WAzUHOY5Q5WpYYPb/jBy/mVadGo2WZ8n9cMQQSVwdVFxsGOHckPQePyK41fsjQ6A7pNiW3ErK5TCQ18gimLAbjBeUDj5NKfe8P6o65uETkRBPE+ZL6O95hueqj7FU/8LtBFVXCFmpYLDa0BBRxZCgJP94lnS/GIo2qYkVMJh4fThWh6ZxvscggaWmVPGqhP2zzSDQup+A+QKBgQDtKD5ZdG5KeDC9jMn3HQGYAf8aiNVx0KNxpCn19uRrclNgaEFPPLj/6yWeclqPOAqzk4AGQ+MaMEQzTmHOP7O411jIgX2Ki2D9OilZjr+kObdGoekWGzZKPm38EqP+Z9oAJxNGDBkUe1iH/DUoLGgp1mt19cZn1pPgdR9vsmZwxQKBgQCcfskmHrt3NltXrOzwV3PWwelsA+E+DVn3N9N9+V8ETs0pIxFAg6LuDVxVQziLe2wApp3dy8b/efxnRUYmiFDBUxKf9CQJcZTDncHO/wASObEHlUqcIkBM9Vcy8EMovKSNrNnJHcvNV7zQaRHZshft2rPKnUaIMb0M3H6GokHv/wKBgBc4lopJxTbTd+pHa8sfcvWAVIszlLq1NBu/eEBWMV1370QEUUjB6FdenetaxRU65olYyvNSGF2LFlJzvU3lnOJfa5kOXM2BAjkpRb04JfmdkR2AYwNAHNu+KyTAaoBRiN309YUpUBdaUHvYLRhG6NgX36PIMeoe75HNxgs4y6EFAoGAcvyNm97U68Ea2I8NAYOgb9nHQ0COjeONiSKR2WwTrryf7mv/zyFp4/QZNeTQdVxYfRnvwPpr22esV80EwGdEvuflNXZTzESShDE0KH4hdULCmsnNKm/YQzO5wIndLt99IUQyOZ4VE2o2KAQrw4MiJfieRm/NVWEGgZ65sP8j580CgYEA2iNWW8jkLQhyPwOG4EztXmoTlCJUcwCmgjnL4dlRzAhsCooY+saXG0Q4GlRTJtpgXNM7kFGgAPjBSk57u6xh5I0/Tet8SWagNC2zLTcP2Bk1y2HtjWG+mSHAGEcth6etgnZgrU5daIVRJyTfslYX0i7x6o5EnCzJV0ftIBYstZ4="}); + //数币 + put("1688842965582499840", new String[]{"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmsFHkB4iIdVSgaz8u8QG66wiZupgSbu2T/ml/kdPm2vemsKgvEqUqp1gR6ulfHcPF8otjVbjiE8q8oR70XfxFIREbomTUmpsOzurLFrAmVhyvu6/tY23/txjQoeeH/tlCy7Lq/TL1AqPKyBcGzsQ4yInpIgRWpXz7fmJCTRw07tyE+4lpXBqiaLdWrkkGG00LnHQAOfcUoXf0TdxFPSfRHiBikfbkmgeVoU66RGlUEXU2esTY2nYGvFn+FqWsNkGEnn2YxIqgbQQ1zNX33+FWBlba1WdQtc8mTJAleaPGXmFnQiEMb55b7xVPjyyCWt6aRwl97KQgtCmfsoPZUWwQQIDAQAB", "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCawUeQHiIh1VKBrPy7xAbrrCJm6mBJu7ZP+aX+R0+ba96awqC8SpSqnWBHq6V8dw8Xyi2NVuOITyryhHvRd/EUhERuiZNSamw7O6ssWsCZWHK+7r+1jbf+3GNCh54f+2ULLsur9MvUCo8rIFwbOxDjIiekiBFalfPt+YkJNHDTu3IT7iWlcGqJot1auSQYbTQucdAA59xShd/RN3EU9J9EeIGKR9uSaB5WhTrpEaVQRdTZ6xNjadga8Wf4Wpaw2QYSefZjEiqBtBDXM1fff4VYGVtrVZ1C1zyZMkCV5o8ZeYWdCIQxvnlvvFU+PLIJa3ppHCX3spCC0KZ+yg9lRbBBAgMBAAECggEAdstPp+25vccHYsvr5icAOQEWF3JrH66csJ+vMJaFIYWYh6xHvsJxhNbyBZJZokWyrExi01CTsRs0mJ3iflVYFqvB7ChnkqhnFMElERNJLW2cB702JKP5TgbXm0aHt30/f2oYppNvtAG3DR/2FGEvAWxCiiZ5S9Q4P8GB1DMROTZBpYQgVlN9vOxqgcy8SsJyruy0xsEP3RIKko9UQ7Y9y/b6TbNOJDx/ZpC9KcOUmI8Or73IMdG1ZucumzHNO3dS2XKL7qeTQ8AWMwwAk2ZsCRx9g05QLiW3+7ZrpmOMwI3wCeJOoxhUQKijCXI3B8Rh1cU++CMk4LdyPOe78PYEEQKBgQDnyOL69Ck6+xe1EJ2HAEDPla5ujCexv6ctYvSernhI6OsMVCWa1D5rCqzC4L0IvRW7/m5lUSWlSzpfIGhSGc+PNyIaYsyYMbaIV5e8LKRp8SxUDrTA4IfYmxoXdYyq2l0PSkBPKMJ2ZyWlRoGGEC432IsiY+GBaznvHwIYFvkYHwKBgQCq7DkJYT6du/bQ2uoZv6hYYIGTY4A9TzjJ0Kp5O00BUz5zNpgBUfb1SmuISHwGyN1hOWFntR0uwfj/BUDvtG0b07k1Xz+4UWXsDqtS6eEnvUR6q/i2yWWGjCMS74t61FZopV6AxHneJV2S6Tt26MFK0VbrCwXaiYg/3tMYgC2rnwKBgF0kfRIby/XHsV8xrhvyHhlNLSt/ZvQm8Cds/KBHvE6QSuRJbFMrt2mMgKBPb6dzVKiXNgXA9j/WWz6e500W0jHbFflEerMuRwvDJ1aXGfr4z7d3sWtQz0ZcDcAfnMeLuJnMXMtytbKfAKHKE4KsPeZzPnYzbQt063MMIutLUA5BAoGBAIduFONxwgOJY8+pJcSxL9qW3RTDymDJ3N1MEUdtzV43b0wq/dZN87f396xMgrl9fqwCo0NhJnZeC8VFjGZiN/HMmPvJNNv+4xtfpDBWUKkENrZcfP2YJnGtqDzgwUvZ432XSoINK+LxCGvXkd5uHnoB1TT3zvOR9ftluy22onlRAoGBAKkIZmwW/2H/86ILrCDyARK4obULB4op8IyrunZ+lH14DksxbL7fmTsSbLyRX7oD/QvGJIuc0EDkgONztsAn5vrETv8Z6RqyKdoZZI3sAQWIBc0om6nH2zqJDIs+mep96DOg/jJAcgiVhyIoFP91IvHY7pvKwy5MTttdZLvvS2XB"}); + }}; + + @Pointcut("@annotation(com.cpop.core.annontation.SimpleSignatureCheck)") + public void simpleSignatureCheck() {} + + /** + * 前置通知 + * @author DB + * @since 2024/1/16 + */ + @Before(value = "simpleSignatureCheck()") + public void beforePointcut() { + //获取RequestAttributes + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + //从获取RequestAttributes中获取HttpServletRequest的信息 + assert requestAttributes != null; + HttpServletRequest request = (HttpServletRequest) requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST); + assert request != null; + String signature = request.getHeader("signature"); + if (StringUtils.isBlank(signature)){ + throw new ServiceException("签名为空,请核实签名"); + } + String appId = request.getHeader("appId"); + if (StringUtils.isBlank(appId)){ + throw new ServiceException("appId为空,请核实签名"); + } + String dateTime = request.getHeader("dateTime"); + if (StringUtils.isBlank(dateTime)){ + throw new ServiceException("时间为空,请核实签名"); + } + String decrypt = rsaUtils.decrypt(signature, stringToKey(APP_IDS.get(appId)[1])); + String sign = appId + dateTime; + String md5DigestAsHex = DigestUtils.md5DigestAsHex(sign.getBytes()); + if (!StringUtils.equals(md5DigestAsHex, decrypt)) { + throw new ServiceException("签名匹配失败,请核实签名"); + } + } + + /** + * 环绕通知,不做处理 + * @author DB + * @since 2024/1/16 + * @param joinPoint 请求 + * @return Object + */ + @Around("simpleSignatureCheck()") + public Object aroundPointcut(ProceedingJoinPoint joinPoint) throws Throwable { + return joinPoint.proceed(joinPoint.getArgs()); + } + + /** + * 异常通知:目标方法发生异常的时候执行以下代码,此时返回通知不会再触发 + * value 属性:绑定通知的切入点表达式。可以关联切入点声明,也可以直接设置切入点表达式 + * pointcut 属性:绑定通知的切入点表达式,优先级高于 value,默认为 "" + * throwing 属性:与方法中的异常参数名称一致, + * + * @param ex:捕获的异常对象,名称与 throwing 属性值一致 + */ + @AfterThrowing(pointcut = "simpleSignatureCheck()", throwing = "ex") + public Object aspectAfterThrowing(JoinPoint jp, Exception ex) { + String methodName = jp.getSignature().getName(); + if (ex instanceof ServiceException) { + log.error("【异常通知】" + methodName + "方法算术异常(ArithmeticException):" + ex.getMessage()); + return R.fail(ex.getMessage()); + } else { + log.error("【异常通知】" + methodName + "方法异常:" + ex.getMessage()); + return R.fail("签名不合法"); + } + + } + + private Key stringToKey(String stringKey) { + byte[] bytes = stringKey.getBytes(StandardCharsets.UTF_8); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + Key key = null; + ObjectInputStream ois = null; + try { + ois = new ObjectInputStream(bais); + key = (Key) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new UtilException(e.getMessage()); + } finally { + try { + assert ois != null; + ois.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return key; + } + +} diff --git a/Cpop-Core/src/main/java/com/cpop/core/base/entity/CpopSignBase.java b/Cpop-Core/src/main/java/com/cpop/core/base/entity/CpopSignBase.java new file mode 100644 index 0000000..50849bd --- /dev/null +++ b/Cpop-Core/src/main/java/com/cpop/core/base/entity/CpopSignBase.java @@ -0,0 +1,33 @@ +package com.cpop.core.base.entity; + +import lombok.Data; + +/** + * 普普签名基础类 + * @author DB + * @version 1.0.0 + * @since 2024-01-16 10:09 + */ +@Data +public class CpopSignBase { + + /** + * 签名 + */ + private String signature; + + /** + * appId + */ + private String appId; + + /** + * 时间(yyyyMMddHHmmss) + */ + private String dateTime; + + /** + * 签名类型 + */ + private String signType; +} diff --git a/Cpop-Core/src/main/java/com/cpop/core/utils/RsaUtils.java b/Cpop-Core/src/main/java/com/cpop/core/utils/RsaUtils.java index e73e662..e0f833a 100644 --- a/Cpop-Core/src/main/java/com/cpop/core/utils/RsaUtils.java +++ b/Cpop-Core/src/main/java/com/cpop/core/utils/RsaUtils.java @@ -86,14 +86,18 @@ public class RsaUtils { * 将密钥对生成到文件中 */ private void generateKeyPairToFiles() { + generateKeyPairToFiles(keyPairConfig.getPublicKeyFile(),keyPairConfig.getPrivateKeyFile()); + } + + private void generateKeyPairToFiles(String publicKeyFile, String privateKeyFile) { ObjectOutputStream oosPublicKey = null; ObjectOutputStream oosPrivateKey = null; try { Map keyPairMap = generateKeyPair(); Key publicKey = keyPairMap.get("publicKey"); Key privateKey = keyPairMap.get("privateKey"); - oosPublicKey = new ObjectOutputStream(Files.newOutputStream(Paths.get(keyPairConfig.getPublicKeyFile()))); - oosPrivateKey = new ObjectOutputStream(Files.newOutputStream(Paths.get(keyPairConfig.getPrivateKeyFile()))); + oosPublicKey = new ObjectOutputStream(Files.newOutputStream(Paths.get(publicKeyFile))); + oosPrivateKey = new ObjectOutputStream(Files.newOutputStream(Paths.get(privateKeyFile))); oosPublicKey.writeObject(publicKey); oosPrivateKey.writeObject(privateKey); } catch (NoSuchAlgorithmException | IOException e) { @@ -111,25 +115,31 @@ public class RsaUtils { } } + + /** * 初始化密钥对文件 * @return 返回密钥对信息【publicKey(公钥字符串)、、privateKey(私钥字符串)】 */ public Map initKeyPair() { + return initKeyPair(keyPairConfig.getPublicKeyFile(),keyPairConfig.getPrivateKeyFile()); + } + + public Map initKeyPair(String publicKeyFile, String privateKeyFile){ Map keyPairMap = new HashMap<>(); - File publicFile = new File(keyPairConfig.getPublicKeyFile()); - File privateFile = new File(keyPairConfig.getPrivateKeyFile()); + File publicFile = new File(publicKeyFile); + File privateFile = new File(privateKeyFile); //判断是否存在公钥和私钥文件 if (!publicFile.exists() || !privateFile.exists()) { - generateKeyPairToFiles(); + generateKeyPairToFiles(publicKeyFile, privateKeyFile); } ObjectInputStream oisPublic = null; ObjectInputStream oisPrivate = null; Key publicKey = null; Key privateKey = null; try { - oisPublic = new ObjectInputStream(Files.newInputStream(Paths.get(keyPairConfig.getPublicKeyFile()))); - oisPrivate = new ObjectInputStream(Files.newInputStream(Paths.get(keyPairConfig.getPrivateKeyFile()))); + oisPublic = new ObjectInputStream(Files.newInputStream(Paths.get(publicKeyFile))); + oisPrivate = new ObjectInputStream(Files.newInputStream(Paths.get(privateKeyFile))); publicKey = (Key) oisPublic.readObject(); privateKey = (Key) oisPrivate.readObject(); byte[] publicKeyBytes = publicKey.getEncoded(); @@ -183,7 +193,28 @@ public class RsaUtils { * @return 解密后的字符串 */ public String decrypt(String source) { - Key privateKey = getKeyFromFile(keyPairConfig.getPrivateKeyFile()); + return decrypt(source,keyPairConfig.getPrivateKeyFile()); + } + + public String decrypt(String source, String privateKeyFile) { + Key privateKey = getKeyFromFile(privateKeyFile); + Base64.Decoder decoder = Base64.getDecoder(); + String decryptSource = null; + try { + //得到Cipher对象对已用公钥加密的数据进行RSA解密 + Cipher cipher = Cipher.getInstance(keyPairConfig.getAlgorithm()); + cipher.init(Cipher.DECRYPT_MODE, privateKey); + //执行解密操作 + byte[] bytes = decoder.decode(source); + decryptSource = new String(cipher.doFinal(bytes), StandardCharsets.UTF_8); + } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | + IllegalBlockSizeException | BadPaddingException e) { + throw new UtilException(e.getMessage()); + } + return decryptSource; + } + + public String decrypt(String source, Key privateKey) { Base64.Decoder decoder = Base64.getDecoder(); String decryptSource = null; try { diff --git a/Cpop-Core/src/main/resources/mapper/CoreMapper.xml b/Cpop-Core/src/main/resources/mapper/CoreMapper.xml index 474be7d..18a4fa5 100644 --- a/Cpop-Core/src/main/resources/mapper/CoreMapper.xml +++ b/Cpop-Core/src/main/resources/mapper/CoreMapper.xml @@ -295,6 +295,9 @@ password = #{password}, + + rsa_password = #{rsaPassword}, + nick_name = #{nickName}, diff --git a/Cpop-Generator/src/main/java/com/cpop/generator/CpopGenerator.java b/Cpop-Generator/src/main/java/com/cpop/generator/CpopGenerator.java index 8276257..6c85a8c 100644 --- a/Cpop-Generator/src/main/java/com/cpop/generator/CpopGenerator.java +++ b/Cpop-Generator/src/main/java/com/cpop/generator/CpopGenerator.java @@ -40,17 +40,17 @@ public class CpopGenerator { /** * 输出路径 */ - private static final String EXPORT_URL = "/Cpop-Oam"; + private static final String EXPORT_URL = "/Cpop-Mall"; /** * 模块 */ - private static final String EXPORT_ITEM = "oam"; + private static final String EXPORT_ITEM = "mall"; /** * 表前缀 */ - private static final String TABLE_PREFIX = "cp_oam_"; + private static final String TABLE_PREFIX = "cp_mall_"; /** * 主入口 diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java new file mode 100644 index 0000000..c051c11 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java @@ -0,0 +1,135 @@ +package com.cpop.jambox.business.bo; + +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.time.LocalDate; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-16 16:29 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "CardTemplateUnionBo对象", description = "课卡模板统一入口") +public class CardTemplateUnionBo { + + /** + * 主键 + */ + @ApiModelProperty(value = "主键") + private String id; + + /** + * 云品牌id + */ + @ApiModelProperty(value = "云品牌id") + private String brandCloudId; + + /** + * 云校区id + */ + @ApiModelProperty(value = "云校区id") + private String storeCloudId; + + /** + * 模板名 + */ + @NotBlank(message = "模板名不能为空") + @ApiModelProperty(value = "模板名",required = true) + private String name; + + /** + * 有效日期数 + */ + @ApiModelProperty(value = "有效日期数") + private Integer validDay; + + /** + * 开始日期 + */ + @ApiModelProperty(value = "开始日期") + private LocalDate startDate; + + /** + * 结束日期 + */ + @ApiModelProperty(value = "结束日期") + private LocalDate endDate; + + /** + * 价格 + */ + @NotNull(message = "价格不能为空") + @ApiModelProperty(value = "价格") + private BigDecimal price; + + /** + * 课时 + */ + @ApiModelProperty("课时") + private Integer classNumber; + + /** + * 周预约数 + */ + @ApiModelProperty(value = "周预约数") + private Integer weekAppointment; + + /** + * 日预约数 + */ + @ApiModelProperty(value = "日预约数") + private Integer dayAppointment; + + /** + * 缓冲天数 + */ + @ApiModelProperty(value = "缓冲天数") + private Integer bufferDay; + + /** + * 模板类型(0:课时卡,1:时限卡,2:储值卡) + */ + @ApiModelProperty(value = "模板类型(0:课时卡,1:时限卡,2:储值卡)") + private Integer templateType; + + /** + * 使用范围 + */ + @ApiModelProperty(value = "使用范围(旧Type字段)") + private String scopeUse; + + /** + * 支付类型(0:微信支付;1:微信先学后付;2:放心学合约支付;3:数字人民币支付;4:线下支付) + */ + @NotNull(message = "支付类型不能为空") + @ApiModelProperty(value = "支付类型(0:微信支付;1:微信先学后付;2:放心学合约支付;3:数字人民币支付;4:线下支付") + private Integer payType; + + /** + * 是否是会员(0否1是) + */ + @ApiModelProperty(value = "是否是会员(0否1是)") + private Boolean isMember; + + /** + * 先学后付支付 + */ + @ApiModelProperty("先学后付支付(次付)") + private LearnNowPayLaterPlanBo learnNowPayLaterPay; + + /** + * 先学后付支付 + */ + @ApiModelProperty("先学后付(月付)") + private LearnNowPayLaterPlanBo learnNowPayLaterMonthPay; +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java index c1a9e34..fdf9653 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java @@ -1,5 +1,6 @@ package com.cpop.jambox.business.controller.backstage; +import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.mybatisflex.core.paginate.Page; import com.cpop.core.base.R; import com.cpop.jambox.business.entity.CardTemplate; @@ -9,8 +10,10 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; import java.io.Serializable; import java.util.List; @@ -28,4 +31,16 @@ public class CardTemplateController { @Autowired private CardTemplateService cardTemplateService; + /** + * 添加课卡模板(整合) + * @author DB + * @since 2023/10/07 9:59 + * @param bo 请求参数 + */ + @ApiOperation(value = "添加课卡模板(整合)") + @PostMapping("/insertCardTemplateUnion") + public R insertCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { + String templateId = cardTemplateService.insertCardTemplateUnion(bo); + return R.ok(templateId); + } } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/EasyLearnController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/EasyLearnController.java index 7ba054f..ee232f0 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/EasyLearnController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/EasyLearnController.java @@ -2,10 +2,7 @@ package com.cpop.jambox.business.controller.backstage; import com.alibaba.excel.EasyExcel; import com.cpop.core.base.R; -import com.cpop.jambox.business.bo.EasyLearnPageBo; -import com.cpop.jambox.business.bo.EasyLearnUnifiedPayBo; -import com.cpop.jambox.business.bo.EasyLearnUnionPayBo; -import com.cpop.jambox.business.bo.OncePlaceOrderBo; +import com.cpop.jambox.business.bo.*; import com.cpop.jambox.business.dto.EasyLearnPageDto; import com.cpop.jambox.business.service.EasyLearnOrderService; import com.cpop.jambox.business.vo.EasyLearnPageVo; diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplate.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplate.java index 9d5ce00..f84b5bf 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplate.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplate.java @@ -41,14 +41,14 @@ public class CardTemplate extends BaseEntity implements Serializable { private String oldTemplateId; /** - * 云品牌id + * 品牌id */ - private String cloudBrandId; + private String brandId; /** - * 云校区id + * 校区id */ - private String cloudStoreId; + private String storeId; /** * 是否使用(0否1是) @@ -113,7 +113,7 @@ public class CardTemplate extends BaseEntity implements Serializable { /** * 支付类型(0:微信支付;1:微信先学后付;2:放心学合约支付;3:数字人民币支付;4:线下支付) */ - private String payType; + private Integer payType; /** * 太阳码 @@ -125,12 +125,6 @@ public class CardTemplate extends BaseEntity implements Serializable { */ private Boolean isMember; - /** - * 模板类型(0:课时卡,1:时限卡,2:储值卡) - */ - @Column(ignore = true) - private String oldTemplateType; - /** * 逻辑删除(0否1是) */ diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java index 4aae0c0..5431941 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java @@ -1,5 +1,7 @@ package com.cpop.jambox.business.service; +import com.cpop.jambox.business.bo.CardTemplateUnionBo; +import com.mybatisflex.core.row.Row; import com.mybatisflex.core.service.IService; import com.cpop.jambox.business.entity.CardTemplate; import com.cpop.jambox.business.vo.CardTemplateListVo; @@ -22,5 +24,14 @@ public interface CardTemplateService extends IService { * @param brandId 品牌id * @return: com.cpop.jambox.business.entity.CardTemplate */ - CardTemplate getOldTemplateInfo(String oldTemplateId, String brandId); + Row getOldTemplateInfo(String oldTemplateId, String brandId); + + /** + * 添加课卡模板(整合) + * @author DB + * @since 2024/1/16 + * @param bo 请求参数 + * @return String 旧模板id + */ + String insertCardTemplateUnion(CardTemplateUnionBo bo); } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/EasyLearnOrderService.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/EasyLearnOrderService.java index 0f16640..10d2035 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/EasyLearnOrderService.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/EasyLearnOrderService.java @@ -1,9 +1,6 @@ package com.cpop.jambox.business.service; -import com.cpop.jambox.business.bo.EasyLearnPageBo; -import com.cpop.jambox.business.bo.EasyLearnUnifiedPayBo; -import com.cpop.jambox.business.bo.EasyLearnUnionPayBo; -import com.cpop.jambox.business.bo.OncePlaceOrderBo; +import com.cpop.jambox.business.bo.*; import com.cpop.jambox.business.dto.EasyLearnPageDto; import com.cpop.jambox.business.entity.EasyLearnOrder; import com.cpop.jambox.business.vo.EasyLearnPageVo; @@ -77,4 +74,5 @@ public interface EasyLearnOrderService extends IService { * @return Object */ Object unifiedPay(EasyLearnUnifiedPayBo bo); + } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java index 360ee24..71ee595 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java @@ -1,11 +1,18 @@ package com.cpop.jambox.business.service.impl; +import com.cpop.common.utils.StringUtils; +import com.cpop.common.utils.bean.BeanUtils; import com.cpop.core.utils.SpringUtils; +import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.jambox.business.entity.BrandExtend; import com.cpop.jambox.business.entity.CardTemplate; +import com.cpop.jambox.business.entity.StoreExtend; import com.cpop.jambox.business.mapper.CardTemplateMapper; import com.cpop.jambox.business.service.BrandExtendService; import com.cpop.jambox.business.service.CardTemplateService; +import com.cpop.jambox.business.service.StoreExtendService; +import com.cpop.system.business.entity.Store; +import com.cpop.system.business.service.StoreService; import com.mybatisflex.core.datasource.DataSourceKey; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.row.Db; @@ -19,6 +26,7 @@ import java.util.List; import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND; import static com.cpop.jambox.business.entity.table.CardTemplateTableDef.CARD_TEMPLATE; +import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND; /** * 果酱-课卡模板 服务层实现。 @@ -38,24 +46,43 @@ public class CardTemplateServiceImpl extends ServiceImpl keyPairMap = rsaUtils.initKeyPair(); + String publicFileUrl = "E:\\Cpop\\Cpop-Union\\Cpop-Mall\\Cpop-Mall-Web\\src\\main\\resources\\static\\keyPair\\publicKey"; + String privateFileUrl = "E:\\Cpop\\Cpop-Union\\Cpop-Mall\\Cpop-Mall-Web\\src\\main\\resources\\static\\keyPair\\privateKey"; + Map keyPairMap = rsaUtils.initKeyPair(publicFileUrl,privateFileUrl); String publicKey = keyPairMap.get("publicKey"); String privateKey = keyPairMap.get("privateKey"); System.out.println("公钥:"); diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/CarouselBo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/CarouselBo.java new file mode 100644 index 0000000..8063de1 --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/CarouselBo.java @@ -0,0 +1,55 @@ +package com.cpop.mall.business.bo; + +import com.mybatisflex.annotation.Id; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-15 13:44 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "商城轮播图对象") +public class CarouselBo { + + /** + * 主键 + */ + @ApiModelProperty(value = "主键") + private String id; + + /** + * 产品id + */ + @NotBlank(message = "产品id不能为空") + @ApiModelProperty(value = "产品id",required = true) + private String productId; + + /** + * 图片地址 + */ + @ApiModelProperty(value = "图片地址",required = true) + @NotBlank(message = "图片地址不能为空") + private String picUrl; + + /** + * 排序 + */ + @NotNull(message = "排序不能为空") + @ApiModelProperty(value = "排序",required = true) + private Integer orderNo; + + /** + * 上架状态(0:下架;1:上架) + */ + @NotNull(message = "上架状态不能为空") + @ApiModelProperty(value = "上架状态(0:下架;1:上架)",required = true) + private Boolean upStatus; +} diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageCarouselController.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageCarouselController.java new file mode 100644 index 0000000..58a582a --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageCarouselController.java @@ -0,0 +1,132 @@ +package com.cpop.mall.business.controller.backstage; + +import com.cpop.core.base.R; +import com.cpop.core.utils.SpringUtils; +import com.cpop.mall.business.bo.CarouselBo; +import com.cpop.mall.business.service.ProductService; +import com.cpop.mall.business.vo.CarouselPageVo; +import com.cpop.mall.business.vo.ProductInfoVo; +import com.cpop.mall.business.vo.ProductSimpleVo; +import com.mybatisflex.core.paginate.Page; +import com.mybatisflex.core.query.QueryWrapper; +import org.springframework.web.bind.annotation.*; +import org.springframework.beans.factory.annotation.Autowired; +import com.cpop.mall.business.entity.Carousel; +import com.cpop.mall.business.service.CarouselService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import java.io.Serializable; +import java.util.List; + +import static com.cpop.mall.business.entity.table.CarouselTableDef.CAROUSEL; +import static com.cpop.mall.business.entity.table.ProductTableDef.PRODUCT; + +/** + * 商城轮播图 控制层。 + * + * @author DB + * @since 2024-01-15 + */ +@RestController +@Api(tags = "商城轮播图接口") +@RequestMapping("/carousel") +public class BackstageCarouselController { + + @Autowired + private CarouselService carouselService; + + /** + * 分页查询商城轮播图 + * @author DB + * @since 2024/1/15 + * @param upStatus 上架状态 + * @return R> + */ + @GetMapping("/getCarouselPage") + @ApiOperation("分页查询商城轮播图") + public R> getCarouselPage(@ApiParam("上架状态") @RequestParam(value = "upStatus", required = false) Boolean upStatus) { + Page page = carouselService.getCarouselPage(upStatus); + return R.ok(page); + } + + /** + * 新增轮播图 + * @author DB + * @since 2024/1/15 + * @param bo 请求参数 + * @return R + */ + @PostMapping("/insertCarousel") + @ApiOperation("新增商城轮播图") + public R insertCarousel(@RequestBody CarouselBo bo) { + carouselService.insertCarousel(bo); + return R.ok(); + } + + /** + * 更新轮播图 + * + * @param bo 请求参数 + * @return R + * @author DB + * @since 2024/1/15 + */ + @PutMapping("/updateCarousel") + @ApiOperation("修改商城轮播图") + public R updateCarousel(@RequestBody CarouselBo bo) { + carouselService.updateCarousel(bo); + return R.ok(); + } + + /** + * 轮播图上下架 + * @param id 主键 + * @return R + * @author DB + * @since 2024/1/15 + */ + @PutMapping("/carouselUnmount/{id}") + @ApiOperation("轮播图上下架") + public R carouselUnmount(@PathVariable String id) { + carouselService.updateChain() + .setRaw(CAROUSEL.UP_STATUS, "if(up_status = 0, 1, 0)") + .where(CAROUSEL.ID.eq(id)) + .update(); + return R.ok(); + } + + /** + * 删除轮播图 + * + * @param id 主键 + * @return R + * @author DB + * @since 2024/1/15 + */ + @DeleteMapping("/removeCarouselById/{id}") + @ApiOperation("删除轮播图") + public R removeCarouselById(@PathVariable String id) { + carouselService.updateChain().where(CAROUSEL.ID.eq(id)).remove(); + return R.ok(); + } + + /** + * 获取上架商品 + * @author DB + * @since 2024/1/15 + * @param brandId 品牌id + * @return R> + */ + @GetMapping("/getUpProductList") + @ApiOperation("获取上架商品") + public R> getUpProductList(@ApiParam("品牌id") @RequestParam(value = "brandId", required = false) String brandId) { + List productSimpleVos = SpringUtils.getBean(ProductService.class).listAs(QueryWrapper.create() + .select(PRODUCT.ID, PRODUCT.PRODUCT_NAME) + .where(PRODUCT.BRAND_ID.eq(brandId)) + .and(PRODUCT.IS_UP.eq(true)) + , ProductSimpleVo.class); + return R.ok(productSimpleVos); + } + +} diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/mini/MiniProductController.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/mini/MiniProductController.java index a40bc68..34d0bc3 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/mini/MiniProductController.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/mini/MiniProductController.java @@ -1,9 +1,12 @@ package com.cpop.mall.business.controller.mini; +import com.alibaba.fastjson.JSONObject; import com.cpop.common.utils.bean.BeanUtils; import com.cpop.core.base.R; +import com.cpop.core.utils.SecurityUtils; import com.cpop.core.utils.SpringUtils; import com.cpop.mall.business.bo.ProductPageBo; +import com.cpop.mall.business.service.CarouselService; import com.cpop.mall.business.service.ProductService; import com.cpop.mall.business.vo.*; import com.cpop.system.business.entity.Store; @@ -12,12 +15,15 @@ import com.mybatisflex.core.paginate.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Arrays; import java.util.List; +import static com.cpop.mall.business.entity.table.CarouselTableDef.CAROUSEL; + /** * 商城-商品表 控制层。 * @@ -32,6 +38,9 @@ public class MiniProductController { @Autowired private ProductService productService; + @Autowired + private CarouselService carouselService; + /** * @descriptions 分页查询商城-商品 * @author DB @@ -117,4 +126,18 @@ public class MiniProductController { return R.ok(info); } + /** + * 获取商城轮播图 + * @author DB + * @since 2024/1/15 + * @return R> + */ + @GetMapping("/getCarouselList") + @ApiOperation("获取商城轮播图") + public R> getCarouselList() { + JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); + List vos = carouselService.queryChain().where(CAROUSEL.BRAND_ID.eq(loginUserInfo.getString("brandId")) + .and(CAROUSEL.UP_STATUS.eq(true))).listAs(CarouselListVo.class); + return R.ok(vos); + } } diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/entity/Carousel.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/entity/Carousel.java new file mode 100644 index 0000000..1a9f4e2 --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/entity/Carousel.java @@ -0,0 +1,74 @@ +package com.cpop.mall.business.entity; + +import com.cpop.core.base.entity.BaseEntity; +import com.cpop.core.base.entity.BaseInsertListener; +import com.cpop.core.base.entity.BaseUpdateListener; +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; +import java.io.Serializable; +import java.time.LocalDateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import lombok.experimental.Accessors; + +/** + * 商城轮播图 实体类。 + * + * @author DB + * @since 2024-01-15 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@Table(value = "cp_mall_carousel", onInsert = BaseInsertListener.class, onUpdate = BaseUpdateListener.class, mapperGenerateEnable = false) +public class Carousel extends BaseEntity implements Serializable { + + /** + * 主键 + */ + @Id + private String id; + + /** + * 产品id + */ + @Id + private String productId; + + /** + * 品牌id + */ + @Id + private String brandId; + + /** + * 图片地址 + */ + private String picUrl; + + /** + * 排序 + */ + private Integer orderNo; + + /** + * 上架状态(0:下架;1:上架) + */ + private Boolean upStatus; + + + + + + /** + * 逻辑删除(0否1是) + */ + @Column(isLogicDelete = true) + private Boolean isDelete; + +} diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/mapper/CarouselMapper.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/mapper/CarouselMapper.java new file mode 100644 index 0000000..17f1ed1 --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/mapper/CarouselMapper.java @@ -0,0 +1,14 @@ +package com.cpop.mall.business.mapper; + +import com.mybatisflex.core.BaseMapper; +import com.cpop.mall.business.entity.Carousel; + +/** + * 商城轮播图 映射层。 + * + * @author DB + * @since 2024-01-15 + */ +public interface CarouselMapper extends BaseMapper { + +} diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/CarouselService.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/CarouselService.java new file mode 100644 index 0000000..dedae33 --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/CarouselService.java @@ -0,0 +1,41 @@ +package com.cpop.mall.business.service; + +import com.cpop.mall.business.bo.CarouselBo; +import com.cpop.mall.business.vo.CarouselPageVo; +import com.mybatisflex.core.paginate.Page; +import com.mybatisflex.core.service.IService; +import com.cpop.mall.business.entity.Carousel; + +/** + * 商城轮播图 服务层。 + * + * @author DB + * @since 2024-01-15 + */ +public interface CarouselService extends IService { + + /** + * 分页查询商城轮播图 + * @author DB + * @since 2024/1/15 + * @param upStatus 上架状态 + * @return Page + */ + Page getCarouselPage(Boolean upStatus); + + /** + * 新增轮播图 + * @author DB + * @since 2024/1/15 + * @param bo 请求参数 + */ + void insertCarousel(CarouselBo bo); + + /** + * 修改轮播图 + * @author DB + * @since 2024/1/15 + * @param bo 请求参数 + */ + void updateCarousel(CarouselBo bo); +} diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/CarouselServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/CarouselServiceImpl.java new file mode 100644 index 0000000..2f1bdc6 --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/CarouselServiceImpl.java @@ -0,0 +1,79 @@ +package com.cpop.mall.business.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.cpop.common.utils.bean.BeanUtils; +import com.cpop.core.base.entity.PageDomain; +import com.cpop.core.utils.SecurityUtils; +import com.cpop.core.utils.sql.SqlUtils; +import com.cpop.mall.business.bo.CarouselBo; +import com.cpop.mall.business.vo.CarouselPageVo; +import com.mybatisflex.core.paginate.Page; +import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.spring.service.impl.ServiceImpl; +import com.cpop.mall.business.entity.Carousel; +import com.cpop.mall.business.mapper.CarouselMapper; +import com.cpop.mall.business.service.CarouselService; +import org.springframework.stereotype.Service; + +import static com.cpop.mall.business.entity.table.CarouselTableDef.CAROUSEL; +import static com.cpop.mall.business.entity.table.ProductTableDef.PRODUCT; + +/** + * 商城轮播图 服务层实现。 + * + * @author DB + * @since 2024-01-15 + */ +@Service("carouselService") +public class CarouselServiceImpl extends ServiceImpl implements CarouselService { + + /** + * 分页查询商城轮播图 + * @author DB + * @since 2024/1/15 + * @param upStatus 上架状态 + * @return Page + */ + @Override + public Page getCarouselPage(Boolean upStatus) { + JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); + PageDomain pageDomain = SqlUtils.getInstance().getPageDomain(); + return this.pageAs(Page.of(pageDomain.getPageNum(), pageDomain.getPageSize()), + QueryWrapper.create() + .select(CAROUSEL.ID,CAROUSEL.PRODUCT_ID,CAROUSEL.PIC_URL,CAROUSEL.ORDER_NO,CAROUSEL.UP_STATUS) + .select(PRODUCT.PRODUCT_NAME) + .leftJoin(PRODUCT).on(PRODUCT.ID.eq(CAROUSEL.PRODUCT_ID)) + .where(CAROUSEL.BRAND_ID.eq(loginUserInfo.getString("brandId"))) + .and(CAROUSEL.UP_STATUS.eq(upStatus)) + .orderBy(CAROUSEL.ORDER_NO.asc()), + CarouselPageVo.class); + } + + /** + * 新增轮播图 + * @author DB + * @since 2024/1/15 + * @param bo 请求参数 + */ + @Override + public void insertCarousel(CarouselBo bo) { + JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); + Carousel carousel = BeanUtils.mapToClass(bo, Carousel.class); + carousel.setBrandId(loginUserInfo.getString("brandId")); + this.save(carousel); + } + + /** + * 修改轮播图 + * @author DB + * @since 2024/1/15 + * @param bo 请求参数 + */ + @Override + public void updateCarousel(CarouselBo bo) { + JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); + Carousel carousel = BeanUtils.mapToClass(bo, Carousel.class); + carousel.setBrandId(loginUserInfo.getString("brandId")); + this.updateById(carousel); + } +} diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java index 05b3979..1f6857b 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java @@ -217,18 +217,18 @@ public class ProductServiceImpl extends ServiceImpl impl //判断当前传入的是否是课卡 if (bo.getProductType() == 0) { //获取模板相关信息 - CardTemplate oldTemplateInfo = SpringUtils.getBean(CardTemplateService.class).getOldTemplateInfo(bo.getCardTemplateId(), product.getBrandId()); - product.setMaxConsume(oldTemplateInfo.getPrice()).setMinConsume(oldTemplateInfo.getPrice()); + Row oldTemplateInfo = SpringUtils.getBean(CardTemplateService.class).getOldTemplateInfo(bo.getCardTemplateId(), product.getBrandId()); + product.setMaxConsume(oldTemplateInfo.getBigDecimal("price")).setMinConsume(oldTemplateInfo.getBigDecimal("price")); this.save(product); //课卡模板获取固定规格 ProductSpecification productSpecification = new ProductSpecification(); - productSpecification.setSpecificationNames(oldTemplateInfo.getName()); + productSpecification.setSpecificationNames(oldTemplateInfo.getString("name")); productSpecifications = new ArrayList(); productSpecifications.add(productSpecification); //记录 recordList = new ArrayList(); ProductRecord productRecord = new ProductRecord(); - productRecord.setRecordNum(2147483647).setRecordNames(productSpecification.getSpecificationNames()).setRecordPrice(oldTemplateInfo.getPrice()).setRecordPoints(0); + productRecord.setRecordNum(2147483647).setRecordNames(productSpecification.getSpecificationNames()).setRecordPrice(oldTemplateInfo.getBigDecimal("price")).setRecordPoints(0); recordList.add(productRecord); } else { //积分支付 @@ -449,8 +449,8 @@ public class ProductServiceImpl extends ServiceImpl impl if (productInfoVo.getProductType() == 0){ try { DataSourceKey.use("jambox"); - CardTemplate cardTemplate = SpringUtils.getBean(CardTemplateService.class).getOldTemplateInfo(productInfoVo.getCardTemplateId(), loginUserInfo.getString("brandId")); - productInfoVo.setCardTemplateName(cardTemplate.getName()); + Row cardTemplate = SpringUtils.getBean(CardTemplateService.class).getOldTemplateInfo(productInfoVo.getCardTemplateId(), loginUserInfo.getString("brandId")); + productInfoVo.setCardTemplateName(cardTemplate.getString("name")); } finally { DataSourceKey.clear(); } diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/CarouselListVo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/CarouselListVo.java new file mode 100644 index 0000000..ddcb820 --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/CarouselListVo.java @@ -0,0 +1,41 @@ +package com.cpop.mall.business.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-15 14:51 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "Brand对象", description = "品牌表") +public class CarouselListVo { + + /** + * 主键 + */ + @ApiModelProperty(value = "主键") + private String id; + + /** + * 产品id + */ + @ApiModelProperty(value = "产品id") + private String productId; + + /** + * 图片地址 + */ + @ApiModelProperty(value = "图片地址") + private String picUrl; + + /** + * 排序 + */ + @ApiModelProperty(value = "排序") + private Integer orderNo; +} diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/CarouselPageVo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/CarouselPageVo.java new file mode 100644 index 0000000..6788069 --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/CarouselPageVo.java @@ -0,0 +1,54 @@ +package com.cpop.mall.business.vo; + +import com.mybatisflex.annotation.Id; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-15 12:54 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "Brand对象", description = "品牌表") +public class CarouselPageVo { + + /** + * 主键 + */ + @ApiModelProperty(value = "主键") + private String id; + + /** + * 产品id + */ + @ApiModelProperty(value = "产品id") + private String productId; + + /** + * 产品名称 + */ + @ApiModelProperty(value = "产品名称") + private String productName; + + /** + * 图片地址 + */ + @ApiModelProperty(value = "图片地址") + private String picUrl; + + /** + * 排序 + */ + @ApiModelProperty(value = "排序") + private Integer orderNo; + + /** + * 上架状态(0:下架;1:上架) + */ + @ApiModelProperty(value = "上架状态(0:下架;1:上架)") + private Boolean upStatus; +} diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductSimpleVo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductSimpleVo.java new file mode 100644 index 0000000..053acce --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductSimpleVo.java @@ -0,0 +1,25 @@ +package com.cpop.mall.business.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-15 14:06 + */ +@Data +public class ProductSimpleVo { + + /** + * 主键 + */ + @ApiModelProperty(value = "主键") + private String id; + + /** + * 商品名称 + */ + @ApiModelProperty(value = "商品名称") + private String productName; +} diff --git a/Cpop-Mall/src/main/resources/mapper/CarouselMapper.xml b/Cpop-Mall/src/main/resources/mapper/CarouselMapper.xml new file mode 100644 index 0000000..a28e3f1 --- /dev/null +++ b/Cpop-Mall/src/main/resources/mapper/CarouselMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml index 5c8cafc..c79cd5f 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml @@ -43,7 +43,9 @@ spring: mongodb: host: localhost port: 27017 - database: cpop-union + database: cpop-dev + username: Cpop + password: Admin@123 server: port: 9420 diff --git a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopApiTests.java b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopApiTests.java index 43bc145..b13e32e 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopApiTests.java +++ b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopApiTests.java @@ -1,6 +1,8 @@ package com.cpop.oam.web; import com.cpop.api.tencent.wxWork.handler.WebHookSendHandler; +import com.cpop.core.utils.RsaUtils; +import com.cpop.core.utils.SpringUtils; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -14,7 +16,7 @@ import java.util.List; * @createTime 2023/09/15 17:44 * @description */ -@SpringBootTest +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class CpopApiTests { @Autowired @@ -36,4 +38,12 @@ public class CpopApiTests { throw new RuntimeException(e); } } + + @Test + public void rsaDecrypt(){ + RsaUtils rsaUtils = SpringUtils.getBean(RsaUtils.class); + String jambox0831 = rsaUtils.encrypt("jambox0831"); + String decrypt = rsaUtils.decrypt(jambox0831); + System.out.println(decrypt); + } } diff --git a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopCoreTests.java b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopCoreTests.java index d3837ad..f82d89c 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopCoreTests.java +++ b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopCoreTests.java @@ -1,5 +1,6 @@ package com.cpop.oam.web; +import cn.hutool.core.util.IdUtil; import com.cpop.core.base.entity.LoginUser; import com.cpop.core.base.enums.OperationLogEnum; import com.cpop.core.base.enums.UserType; @@ -7,6 +8,7 @@ import com.cpop.core.service.CoreService; import com.cpop.core.utils.PasswordEncoder; import com.cpop.core.utils.RsaUtils; import com.cpop.core.utils.SpringUtils; +import com.cpop.core.utils.uuid.IdUtils; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -84,5 +86,36 @@ public class CpopCoreTests { System.out.println("encode加密:"+encode); } - + /** + * 初始化密钥对 + */ + @Test + public void initPublicOrPrivateKey() { + String snowflakeNextIdStr = IdUtil.getSnowflakeNextIdStr(); + String baseKeyRepository = "E:\\KeyRepository\\"; + String publicKeyFile = baseKeyRepository + "publicKey" + snowflakeNextIdStr; + String privateKeyFile = baseKeyRepository + "privateKey" + snowflakeNextIdStr; + Map keyPairMap = rsaUtils.initKeyPair(publicKeyFile, privateKeyFile); + String publicKey = keyPairMap.get("publicKey"); + String privateKey = keyPairMap.get("privateKey"); + System.out.println("公钥:"); + System.out.println(publicKey); + System.out.println(); + System.out.println("私钥:"); + System.out.println(privateKey); + System.out.println(); + String source = "Admin@123"; + System.out.println("待加密字符串:" + source); + System.out.println(); + String strEncrypt = rsaUtils.encrypt(source); + System.out.println("加密后的字符串:"); + System.out.println(strEncrypt); + System.out.println(); + String strDecrypt = rsaUtils.decrypt(strEncrypt); + System.out.println("解密后的字符串:"); + System.out.println(strDecrypt); + //加密 + String encode = SpringUtils.getBean(PasswordEncoder.class).encode("Admin@123"); + System.out.println("encode加密:" + encode); + } } diff --git a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java new file mode 100644 index 0000000..1b5818a --- /dev/null +++ b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java @@ -0,0 +1,62 @@ +package com.cpop.oam.web; + +import com.alibaba.fastjson.JSONArray; +import com.cpop.common.utils.StringUtils; +import com.cpop.core.utils.SpringUtils; +import com.cpop.jambox.business.entity.Plug; +import com.cpop.jambox.business.entity.StoreExtend; +import com.cpop.jambox.business.service.PlugService; +import com.cpop.jambox.business.service.StoreExtendService; +import com.cpop.system.business.entity.Store; +import com.cpop.system.business.service.StoreService; +import com.mybatisflex.core.datasource.DataSourceKey; +import com.mybatisflex.core.row.DbChain; +import com.mybatisflex.core.row.Row; +import com.mybatisflex.core.row.RowUtil; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-16 17:17 + */ +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class CpopDataSyncTests { + + /** + * 同步校区缺失数据 + * @author DB + * @since 2024/1/16 + */ + @Test + public void syncStoreInfo(){ + List rowList; + try { + DataSourceKey.use("jambox"); + rowList = DbChain.table("t_mechanism_info") + .select("tmi.store_id as storeCloudId") + .from("t_mechanism_info").as("tmi") + .leftJoin("t_signContract_mechanism").as("tsm").on("tsm.store_id = tmi.store_id") + .where("tmi.deleted = 1") + .and("DATEDIFF(\n" + + "\tDATE_FORMAT( tsm.end_time, '%Y-%m-%d' ),\n" + + "\tDATE_FORMAT( tmi.creation_time, '%Y-%m-%d' ))>= 300") + .list(); + } finally { + DataSourceKey.clear(); + } + //获取所有校区 + Map storeMap = SpringUtils.getBean(StoreExtendService.class).list().stream().collect(Collectors.toMap(StoreExtend::getStoreCloudId, StoreExtend::getStoreId)); + rowList.forEach(item -> { + item.set("id", storeMap.get(item.getString("storeCloudId"))); + item.set("have_active", true); + }); + List storeList = RowUtil.toEntityList(rowList, Store.class).stream().filter(item -> StringUtils.isNotBlank(item.getId())).collect(Collectors.toList()); + SpringUtils.getBean(StoreService.class).updateBatch(storeList); + } +} diff --git a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopImportTests.java b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopImportTests.java index 65af0a4..8e9a782 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopImportTests.java +++ b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopImportTests.java @@ -1578,18 +1578,16 @@ public class CpopImportTests { @Test public void batchUpdateStaffPassword(){ List cpSysUser = DbChain.table("cp_sys_user") - .select("id","phone_number","password") + .select("id","phone_number") .where("user_type = 'OAM_USER'") .and("is_delete = 0") .list(); List entityList = RowUtil.toEntityList(cpSysUser, SysUser.class); //加密 - PasswordEncoder passwordEncoder = SpringUtils.getBean(PasswordEncoder.class); RsaUtils rsaUtils = SpringUtils.getBean(RsaUtils.class); entityList.forEach(item -> { if (!StringUtils.equals("1", item.getId())) { String lastFourChars = "jambox" + item.getPhoneNumber().substring(item.getPhoneNumber().length() - 4); - item.setPassword(passwordEncoder.encode(lastFourChars)); item.setRsaPassword(rsaUtils.encrypt(lastFourChars)); } }); diff --git a/Cpop-Oam/pom.xml b/Cpop-Oam/pom.xml index ee8b262..5e2d5d8 100644 --- a/Cpop-Oam/pom.xml +++ b/Cpop-Oam/pom.xml @@ -19,10 +19,6 @@ com.cpop Cpop-Core - - com.cpop - Cpop-Api - com.cpop Cpop-Jambox diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/CloudUnionCallbackBo.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/CloudUnionCallbackBo.java new file mode 100644 index 0000000..20eda29 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/CloudUnionCallbackBo.java @@ -0,0 +1,163 @@ +package com.cpop.oam.business.bo; + +import com.cpop.system.business.bo.StoreBo; +import com.cpop.system.business.bo.SyncBrandAndStoreBo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import java.sql.Date; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-16 11:35 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "CloudUnionCallbackBo对象", description = "云回调统一入参") +public class CloudUnionCallbackBo { + + /** + * 回调枚举(DATA_IMPORT_CALLBACK:数据导入回调) + */ + @NotBlank(message = "回调枚举不能为空") + @ApiModelProperty(value = "回调枚举(DATA_IMPORT_CALLBACK:数据导入回调;SYNC_BRAND_AND_STORE_CALLBACK:同步品牌与校区)",required = true) + private String callbackEnum; + + /** + * 主要id + */ + @ApiModelProperty(value = "主要id") + private String mainId; + + /** + * 同步品牌与校区相关参数 + */ + @ApiModelProperty(value = "同步品牌与校区相关参数") + private SyncBrandAndStore syncBrandAndStore; + + @Data + @ApiModel("同步品牌与校区") + public class SyncBrandAndStore { + + /** + * 品牌 + */ + @ApiModelProperty(value = "品牌") + private SyncBrandAndStoreBo.BrandInfo brandInfo; + + /** + * 校区 + */ + @ApiModelProperty(value = "校区") + private SyncBrandAndStoreBo.StoreInfo storeInfo; + + + /** + * 品牌信息 + */ + @Data + public class BrandInfo { + + /** + * 云品牌id + */ + @ApiModelProperty(value = "云品牌id") + private String brandCloudId; + + /** + * 品牌名 + */ + @ApiModelProperty(value = "品牌名") + private String brandName; + } + + /** + * 校区信息 + */ + @Data + public class StoreInfo { + + /** + * 云品牌id + */ + @ApiModelProperty(value = "云校区id") + private String storeCloudId; + + /** + * 店铺/校区名 + */ + @ApiModelProperty(value = "店铺/校区名") + private String storeName; + + /** + * 店铺/校区地址 + */ + @ApiModelProperty(value = "店铺/校区地址") + private String storeAddr; + + /** + * 负责人 + */ + @ApiModelProperty(value = "负责人") + private String personCharge; + + /** + * 手机号 + */ + @ApiModelProperty(value = "手机号") + private String phone; + + /** + * 营业执照地址 + */ + @ApiModelProperty(value = "营业执照地址") + private String licenseAddr; + + /** + * 营业执照日期 + */ + @ApiModelProperty(value = "营业执照日期") + private Date licenseDate; + + /** + * 营业执照公司名 + */ + @ApiModelProperty(value = "营业执照公司名") + private String licenseName; + + /** + * 营业执照证书码 + */ + @ApiModelProperty(value = "营业执照证书码") + private String licenseCode; + + /** + * 营业执照法人名 + */ + @ApiModelProperty(value = "营业执照法人名") + private String licenseUserName; + + /** + * 营业执照图片地址 + */ + @ApiModelProperty(value = "营业执照图片地址") + private String licensePicUrl; + + /** + * 经度 + */ + @ApiModelProperty(value = "经度") + private String longitude; + + /** + * 纬度 + */ + @ApiModelProperty(value = "纬度") + private String latitude; + } + } +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/WxPayController.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/WxPayController.java index 032ba35..541bdbe 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/WxPayController.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/WxPayController.java @@ -52,7 +52,6 @@ public class WxPayController { * @date 2023/11/15 11:06 * @return: com.cpop.core.base.R */ - @PreAuthorize("@aps.hasPermission('brandStore:brand:update')") @ApiOperation("开通微信分账") @PutMapping("/changeBrandSharing") public R changeBrandSharing(@RequestBody @Validated ChangeWechatSharingBo bo) { diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/callback/CloudCallbackController.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/callback/CloudCallbackController.java new file mode 100644 index 0000000..aac0545 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/callback/CloudCallbackController.java @@ -0,0 +1,42 @@ +package com.cpop.oam.business.controller.callback; + +import com.cpop.core.annontation.SimpleSignatureCheck; +import com.cpop.core.base.R; +import com.cpop.oam.business.bo.CloudUnionCallbackBo; +import com.cpop.oam.framework.enums.CloudCallbackEnums; +import com.cpop.oam.framework.strategy.cloud.CloudCallbackStrategy; +import com.cpop.system.business.vo.SysFileVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-16 11:28 + */ +@Api(tags = "云回调controller") +@RestController +@RequestMapping("/cloudCallback") +public class CloudCallbackController { + + /** + * 云联合回调 + * @author DB + * @since 2024/1/16 + * @param callback 回调参数 + * @return R + */ + //@SimpleSignatureCheck + @ApiOperation("云联合回调") + @PostMapping("/cloudUnionCallback") + public R cloudUnionCallback(@RequestBody @Validated CloudUnionCallbackBo callback) { + CloudCallbackStrategy cloudCallbackStrategy = CloudCallbackEnums.valueOf(callback.getCallbackEnum()).getCloudCallbackStrategy(); + cloudCallbackStrategy.callback(callback); + return R.ok(); + } +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BusinessServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BusinessServiceImpl.java index 2347477..909dfad 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BusinessServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BusinessServiceImpl.java @@ -393,11 +393,7 @@ public class BusinessServiceImpl extends ServiceImpl i storeSign.setSignStaffId(loginUserInfo.getString("id")); storeSignService.save(storeSign); } - /*storeSign.setSignStaffId(loginUserInfo.getString("id")); - StoreRenewService storeRenewService = SpringUtils.getBean(StoreRenewService.class); - StoreRenewBo storeRenewBo = new StoreRenewBo(); - storeRenewBo.setStoreId(bo.getStoreId()).setRenewType(1).setRenewDesc("机构签约自动续费一年").setRenewDate(LocalDate.now().plusYears(1)); - storeRenewService.storeRenew(storeRenewBo);*/ + } } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java index 2711ee8..cd0f146 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java @@ -34,12 +34,14 @@ import com.cpop.oam.business.mapper.DataImportMapper; import com.cpop.oam.business.service.DataImportService; import com.qcloud.cos.model.UploadResult; import lombok.extern.slf4j.Slf4j; +import org.apache.http.conn.ConnectTimeoutException; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.IOException; +import java.net.SocketTimeoutException; import java.util.ArrayList; import java.util.List; @@ -106,6 +108,12 @@ public class DataImportServiceImpl extends ServiceImpl(), - "==========有一条校区数据导入失败==========\n" + - "导入id:" + dataImport.getId() + "\n" + - "校区id:" + dataImport.getStoreId() + "\n", - true); - } catch (IOException ex) { - throw new ServiceException("发送消息通知失败!"); - } + log.info("数据导入超时,导入id为:{}", dataImport.getId()); } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/TaskServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/TaskServiceImpl.java index 22cd726..9252054 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/TaskServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/TaskServiceImpl.java @@ -741,7 +741,7 @@ public class TaskServiceImpl extends ServiceImpl implements Ta //所有技术员工信息 Map staffMap = SpringUtils.getBean(StaffService.class).queryChain() .leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID)) - .where(STAFF.STAFF_TYPE.eq(0)) + .where(STAFF.STAFF_TYPE.in(0, 2)) .and(SYS_USER.STATUS.eq(1)) .list() .stream().collect(Collectors.toMap(Staff::getId, item -> item)); diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/framework/enums/CloudCallbackEnums.java b/Cpop-Oam/src/main/java/com/cpop/oam/framework/enums/CloudCallbackEnums.java new file mode 100644 index 0000000..ec8cefb --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/framework/enums/CloudCallbackEnums.java @@ -0,0 +1,50 @@ +package com.cpop.oam.framework.enums; + +import com.cpop.core.utils.SpringUtils; +import com.cpop.oam.framework.strategy.cloud.CloudCallbackStrategy; +import com.cpop.oam.framework.strategy.cloud.CloudDataImportCallbackStrategy; +import com.cpop.oam.framework.strategy.cloud.CloudSyncBrandOrStoreCallbackStrategy; +import lombok.Getter; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-16 11:38 + */ +@Getter +public enum CloudCallbackEnums { + + /** + * 数据导入回调 + */ + DATA_IMPORT_CALLBACK(0, "dataImportCallback", SpringUtils.getBean(CloudDataImportCallbackStrategy.class)), + /** + * 同步品牌与校区回调 + */ + SYNC_BRAND_AND_STORE_CALLBACK(1, "syncBrandAndStoreCallback", SpringUtils.getBean(CloudSyncBrandOrStoreCallbackStrategy.class)) + ; + + CloudCallbackEnums(Integer code, String name, CloudCallbackStrategy cloudCallbackStrategy) { + this.code = code; + this.name = name; + this.cloudCallbackStrategy = cloudCallbackStrategy; + } + + private Integer code; + + private String name; + + private CloudCallbackStrategy cloudCallbackStrategy; + + public void setCode(Integer code) { + this.code = code; + } + + public void setName(String name) { + this.name = name; + } + + public void setCloudCallbackStrategy(CloudCallbackStrategy cloudCallbackStrategy) { + this.cloudCallbackStrategy = cloudCallbackStrategy; + } +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudCallbackStrategy.java b/Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudCallbackStrategy.java new file mode 100644 index 0000000..860fb32 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudCallbackStrategy.java @@ -0,0 +1,19 @@ +package com.cpop.oam.framework.strategy.cloud; + +import com.cpop.oam.business.bo.CloudUnionCallbackBo; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-16 11:42 + */ +public interface CloudCallbackStrategy { + + /** + * 回调 + * @author DB + * @since 2024/1/16 + */ + void callback(CloudUnionCallbackBo callback); + +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudDataImportCallbackStrategy.java b/Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudDataImportCallbackStrategy.java new file mode 100644 index 0000000..5f49680 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudDataImportCallbackStrategy.java @@ -0,0 +1,43 @@ +package com.cpop.oam.framework.strategy.cloud; + +import com.cpop.api.tencent.wxWork.handler.WebHookSendHandler; +import com.cpop.core.base.exception.ServiceException; +import com.cpop.core.utils.SpringUtils; +import com.cpop.oam.business.bo.CloudUnionCallbackBo; +import com.cpop.oam.business.entity.DataImport; +import com.cpop.oam.business.service.DataImportService; +import com.cpop.oam.framework.constant.WebHookKeyConstant; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.ArrayList; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-16 11:44 + */ +@Component +public class CloudDataImportCallbackStrategy implements CloudCallbackStrategy { + + /** + * 回调策略 + */ + @Override + public void callback(CloudUnionCallbackBo callback) { + DataImportService dataImportService = SpringUtils.getBean(DataImportService.class); + DataImport dataImport = dataImportService.getById(callback.getMainId()); + //数据导入异常通知 + try { + SpringUtils.getBean(WebHookSendHandler.class) + .webHookSendText(WebHookKeyConstant.PRODUCT_BOT, + new ArrayList<>(), + "==========有一条校区数据导入失败==========\n" + + "导入id:" + dataImport.getId() + "\n" + + "校区id:" + dataImport.getStoreId() + "\n", + true); + } catch (IOException ex) { + throw new ServiceException("发送消息通知失败!"); + } + } +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudSyncBrandOrStoreCallbackStrategy.java b/Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudSyncBrandOrStoreCallbackStrategy.java new file mode 100644 index 0000000..2ae39fd --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/framework/strategy/cloud/CloudSyncBrandOrStoreCallbackStrategy.java @@ -0,0 +1,84 @@ +package com.cpop.oam.framework.strategy.cloud; + +import com.cpop.common.utils.bean.BeanUtils; +import com.cpop.core.base.entity.LoginUser; +import com.cpop.core.base.enums.SourceType; +import com.cpop.core.utils.SecurityUtils; +import com.cpop.core.utils.SpringUtils; +import com.cpop.oam.business.bo.CloudUnionCallbackBo; +import com.cpop.system.business.bo.SyncBrandAndStoreBo; +import com.cpop.system.business.entity.Brand; +import com.cpop.system.business.entity.Store; +import com.cpop.system.business.entity.StoreLicense; +import com.cpop.system.business.service.BrandService; +import com.cpop.system.business.service.StoreLicenseService; +import com.cpop.system.business.service.StoreService; +import com.mybatisflex.core.row.Db; +import com.mybatisflex.core.row.DbChain; +import com.mybatisflex.core.row.Row; +import com.mybatisflex.core.row.RowKey; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +/** + * + * @author DB + * @version 1.0.0 + * @since 2024-01-16 14:37 + */ +@Component +public class CloudSyncBrandOrStoreCallbackStrategy implements CloudCallbackStrategy{ + + /** + * 回调策略 + * @author DB + * @since 2024/1/16 + * @param callback 回调参数 + */ + @Override + public void callback(CloudUnionCallbackBo callback) { + SyncBrandAndStoreBo.BrandInfo brandInfo = callback.getSyncBrandAndStore().getBrandInfo(); + //查询品牌 + Row brandExtend = DbChain.table("cp_j_brand_extend").where("brand_cloud_id = ?", brandInfo.getBrandCloudId()).one(); + Brand brand; + LocalDateTime now = LocalDateTime.now(); + LoginUser loginUser = SecurityUtils.getInstance().getLoginUser(); + BrandService brandService = SpringUtils.getBean(BrandService.class); + if (brandExtend.isEmpty()) { + brand = new Brand(); + brand.setBrandName(brandInfo.getBrandName()).setSourceType(SourceType.JAMBOX.toString()); + brandService.save(brand); + //保存拓展 + RowKey brandKey = RowKey.SNOW_FLAKE_ID; + DbChain.table("cp_j_brand_extend") + .setId(brandKey) + .set("brand_id", brand.getId()) + .set("brand_cloud_id", brandInfo.getBrandCloudId()) + .set("create_time", now) + .set("update_time", now) + .set("create_user_id", loginUser == null ? "1" : loginUser.getUserId()) + .set("update_user_id", loginUser == null ? "1" : loginUser.getUserId()) + .save(); + }else { + brand = brandService.getById(brandExtend.getString("brandId")); + } + SyncBrandAndStoreBo.StoreInfo storeInfo = callback.getSyncBrandAndStore().getStoreInfo(); + Store store = BeanUtils.mapToClass(storeInfo, Store.class); + store.setBrandId(brand.getId()).setSourceType(SourceType.JAMBOX.toString()); + SpringUtils.getBean(StoreService.class).save(store); + //拓展 + Row row = Row.ofKey(RowKey.SNOW_FLAKE_ID); + row.set("store_cloud_id", storeInfo.getStoreCloudId()); + row.set("store_id", store.getId()); + row.set("create_time", now); + row.set("update_time", now); + row.set("create_user_id", loginUser == null ? "1" : loginUser.getUserId()); + row.set("update_user_id", loginUser == null ? "1" : loginUser.getUserId()); + Db.insert("cp_j_store_extend",row); + //营业执照 + StoreLicense storeLicense = BeanUtils.mapToClass(storeInfo, StoreLicense.class); + storeLicense.setStoreId(store.getId()); + SpringUtils.getBean(StoreLicenseService.class).save(storeLicense); + } +} diff --git a/Cpop-System/pom.xml b/Cpop-System/pom.xml index 16be23f..710365c 100644 --- a/Cpop-System/pom.xml +++ b/Cpop-System/pom.xml @@ -24,6 +24,10 @@ org.springframework.boot spring-boot-starter-websocket + + com.cpop + Cpop-Api + diff --git a/Cpop-System/src/main/java/com/cpop/system/business/bo/StoreBo.java b/Cpop-System/src/main/java/com/cpop/system/business/bo/StoreBo.java new file mode 100644 index 0000000..85c5c38 --- /dev/null +++ b/Cpop-System/src/main/java/com/cpop/system/business/bo/StoreBo.java @@ -0,0 +1,60 @@ +package com.cpop.system.business.bo; + +import com.mybatisflex.annotation.Id; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-15 11:04 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "StoreBo对象") +public class StoreBo { + + /** + * 店铺/校区id + */ + @ApiModelProperty(value = "店铺/校区id") + private String id; + + /** + * 品牌id + */ + @ApiModelProperty(value = "品牌id") + private String brandId; + + /** + * 店铺/校区名 + */ + @NotBlank(message = "不能为空") + @ApiModelProperty(value = "店铺/校区名",required = true) + private String storeName; + + /** + * 负责人 + */ + @NotBlank(message = "负责人不能为空") + @ApiModelProperty(value = "负责人",required = true) + private String personCharge; + + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空") + @ApiModelProperty(value = "手机号",required = true) + private String phone; + + /** + * 微信商户id + */ + @ApiModelProperty(value = "微信商户id") + private String wxMchId; + +} diff --git a/Cpop-System/src/main/java/com/cpop/system/business/bo/StoreRenewBo.java b/Cpop-System/src/main/java/com/cpop/system/business/bo/StoreRenewBo.java index 000b252..a333d60 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/bo/StoreRenewBo.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/bo/StoreRenewBo.java @@ -37,9 +37,8 @@ public class StoreRenewBo { /** * 续费日期 */ - @NotNull(message = "不能为空") @DateTimeFormat(pattern = "yyyy-MM-dd") - @ApiModelProperty(value = "续费日期", required = true) + @ApiModelProperty(value = "续费日期") private LocalDate renewDate; /** @@ -60,6 +59,6 @@ public class StoreRenewBo { * 类型(0:续费;1:延期) */ @NotNull(message = "类型不能为空") - @ApiModelProperty(value = "类型(0:续费;1:延期)", required = true) + @ApiModelProperty(value = "类型(0:续费;1:延期;2:激活)", required = true) private Integer renewType; } diff --git a/Cpop-System/src/main/java/com/cpop/system/business/controller/StoreController.java b/Cpop-System/src/main/java/com/cpop/system/business/controller/StoreController.java index b6bdcb4..54e04ec 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/controller/StoreController.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/controller/StoreController.java @@ -1,6 +1,7 @@ package com.cpop.system.business.controller; import com.cpop.core.base.R; +import com.cpop.system.business.bo.StoreBo; import com.cpop.system.business.bo.StorePageBo; import com.cpop.system.business.bo.StoreRenewBo; import com.cpop.system.business.service.StoreRenewService; @@ -59,4 +60,18 @@ public class StoreController { storeRenewService.storeRenew(bo); return R.ok(); } + + /** + * 更新校区 + * @author DB + * @since 2024/1/15 + * @param bo 请求参数 + * @return R + */ + @ApiOperation("更新校区") + @PutMapping("/updateStore") + public R updateStore(@RequestBody @Validated StoreBo bo) { + storeService.updateStore(bo); + return R.ok(); + } } diff --git a/Cpop-System/src/main/java/com/cpop/system/business/controller/SysCommonController.java b/Cpop-System/src/main/java/com/cpop/system/business/controller/SysCommonController.java index e123bf1..89c9f31 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/controller/SysCommonController.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/controller/SysCommonController.java @@ -96,6 +96,7 @@ public class SysCommonController { * @param bo 请求参数 * @return R */ + @Deprecated @ApiOperation("小程序同步品牌和校区") @PostMapping("/miniSyncBrandAndStore") public R miniSyncBrandAndStore(@RequestBody SyncBrandAndStoreBo bo) { diff --git a/Cpop-System/src/main/java/com/cpop/system/business/entity/Store.java b/Cpop-System/src/main/java/com/cpop/system/business/entity/Store.java index 7dc4bc2..7499213 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/entity/Store.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/entity/Store.java @@ -55,12 +55,12 @@ public class Store extends BaseEntity implements Serializable { /** * 是否有顾问 */ - private String haveCounselor; + private Boolean haveCounselor; /** * 是否激活 */ - private String haveActive; + private Boolean haveActive; /** * 品牌id diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/StoreService.java b/Cpop-System/src/main/java/com/cpop/system/business/service/StoreService.java index b23e2a0..9da5be5 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/service/StoreService.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/service/StoreService.java @@ -1,5 +1,6 @@ package com.cpop.system.business.service; +import com.cpop.system.business.bo.StoreBo; import com.cpop.system.business.bo.StorePageBo; import com.cpop.system.business.bo.SyncBrandAndStoreBo; import com.cpop.system.business.vo.StorePageVo; @@ -30,4 +31,12 @@ public interface StoreService extends IService { * @param bo 请求参数 */ void miniSyncBrandAndStore(SyncBrandAndStoreBo bo); + + /** + * 更新校区 + * @author DB + * @since 2024/1/15 + * @param bo 请求参数 + */ + void updateStore(StoreBo bo); } diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreRenewServiceImpl.java b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreRenewServiceImpl.java index 052dec6..7f5603e 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreRenewServiceImpl.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreRenewServiceImpl.java @@ -15,6 +15,7 @@ import com.cpop.system.framework.constant.SystemRedisKey; import com.mybatisflex.core.datasource.DataSourceKey; import com.mybatisflex.core.row.DbChain; import com.mybatisflex.core.row.Row; +import com.mybatisflex.core.row.RowKey; import com.mybatisflex.spring.service.impl.ServiceImpl; import com.cpop.system.business.entity.StoreRenew; import com.cpop.system.business.mapper.StoreRenewMapper; @@ -30,6 +31,7 @@ import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisClientConfig; import javax.annotation.Resource; +import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.concurrent.TimeUnit; @@ -54,19 +56,22 @@ public class StoreRenewServiceImpl extends ServiceImpl implements public Page getStorePage(StorePageBo bo) { PageDomain pageDomain = SqlUtils.getInstance().getPageDomain(); return this.getMapper().paginateAs(Page.of(pageDomain.getPageNum(), pageDomain.getPageSize()), - QueryWrapper.create().select(STORE.ID, STORE.STORE_NAME, STORE.SOURCE_TYPE, STORE.CREATE_TIME, STORE.STORE_ADDR, STORE.PERSON_CHARGE, STORE.PHONE, STORE.HAVE_ACTIVE, STORE.HAVE_COUNSELOR) + QueryWrapper.create().select(STORE.ID, STORE.STORE_NAME, STORE.SOURCE_TYPE, STORE.CREATE_TIME, STORE.STORE_ADDR, STORE.PERSON_CHARGE, STORE.PHONE, STORE.HAVE_ACTIVE, + STORE.HAVE_COUNSELOR, STORE.WX_MCH_ID) .select(STORE_SIGN.EXPIRE_DATE) - .select(BRAND.BRAND_NAME,BRAND.ID.as(StorePageVo::getBrandId)) + .select(BRAND.BRAND_NAME, BRAND.ID.as(StorePageVo::getBrandId)) .select("cp_j_store_extend.store_cloud_id as storeCloudId") .from(STORE) .leftJoin(STORE_SIGN).on(STORE_SIGN.STORE_ID.eq(STORE.ID)) @@ -124,4 +128,29 @@ public class StoreServiceImpl extends ServiceImpl implements storeLicense.setStoreId(store.getId()); SpringUtils.getBean(StoreLicenseService.class).save(storeLicense); } + + /** + * 更新校区 + * @author DB + * @since 2024/1/15 + * @param bo 请求参数 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateStore(StoreBo bo) { + Store store = BeanUtils.mapToClass(bo, Store.class); + this.updateById(store); + //获取云信息 + Row row = Db.selectOneByQuery("cp_j_store_extend", QueryWrapper.create() + .select("cjse.store_cloud_id", "cjbe.brand_cloud_id") + .from("cp_j_store_extend").as("cjse") + .leftJoin("cp_sys_store").as("css").on("css.id = cjse.store_id") + .leftJoin("cp_j_brand_extend").as("cjbe").on("cjbe.brand_id = css.brand_id") + .where("cjse.store_id = ?", store.getId())); + CloudStoreDto cloudStoreDto = BeanUtils.mapToClass(store, CloudStoreDto.class); + cloudStoreDto.setBrandCloudId(row.getString("brandCloudId")); + cloudStoreDto.setStoreCloudId(row.getString("storeCloudId")); + //云更新 + SpringUtils.getBean(CloudStoreHandler.class).updateStore(cloudStoreDto); + } } diff --git a/Cpop-System/src/main/java/com/cpop/system/business/vo/StorePageVo.java b/Cpop-System/src/main/java/com/cpop/system/business/vo/StorePageVo.java index a7069ee..f399feb 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/vo/StorePageVo.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/vo/StorePageVo.java @@ -101,4 +101,10 @@ public class StorePageVo implements Serializable { @ApiModelProperty("是否激活") private Boolean haveActive; + /** + * 微信商户号 + */ + @ApiModelProperty("微信商户号") + private String wxMchId; + } From 37d2f50b3369044a3506177869c0647f00fcddd9 Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Thu, 18 Jan 2024 22:10:36 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E9=9B=86=E6=88=90=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98;=E4=BF=AE=E8=AE=A2=E5=95=86=E5=9F=8Ejedis?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=B1=A0;=E6=B7=BB=E5=8A=A0=E4=B8=B4?= =?UTF-8?q?=E6=97=B6=E7=99=BD=E5=90=8D=E5=8D=95;=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E8=BD=AE=E6=92=AD=E5=9B=BE;=E8=AF=BE=E5=8D=A1=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=8B=93=E5=B1=95;=E6=95=B0=E6=8D=AE=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E4=B8=BA=E7=A9=BA=E6=A3=80=E6=9F=A5;=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=A0=A1=E5=8C=BA=E6=A3=80=E6=9F=A5;=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=94=AF=E4=BB=98=E6=B7=BB=E5=8A=A0=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=88=86=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/dto/CloudCourseStudentDto.java | 4 +- .../com/cpop/generator/CpopGenerator.java | 6 +- .../business/bo/CardTemplateUnionBo.java | 34 ++- .../business/bo/LearnNowPayLaterPlanBo.java | 8 +- .../backstage/CardTemplateController.java | 16 +- .../jambox/business/entity/CardTemplate.java | 15 +- .../business/entity/CardTemplateExtend.java | 62 +++++ .../mapper/CardTemplateExtendMapper.java | 14 ++ .../service/CardTemplateExtendService.java | 14 ++ .../business/service/CardTemplateService.java | 2 +- .../impl/CardTemplateExtendServiceImpl.java | 18 ++ .../service/impl/CardTemplateServiceImpl.java | 38 ++- .../framework/tasks/LearnNowPayLaterTask.java | 92 ++++++++ .../mapper/CardTemplateExtendMapper.xml | 7 + .../src/main/resources/application-dev.yml | 1 + .../src/main/resources/application-local.yml | 1 + .../src/main/resources/application-prod.yml | 1 + .../src/main/resources/application-test.yml | 1 + .../BackstageCarouselController.java | 7 +- .../service/impl/OrderRefundServiceImpl.java | 1 + .../src/main/resources/application-dev.yml | 2 +- .../src/main/resources/application.yml | 15 +- .../com/cpop/oam/web/CpopDataSyncTests.java | 217 +++++++++++++++++- .../com/cpop/oam/web/CpopImportTests.java | 3 +- .../oam/business/bo/TaskAuditCommentsBo.java | 4 + .../service/impl/BusinessServiceImpl.java | 1 - .../service/impl/DataImportServiceImpl.java | 3 + .../service/impl/TaskServiceImpl.java | 37 +-- .../config/wxPay/WxPayConfiguration.java | 1 + .../config/wxPay/WxPayProperties.java | 4 + .../src/main/resources/application-pay.yml | 14 +- .../service/impl/StoreRenewServiceImpl.java | 18 +- .../service/impl/StoreServiceImpl.java | 4 +- .../system/framework/utils/DictUtils.java | 1 + 34 files changed, 561 insertions(+), 105 deletions(-) create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplateExtend.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/mapper/CardTemplateExtendMapper.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateExtendService.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateExtendServiceImpl.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java create mode 100644 Cpop-Jambox/src/main/resources/mapper/CardTemplateExtendMapper.xml diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudCourseStudentDto.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudCourseStudentDto.java index a2cefcb..05e95a1 100644 --- a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudCourseStudentDto.java +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudCourseStudentDto.java @@ -123,11 +123,11 @@ public class CloudCourseStudentDto { * 扣除课卡名 */ @SerializedName("periodName") - private String cardName; + private String deductionCardName; /** * 状态操作时间 */ @SerializedName("_createTime") - private String createTime; + private String entryTime; } diff --git a/Cpop-Generator/src/main/java/com/cpop/generator/CpopGenerator.java b/Cpop-Generator/src/main/java/com/cpop/generator/CpopGenerator.java index 6c85a8c..cfc90dd 100644 --- a/Cpop-Generator/src/main/java/com/cpop/generator/CpopGenerator.java +++ b/Cpop-Generator/src/main/java/com/cpop/generator/CpopGenerator.java @@ -40,17 +40,17 @@ public class CpopGenerator { /** * 输出路径 */ - private static final String EXPORT_URL = "/Cpop-Mall"; + private static final String EXPORT_URL = "/Cpop-Jambox"; /** * 模块 */ - private static final String EXPORT_ITEM = "mall"; + private static final String EXPORT_ITEM = "jambox"; /** * 表前缀 */ - private static final String TABLE_PREFIX = "cp_mall_"; + private static final String TABLE_PREFIX = "cp_j_"; /** * 主入口 diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java index c051c11..4d08e0b 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java @@ -8,9 +8,11 @@ import lombok.Data; import lombok.experimental.Accessors; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.time.LocalDate; +import java.util.List; /** * @author DB @@ -28,6 +30,12 @@ public class CardTemplateUnionBo { @ApiModelProperty(value = "主键") private String id; + /** + * 旧课卡模板id + */ + @ApiModelProperty(value = "旧课卡模板id") + private String oldTemplateId; + /** * 云品牌id */ @@ -53,12 +61,6 @@ public class CardTemplateUnionBo { @ApiModelProperty(value = "有效日期数") private Integer validDay; - /** - * 开始日期 - */ - @ApiModelProperty(value = "开始日期") - private LocalDate startDate; - /** * 结束日期 */ @@ -109,11 +111,11 @@ public class CardTemplateUnionBo { private String scopeUse; /** - * 支付类型(0:微信支付;1:微信先学后付;2:放心学合约支付;3:数字人民币支付;4:线下支付) + * 支付类型(0:微信支付;1:先学后付次付;2:旧放心学合约支付;3:数字人民币支付;4:线下支付;5:先学后付月付;) */ - @NotNull(message = "支付类型不能为空") - @ApiModelProperty(value = "支付类型(0:微信支付;1:微信先学后付;2:放心学合约支付;3:数字人民币支付;4:线下支付") - private Integer payType; + @NotEmpty(message = "支付类型不能为空") + @ApiModelProperty(value = "支付类型(0:微信支付;1:先学后付次付;2:旧放心学合约支付;3:数字人民币支付;4:线下支付;5:先学后付月付;)") + private List payType; /** * 是否是会员(0否1是) @@ -121,6 +123,18 @@ public class CardTemplateUnionBo { @ApiModelProperty(value = "是否是会员(0否1是)") private Boolean isMember; + /** + * 是否是引流卡 + */ + @ApiModelProperty(value = "是否是引流卡(0否1是)") + private Boolean isDrainage; + + /** + * 二维码 + */ + @ApiModelProperty(value = "二维码") + private String qrCode; + /** * 先学后付支付 */ diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterPlanBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterPlanBo.java index c60538a..e2e8f9a 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterPlanBo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterPlanBo.java @@ -41,8 +41,8 @@ public class LearnNowPayLaterPlanBo { @ApiModelProperty("支付分计划原总金额") private Integer totalOriginalPrice; - public void setDeductionQuantity(BigDecimal deductionQuantity) { - this.deductionQuantity = deductionQuantity.scaleByPowerOfTen(2).intValue(); + public void setTotalOriginalPrice(BigDecimal totalOriginalPrice) { + this.totalOriginalPrice = totalOriginalPrice.scaleByPowerOfTen(2).intValue(); } /** @@ -51,8 +51,8 @@ public class LearnNowPayLaterPlanBo { @ApiModelProperty("支付分计划实际扣费总金额(单位分)") private Integer totalActualPrice; - public void setTotalOriginalPrice(BigDecimal totalOriginalPrice) { - this.totalOriginalPrice = totalOriginalPrice.scaleByPowerOfTen(2).intValue(); + public void setTotalActualPrice(BigDecimal totalActualPrice) { + this.totalActualPrice = totalActualPrice.scaleByPowerOfTen(2).intValue(); } /** diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java index fdf9653..ce6661b 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java @@ -1,22 +1,15 @@ package com.cpop.jambox.business.controller.backstage; +import com.cpop.core.annontation.SimpleSignatureCheck; import com.cpop.jambox.business.bo.CardTemplateUnionBo; -import com.mybatisflex.core.paginate.Page; import com.cpop.core.base.R; -import com.cpop.jambox.business.entity.CardTemplate; import com.cpop.jambox.business.service.CardTemplateService; -import com.cpop.jambox.business.vo.CardTemplateListVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; -import java.io.Serializable; -import java.util.List; - /** * 果酱-课卡模板 控制层。 * @@ -37,10 +30,11 @@ public class CardTemplateController { * @since 2023/10/07 9:59 * @param bo 请求参数 */ + //@SimpleSignatureCheck @ApiOperation(value = "添加课卡模板(整合)") @PostMapping("/insertCardTemplateUnion") - public R insertCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { - String templateId = cardTemplateService.insertCardTemplateUnion(bo); - return R.ok(templateId); + public R insertCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { + cardTemplateService.insertCardTemplateUnion(bo); + return R.ok(); } } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplate.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplate.java index f84b5bf..890f36b 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplate.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplate.java @@ -65,11 +65,6 @@ public class CardTemplate extends BaseEntity implements Serializable { */ private Integer validDay; - /** - * 开始日期 - */ - private LocalDate startDate; - /** * 结束日期 */ @@ -110,11 +105,6 @@ public class CardTemplate extends BaseEntity implements Serializable { */ private String scopeUse; - /** - * 支付类型(0:微信支付;1:微信先学后付;2:放心学合约支付;3:数字人民币支付;4:线下支付) - */ - private Integer payType; - /** * 太阳码 */ @@ -125,6 +115,11 @@ public class CardTemplate extends BaseEntity implements Serializable { */ private Boolean isMember; + /** + * 是否是引流卡 + */ + private Boolean isDrainage; + /** * 逻辑删除(0否1是) */ diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplateExtend.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplateExtend.java new file mode 100644 index 0000000..fcc457f --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/CardTemplateExtend.java @@ -0,0 +1,62 @@ +package com.cpop.jambox.business.entity; + +import com.cpop.core.base.entity.BaseEntity; +import com.cpop.core.base.entity.BaseInsertListener; +import com.cpop.core.base.entity.BaseUpdateListener; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; +import java.io.Serializable; +import java.time.LocalDateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import lombok.experimental.Accessors; + +/** + * 果酱模板拓展表 实体类。 + * + * @author DB + * @since 2024-01-17 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@Table(value = "cp_j_card_template_extend", onInsert = BaseInsertListener.class, onUpdate = BaseUpdateListener.class, mapperGenerateEnable = false) +public class CardTemplateExtend extends BaseEntity implements Serializable { + + /** + * 模板id + */ + @Id + private String templateId; + + /** + * 支付类型(0:微信支付;1:先学后付次付;2:旧放心学合约支付;3:数字人民币支付;4:线下支付;5:先学后付月付 + */ + @Id + private Integer payType; + + /** + * 拓展id + */ + private String extendId; + + /** + * 拓展参数1 + */ + private String extendParamOne; + + /** + * 拓展参数2 + */ + private String extendParamTwo; + + /** + * 拓展参数3 + */ + private String extendParamThree; + +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/mapper/CardTemplateExtendMapper.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/mapper/CardTemplateExtendMapper.java new file mode 100644 index 0000000..0a08f9f --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/mapper/CardTemplateExtendMapper.java @@ -0,0 +1,14 @@ +package com.cpop.jambox.business.mapper; + +import com.mybatisflex.core.BaseMapper; +import com.cpop.jambox.business.entity.CardTemplateExtend; + +/** + * 果酱模板拓展表 映射层。 + * + * @author DB + * @since 2024-01-17 + */ +public interface CardTemplateExtendMapper extends BaseMapper { + +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateExtendService.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateExtendService.java new file mode 100644 index 0000000..2021c53 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateExtendService.java @@ -0,0 +1,14 @@ +package com.cpop.jambox.business.service; + +import com.mybatisflex.core.service.IService; +import com.cpop.jambox.business.entity.CardTemplateExtend; + +/** + * 果酱模板拓展表 服务层。 + * + * @author DB + * @since 2024-01-17 + */ +public interface CardTemplateExtendService extends IService { + +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java index 5431941..ee7f963 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java @@ -33,5 +33,5 @@ public interface CardTemplateService extends IService { * @param bo 请求参数 * @return String 旧模板id */ - String insertCardTemplateUnion(CardTemplateUnionBo bo); + void insertCardTemplateUnion(CardTemplateUnionBo bo); } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateExtendServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateExtendServiceImpl.java new file mode 100644 index 0000000..611cded --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateExtendServiceImpl.java @@ -0,0 +1,18 @@ +package com.cpop.jambox.business.service.impl; + +import com.mybatisflex.spring.service.impl.ServiceImpl; +import com.cpop.jambox.business.entity.CardTemplateExtend; +import com.cpop.jambox.business.mapper.CardTemplateExtendMapper; +import com.cpop.jambox.business.service.CardTemplateExtendService; +import org.springframework.stereotype.Service; + +/** + * 果酱模板拓展表 服务层实现。 + * + * @author DB + * @since 2024-01-17 + */ +@Service("cardTemplateExtendService") +public class CardTemplateExtendServiceImpl extends ServiceImpl implements CardTemplateExtendService { + +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java index 71ee595..9654d20 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java @@ -1,28 +1,36 @@ package com.cpop.jambox.business.service.impl; +import com.alibaba.fastjson.JSONArray; import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.bean.BeanUtils; +import com.cpop.core.base.entity.LoginUser; +import com.cpop.core.utils.SecurityUtils; import com.cpop.core.utils.SpringUtils; import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.jambox.business.entity.BrandExtend; import com.cpop.jambox.business.entity.CardTemplate; +import com.cpop.jambox.business.entity.CardTemplateExtend; import com.cpop.jambox.business.entity.StoreExtend; import com.cpop.jambox.business.mapper.CardTemplateMapper; import com.cpop.jambox.business.service.BrandExtendService; +import com.cpop.jambox.business.service.CardTemplateExtendService; import com.cpop.jambox.business.service.CardTemplateService; import com.cpop.jambox.business.service.StoreExtendService; +import com.cpop.jambox.framework.tasks.LearnNowPayLaterTask; import com.cpop.system.business.entity.Store; import com.cpop.system.business.service.StoreService; import com.mybatisflex.core.datasource.DataSourceKey; import com.mybatisflex.core.query.QueryWrapper; -import com.mybatisflex.core.row.Db; -import com.mybatisflex.core.row.Row; -import com.mybatisflex.core.row.RowUtil; +import com.mybatisflex.core.row.*; import com.mybatisflex.spring.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.io.File; +import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND; import static com.cpop.jambox.business.entity.table.CardTemplateTableDef.CARD_TEMPLATE; @@ -69,7 +77,8 @@ public class CardTemplateServiceImpl extends ServiceImpl cardTemplateExtends = new ArrayList<>(); + //添加课卡模板拓展 + bo.getPayType().forEach(item->{ + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()) + .setPayType(item); + cardTemplateExtends.add(cardTemplateExtend); + }); + SpringUtils.getBean(CardTemplateExtendService.class).saveBatch(cardTemplateExtends); + //次付 + if (bo.getPayType().contains(1)) { + SpringUtils.getBean(LearnNowPayLaterTask.class).asyncCreateLearnNowPayLaterPlan(cardTemplate, bo.getLearnNowPayLaterPay(), 1); + } + //月付 + if (bo.getPayType().contains(5)) { + SpringUtils.getBean(LearnNowPayLaterTask.class).asyncCreateLearnNowPayLaterPlan(cardTemplate, bo.getLearnNowPayLaterMonthPay(), 5); + } } + } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java new file mode 100644 index 0000000..965d87d --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java @@ -0,0 +1,92 @@ +package com.cpop.jambox.framework.tasks; + +import com.cpop.common.utils.bean.BeanUtils; +import com.cpop.core.base.exception.ServiceException; +import com.cpop.core.utils.SpringUtils; +import com.cpop.jambox.business.bo.CardTemplateUnionBo; +import com.cpop.jambox.business.bo.LearnNowPayLaterPlanBo; +import com.cpop.jambox.business.entity.CardTemplate; +import com.cpop.jambox.business.entity.CardTemplateExtend; +import com.cpop.jambox.business.service.CardTemplateExtendService; +import com.cpop.pay.framewok.handler.wxPay.WxPayHandler; +import com.cpop.system.business.entity.WxPayScore; +import com.cpop.system.business.entity.WxPayScoreDetail; +import com.cpop.system.business.service.WxPayScoreDetailService; +import com.cpop.system.business.service.WxPayScoreService; +import com.github.binarywang.wxpay.bean.payscore.PayScorePlanDetailRequest; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanRequest; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanResult; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.PartnerPayScoreSignPlanService; +import com.github.binarywang.wxpay.service.WxPayService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static com.cpop.jambox.business.entity.table.CardTemplateExtendTableDef.CARD_TEMPLATE_EXTEND; +import static com.cpop.jambox.business.entity.table.CardTemplateTableDef.CARD_TEMPLATE; +import static com.cpop.system.business.entity.table.WxPayScoreTableDef.WX_PAY_SCORE; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-17 18:18 + */ +@Component +public class LearnNowPayLaterTask { + + @Autowired + private WxPayHandler wxPayHandler; + + /** + * 异步创建先学后付计划 + * @author DB + * @since 2024/1/17 + * @param cardTemplate 课卡模板 + * @param payType 支付类型 + */ + @Async("customAsyncThreadPool") + @Transactional(rollbackFor = Exception.class) + public void asyncCreateLearnNowPayLaterPlan(CardTemplate cardTemplate, LearnNowPayLaterPlanBo bo, Integer payType) { + String subMchId = wxPayHandler.getSubMchId(cardTemplate.getBrandId(), cardTemplate.getStoreId()); + //录入计划与详情 + WxPayScore wxPayScore = BeanUtils.mapToClass(bo, WxPayScore.class); + wxPayScore.setSignAccount(subMchId); + WxPayScoreService wxPayScoreService = SpringUtils.getBean(WxPayScoreService.class); + wxPayScoreService.save(wxPayScore); + //创建计划 + WxPayService wxPayService = wxPayHandler.getWxPayService(null, subMchId); + PartnerPayScoreSignPlanService partnerPayScoreSignPlanService = wxPayService.getPartnerPayScoreSignPlanService(); + WxPartnerPayScoreSignPlanRequest planRequest = BeanUtils.mapToClass(bo,WxPartnerPayScoreSignPlanRequest.class); + List payScorePlanDetailRequests = BeanUtils.mapToList(bo.getPlanDetailList(), PayScorePlanDetailRequest.class); + planRequest.setPlanDetailList(payScorePlanDetailRequests); + planRequest.setMerchantPlanNo(wxPayScore.getId()); + WxPartnerPayScoreSignPlanResult result; + //设置商户侧计划 + try { + result = partnerPayScoreSignPlanService.createPlans(planRequest); + } catch (WxPayException e) { + throw new ServiceException(e.getMessage()); + } + List wxPayScoreDetails = BeanUtils.mapToList(result.getPlanDetailList(), WxPayScoreDetail.class); + wxPayScoreDetails.forEach(item -> { + item.setSysWxPayScoreId(wxPayScore.getId()); + }); + //批量保存计划详情 + SpringUtils.getBean(WxPayScoreDetailService.class).saveBatch(wxPayScoreDetails); + //更新外部计划id + wxPayScoreService.updateChain() + .set(WX_PAY_SCORE.OUT_PLAN_ID,result.getPlanId()) + .where(WX_PAY_SCORE.ID.eq(wxPayScore.getId())) + .update(); + //更新模板拓展 + SpringUtils.getBean(CardTemplateExtendService.class).updateChain() + .set(CARD_TEMPLATE_EXTEND.EXTEND_ID,wxPayScore.getId()) + .where(CARD_TEMPLATE_EXTEND.PAY_TYPE.eq(payType)) + .and(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(cardTemplate.getId())) + .update(); + } +} diff --git a/Cpop-Jambox/src/main/resources/mapper/CardTemplateExtendMapper.xml b/Cpop-Jambox/src/main/resources/mapper/CardTemplateExtendMapper.xml new file mode 100644 index 0000000..72de3dd --- /dev/null +++ b/Cpop-Jambox/src/main/resources/mapper/CardTemplateExtendMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-dev.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-dev.yml index f381106..599c38f 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-dev.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-dev.yml @@ -38,6 +38,7 @@ spring: max-active: 8 # max-wait: -1ms + client-type: jedis data: mongodb: host: localhost diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-local.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-local.yml index c62c2b0..d22df63 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-local.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-local.yml @@ -38,6 +38,7 @@ spring: max-active: 8 # max-wait: -1ms + client-type: jedis data: mongodb: host: localhost diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml index 126bd7d..212238d 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml @@ -39,6 +39,7 @@ spring: max-active: 8 # max-wait: -1ms + client-type: jedis data: mongodb: host: localhost diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml index 1ce4040..8bfe9de 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml @@ -39,6 +39,7 @@ spring: max-active: 8 # max-wait: -1ms + client-type: jedis data: mongodb: host: localhost diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageCarouselController.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageCarouselController.java index 58a582a..c1ef383 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageCarouselController.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageCarouselController.java @@ -1,6 +1,8 @@ package com.cpop.mall.business.controller.backstage; +import com.alibaba.fastjson.JSONObject; import com.cpop.core.base.R; +import com.cpop.core.utils.SecurityUtils; import com.cpop.core.utils.SpringUtils; import com.cpop.mall.business.bo.CarouselBo; import com.cpop.mall.business.service.ProductService; @@ -120,10 +122,11 @@ public class BackstageCarouselController { */ @GetMapping("/getUpProductList") @ApiOperation("获取上架商品") - public R> getUpProductList(@ApiParam("品牌id") @RequestParam(value = "brandId", required = false) String brandId) { + public R> getUpProductList() { + JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); List productSimpleVos = SpringUtils.getBean(ProductService.class).listAs(QueryWrapper.create() .select(PRODUCT.ID, PRODUCT.PRODUCT_NAME) - .where(PRODUCT.BRAND_ID.eq(brandId)) + .where(PRODUCT.BRAND_ID.eq(loginUserInfo.getString("brandId"))) .and(PRODUCT.IS_UP.eq(true)) , ProductSimpleVo.class); return R.ok(productSimpleVos); diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderRefundServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderRefundServiceImpl.java index 0c4d80b..44ed93b 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderRefundServiceImpl.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderRefundServiceImpl.java @@ -87,6 +87,7 @@ public class OrderRefundServiceImpl extends ServiceImpl storeList = RowUtil.toEntityList(rowList, Store.class).stream().filter(item -> StringUtils.isNotBlank(item.getId())).collect(Collectors.toList()); SpringUtils.getBean(StoreService.class).updateBatch(storeList); } + + /** + * 同步课卡模板 + * @author DB + * @since 2024/1/17 + */ + @Test + public void syncCardTemplate(){ + List rowList; + try { + DataSourceKey.use("jambox"); + rowList = DbChain.table("t_card_template") + .select("tct.template_id as oldTemplateId", "tct.brand_id as brandCloudId", "tct.store_id as storeCloudId", "tct.open_status as status", "tct.name", "tct.day as validDay", + "tct.end as endDate", "tct.price", "tct.week_appointment", "tct.day_appointment", "tct.free_day as bufferDay", "tct.number as classNumber", + "tct.type as scopeUse", "tct.time_limit", "tct.is_suda", "tct.pay_type", "tct.template_qr_code as qrCode", "tct.is_member", "tct.stage_num", "tct.deposit", "tct.buffer_days", + "tct.is_drainage", "tct.is_ecpp_activity", "tct.ecpp_activity_code", "tct.ecpp_activity_desc") + .select("(SELECT jwpp.plan_id from j_wechat_pay_plan as jwpp WHERE jwpp.template_id = tct.template_id AND jwpp.is_month = 0 AND jwpp.deleted = 1 LIMIT 1 ) as oncePlanId") + .select("(SELECT jwpp.plan_id from j_wechat_pay_plan as jwpp WHERE jwpp.template_id = tct.template_id AND jwpp.is_month = 1 AND jwpp.deleted = 1 LIMIT 1 ) as monthPlanId") + .select("creation_time as createTime", "last_modification_date as updateTime") + .from("t_card_template").as("tct") + .where("tct.deleted = 1") + .list(); + } finally { + DataSourceKey.clear(); + } + //获取所有计划 + Map wxPayScoreMap = SpringUtils.getBean(WxPayScoreService.class).list().stream().collect(Collectors.toMap(WxPayScore::getOutPlanId, item -> item)); + Map brandMap = SpringUtils.getBean(BrandExtendService.class).list().stream().collect(Collectors.toMap(BrandExtend::getBrandCloudId, BrandExtend::getBrandId)); + Map storeMap = SpringUtils.getBean(StoreExtendService.class).list().stream().collect(Collectors.toMap(StoreExtend::getStoreCloudId, StoreExtend::getStoreId)); + List cardTemplateExtends = new ArrayList<>(); + rowList.forEach(item -> { + //模板类型 + item.set("templateType", changeTimeLimitToTemplateType(item.getString("timeLimit"))); + if (item.getBoolean("isSuda")){ + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(item.getString("oldTemplateId")) + .setPayType(3) + .setExtendParamOne(item.getString("isEcppActivity")) + .setExtendParamTwo(item.getString("ecppActivityCode")) + .setExtendParamThree(item.getString("ecppActivityDesc")); + cardTemplateExtends.add(cardTemplateExtend); + } + if (StringUtils.isNotBlank(item.getString("brandCloudId"))){ + item.set("brandId",brandMap.get(item.getString("brandCloudId"))); + } + if (StringUtils.isNotBlank(item.getString("storeCloudId"))){ + item.set("storeId",storeMap.get(item.getString("storeCloudId"))); + } + if (StringUtils.isNotBlank(item.getString("payType"))){ + List payTypeList = Arrays.stream(item.getString("payType").split(",")).collect(Collectors.toList()); + payTypeList.forEach(inner -> { + changePayType(inner, cardTemplateExtends, item, wxPayScoreMap); + }); + } else { + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(item.getString("oldTemplateId")) + .setPayType(4); + cardTemplateExtends.add(cardTemplateExtend); + } + + }); + List entityList = RowUtil.toEntityList(rowList, CardTemplate.class); + SpringUtils.getBean(CardTemplateService.class).saveBatch(entityList); + Map collect = entityList.stream().collect(Collectors.toMap(CardTemplate::getOldTemplateId, CardTemplate::getId)); + LocalDateTime now = LocalDateTime.now(); + cardTemplateExtends.forEach(item->{ + item.setTemplateId(collect.get(item.getTemplateId())); + item.setCreateTime(now); + item.setUpdateTime(now); + }); + SpringUtils.getBean(CardTemplateExtendService.class).saveBatch(cardTemplateExtends); + } + + private Integer changeTimeLimitToTemplateType(String timeLimit) { + switch (timeLimit) { + case "课时卡": + return 0; + case "时限卡": + return 1; + default: + return 2; + } + } + + private void changePayType(String payType,List cardTemplateExtends,Row row,Map wxPayScoreMap) { + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + switch (payType) { + //先学后付次付 + case "1": + if (StringUtils.isNotBlank(row.getString("oncePlanId"))){ + WxPayScore oncePlan = wxPayScoreMap.get(row.getString("oncePlanId")); + if (oncePlan != null){ + cardTemplateExtend.setExtendId(oncePlan.getId()) + .setPayType(1); + cardTemplateExtends.add(cardTemplateExtend); + } + } + break; + //旧放心学合约 + case "2": + cardTemplateExtend.setTemplateId(row.getString("oldTemplateId")) + .setPayType(2) + .setExtendParamOne(row.getString("stageNum")) + .setExtendParamTwo(row.getString("deposit")) + .setExtendParamThree(row.getString("bufferDays")); + cardTemplateExtends.add(cardTemplateExtend); + break; + //先学后付月付 + case "5": + if (StringUtils.isNotBlank(row.getString("monthPlanId"))){ + WxPayScore monthPlan = wxPayScoreMap.get(row.getString("monthPlanId")); + if (monthPlan != null){ + cardTemplateExtend.setExtendId(monthPlan.getId()) + .setPayType(5); + cardTemplateExtends.add(cardTemplateExtend); + } + } + break; + default: + break; + } + } + + /** + * 同步校区签约 + * @author DB + * @since 2024/1/18 + */ + @Test + public void syncOldStoreSignData() { + List rowList; + try { + DataSourceKey.use("jambox"); + rowList = DbChain.table("t_signContract_mechanism") + .select("tsm.store_id as storeCloudId", "tsm.creation_time as createTime", "tsm.last_modification_date as updateTime","os.phone") + .from("t_signContract_mechanism").as("tsm") + .leftJoin("t_mechanism_info").as("tmi").on("tmi.store_id = tsm.store_id") + .leftJoin("OAM_staff").as("os").on("os.staff_id = tmi.clue_id") + .where("tsm.deleted = 1") + .list(); + } finally { + DataSourceKey.clear(); + } + Map phoneToId = DbChain.table(STAFF.getTableName()) + .select(STAFF.ID) + .select(SYS_USER.PHONE_NUMBER.as("phone")) + .from(STAFF) + .leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID)) + .list() + .stream().collect(Collectors.toMap(item -> item.getString("phone"), item -> item.getString("id"))); + Map cloudToId = SpringUtils.getBean(StoreExtendService.class).list() + .stream().collect(Collectors.toMap(StoreExtend::getStoreCloudId, StoreExtend::getStoreId)); + rowList.forEach(item->{ + if (StringUtils.isNotBlank(item.getString("phone"))){ + item.set("sign_staff_id",phoneToId.get(item.getString("phone"))); + } + item.set("store_id",cloudToId.get(item.getString("storeCloudId"))); + }); + List entityList = RowUtil.toEntityList(rowList, StoreSign.class) + .stream().filter(item->StringUtils.isNotBlank(item.getStoreId())).collect(Collectors.toList()); + Db.executeBatch(entityList, StoreSignMapper.class, (mapper, storeSign) -> { + // ↑↑↑↑↑ 以上的这个 mapper,未被使用 + UpdateChain.of(mapper) + .set(STORE_SIGN.CREATE_TIME,storeSign.getCreateTime()) + .set(STORE_SIGN.UPDATE_TIME,storeSign.getUpdateTime()) + .set(STORE_SIGN.SIGN_STAFF_ID,storeSign.getSignStaffId()) + .where(STORE_SIGN.STORE_ID.eq(storeSign.getStoreId())) + .update(); + }); + } + + @Test + public void removeExtendSignData(){ + StoreSignService storeSignService = SpringUtils.getBean(StoreSignService.class); + List list = storeSignService.queryChain() + .select(max(STORE_SIGN.ID).as(StoreSign::getId)) + .groupBy(STORE_SIGN.STORE_ID) + .having(count(STORE_SIGN.STORE_ID).gt(1)).list(); + storeSignService.removeByIds(list.stream().map(StoreSign::getId).collect(Collectors.toList())); + } + + @Test + public void checkSpecialCharacter(){ + String input = "排课000\uD83C\uDF3F\uD83C\uDF8B\uD83C\uDF15\uD83C\uDF44\uD83D\uDC1A"; + //特殊字符过滤 + String pattern = "[^a-zA-Z0-9]"; + System.out.println(input.replaceAll(pattern, "")); + } } diff --git a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopImportTests.java b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopImportTests.java index 8e9a782..fa644ed 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopImportTests.java +++ b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopImportTests.java @@ -59,7 +59,7 @@ import static com.cpop.system.business.entity.table.StoreTableDef.STORE; */ @Slf4j @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles(profiles = {"prod", "core"}) +@ActiveProfiles(profiles = {"dev", "core"}) public class CpopImportTests { /** @@ -1638,4 +1638,5 @@ public class CpopImportTests { }); financeReimburseService.updateBatch(updateEnetyList); } + } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/TaskAuditCommentsBo.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/TaskAuditCommentsBo.java index c16fd36..1d8e2a8 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/TaskAuditCommentsBo.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/TaskAuditCommentsBo.java @@ -47,6 +47,10 @@ public class TaskAuditCommentsBo { @ApiModelProperty("任务权重(任务绩点)") private Integer taskWeight; + public void setTaskWeight(String taskWeight) { + this.taskWeight = Integer.parseInt(taskWeight.split(",")[0]); + } + /** * 备注(不通过时可以写入备注) */ diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BusinessServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BusinessServiceImpl.java index 909dfad..6745cc0 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BusinessServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BusinessServiceImpl.java @@ -393,7 +393,6 @@ public class BusinessServiceImpl extends ServiceImpl i storeSign.setSignStaffId(loginUserInfo.getString("id")); storeSignService.save(storeSign); } - } } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java index cd0f146..6bb2e04 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java @@ -225,6 +225,9 @@ public class DataImportServiceImpl extends ServiceImpl implements Ta } } + /** + * 任务评级 + */ + private final String OAM_TASK_RATING = "oam_task_rating"; + /** * 技术模块-任务领取-技术人员领取任务 * @@ -244,32 +253,8 @@ public class TaskServiceImpl extends ServiceImpl implements Ta // 获取任务评级 String taskRating = task.getTaskRating(); LocalDate now = LocalDate.now(); - switch (taskRating) { - case "A": - // 30天 - task.setExpectedCompletionDate(now.plusDays(30)); - break; - case "B": - // 21天 - task.setExpectedCompletionDate(now.plusDays(21)); - break; - case "C": - // 15天 - task.setExpectedCompletionDate(now.plusDays(15)); - break; - case "D": - // 7天 - task.setExpectedCompletionDate(now.plusDays(7)); - break; - case "E": - // 3天 - task.setExpectedCompletionDate(now.plusDays(3)); - break; - default: - // 1天 - task.setExpectedCompletionDate(now.plusDays(1)); - break; - } + String dictValue = DictUtils.getDictValue(OAM_TASK_RATING, taskRating); + task.setExpectedCompletionDate(now.plusDays(Integer.parseInt(dictValue.split(",")[1]))); } // 获取当前用户 JSONObject loginUser = SecurityUtils.getInstance().getLoginUserInfo(); diff --git a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayConfiguration.java b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayConfiguration.java index f65d3ef..b5b12df 100644 --- a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayConfiguration.java +++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayConfiguration.java @@ -41,6 +41,7 @@ public class WxPayConfiguration { payConfig.setPrivateCertPath(this.properties.getPrivateCertPath()); //通知地址 payConfig.setNotifyUrl(this.properties.getNotifyUrl()); + payConfig.setServiceId(this.properties.getServiceId()); // 可以指定是否使用沙箱环境 payConfig.setUseSandboxEnv(false); WxPayService wxPayService = new WxPayServiceImpl(); diff --git a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java index bdf4a17..454800d 100644 --- a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java +++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java @@ -81,4 +81,8 @@ public class WxPayProperties { */ private String easyLearnUnionPayNotifyUrl; + /** + * 服务id + */ + private String serviceId; } diff --git a/Cpop-Pay/src/main/resources/application-pay.yml b/Cpop-Pay/src/main/resources/application-pay.yml index c5f1be7..65fd4b0 100644 --- a/Cpop-Pay/src/main/resources/application-pay.yml +++ b/Cpop-Pay/src/main/resources/application-pay.yml @@ -2,12 +2,14 @@ wx: #微信支付 pay: #微信公众号或者小程序等的appid - appId: wx20853d18c455e874 + app-id: wx20853d18c455e874 #微信支付商户号 - mchId: 1618884922 + mch-id: 1618884922 #微信支付商户密钥 - mchKey: JamBox20230919174000000000000002 - apiV3Key: JamBox20230919174000000000000002 + mch-key: JamBox20230919174000000000000002 + api-v3-key: JamBox20230919174000000000000002 + #服务id + service-id: 00003053000000169450961228104460 #分账服务商账号 - sharingAccount: 1618884922 - sharingAccountName: 果酱盒子 + sharing-account: 1618884922 + sharing-account-name: 果酱盒子 diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreRenewServiceImpl.java b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreRenewServiceImpl.java index 7f5603e..2a9df4e 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreRenewServiceImpl.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreRenewServiceImpl.java @@ -10,6 +10,7 @@ import com.cpop.core.service.impl.RedisServiceImpl; import com.cpop.core.utils.SecurityUtils; import com.cpop.core.utils.SpringUtils; import com.cpop.system.business.bo.StoreRenewBo; +import com.cpop.system.business.service.StoreService; import com.cpop.system.business.service.StoreSignService; import com.cpop.system.framework.constant.SystemRedisKey; import com.mybatisflex.core.datasource.DataSourceKey; @@ -32,10 +33,12 @@ import redis.clients.jedis.JedisClientConfig; import javax.annotation.Resource; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.concurrent.TimeUnit; import static com.cpop.system.business.entity.table.StoreSignTableDef.STORE_SIGN; +import static com.cpop.system.business.entity.table.StoreTableDef.STORE; /** * 校区续费表 服务层实现。 @@ -62,6 +65,10 @@ public class StoreRenewServiceImpl extends ServiceImpl implements LocalDateTime now = LocalDateTime.now(); LoginUser loginUser = SecurityUtils.getInstance().getLoginUser(); BrandService brandService = SpringUtils.getBean(BrandService.class); - if (brandExtend.isEmpty()) { + if (brandExtend == null || brandExtend.isEmpty()) { brand = new Brand(); brand.setBrandName(brandInfo.getBrandName()).setSourceType(SourceType.JAMBOX.toString()); brandService.save(brand); @@ -107,7 +107,7 @@ public class StoreServiceImpl extends ServiceImpl implements .set("create_user_id", loginUser == null ? "1" : loginUser.getUserId()) .set("update_user_id", loginUser == null ? "1" : loginUser.getUserId()) .save(); - }else { + } else { brand = brandService.getById(brandExtend.getString("brandId")); } Store store = BeanUtils.mapToClass(bo.getStoreInfo(), Store.class); diff --git a/Cpop-System/src/main/java/com/cpop/system/framework/utils/DictUtils.java b/Cpop-System/src/main/java/com/cpop/system/framework/utils/DictUtils.java index 6e8c13f..c6f6378 100644 --- a/Cpop-System/src/main/java/com/cpop/system/framework/utils/DictUtils.java +++ b/Cpop-System/src/main/java/com/cpop/system/framework/utils/DictUtils.java @@ -19,6 +19,7 @@ import java.util.stream.Collectors; /** * 字典工具类 + * @author Lost */ public class DictUtils { /** From 04b930504d47e9fed1e1c3b0c07f76f0a5edd567 Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Fri, 19 Jan 2024 09:08:58 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E5=85=88=E5=AD=A6=E5=90=8E=E4=BB=98?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backstage/CardTemplateController.java | 24 +++++-- .../mini/MiniEasyLearnController.java | 68 ++++++++++++++++++ .../business/service/CardTemplateService.java | 24 +++++-- .../service/impl/CardTemplateServiceImpl.java | 71 ++++++++++++++++--- .../vo/LearnNowPayLaterPlanDetailVo.java | 49 +++++++++++++ .../business/vo/LearnNowPayLaterPlanVo.java | 64 +++++++++++++++++ .../framework/tasks/LearnNowPayLaterTask.java | 4 +- .../com/cpop/mall/web/CpopWxPayTests.java | 15 ++-- .../com/cpop/oam/web/CpopEasyLearnTest.java | 17 ++++- 9 files changed, 308 insertions(+), 28 deletions(-) create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanVo.java diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java index ce6661b..fb9c8fb 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java @@ -1,14 +1,16 @@ package com.cpop.jambox.business.controller.backstage; -import com.cpop.core.annontation.SimpleSignatureCheck; -import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.core.base.R; +import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.jambox.business.service.CardTemplateService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * 果酱-课卡模板 控制层。 @@ -33,8 +35,22 @@ public class CardTemplateController { //@SimpleSignatureCheck @ApiOperation(value = "添加课卡模板(整合)") @PostMapping("/insertCardTemplateUnion") - public R insertCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { + public R insertCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { cardTemplateService.insertCardTemplateUnion(bo); return R.ok(); } + + /** + * 修改课卡模板(整合) + * @author DB + * @since 2023/10/07 9:59 + * @param bo 请求参数 + */ + //@SimpleSignatureCheck + @ApiOperation(value = "修改课卡模板(整合)") + @PostMapping("/updateCardTemplateUnion") + public R updateCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { + cardTemplateService.updateCardTemplateUnion(bo); + return R.ok(); + } } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java new file mode 100644 index 0000000..8f3d9b1 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java @@ -0,0 +1,68 @@ +package com.cpop.jambox.business.controller.mini; + +import com.cpop.core.base.R; +import com.cpop.jambox.business.service.CardTemplateService; +import com.cpop.jambox.business.service.EasyLearnOrderService; +import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-18 22:58 + */ +@RestController +@Api(tags = "果酱小程序-放心学接口") +@RequestMapping("/mini/easyLearn") +public class MiniEasyLearnController { + + @Autowired + private CardTemplateService cardTemplateService; + + @Autowired + private EasyLearnOrderService easyLearnOrderService; + + /** + * 获取支付分计划 + * @author DB + * @since 2024/1/18 + * @param oldTemplateId 旧模板id + * @param isMonth 是否月付 + * @return R + */ + @ApiOperation("获取支付分计划") + @GetMapping("/getWxPayScorePlan") + public R getWxPayScorePlan(@ApiParam(value = "旧模板id",required = true) @RequestParam("oldTemplateId") String oldTemplateId, + @ApiParam(value = "是否月付(0否1是)",required = true) @RequestParam("isMonth") Boolean isMonth) { + LearnNowPayLaterPlanDetailVo vo = cardTemplateService.getWxPayScorePlan(oldTemplateId,isMonth); + return R.ok(vo); + } + + /** + * 获取支付分计划 + * @author DB + * @since 2024/1/18 + * @param oldTemplateId 旧模板id + * @param isMonth 是否月付 + * @return R + */ + @ApiOperation("创建用户签约计划") + @PostMapping("/createUserSignPlans") + public R createUserSignPlans(@ApiParam(value = "旧模板id",required = true) @RequestParam("oldTemplateId") String oldTemplateId, + @ApiParam(value = "是否月付(0否1是)",required = true) @RequestParam("isMonth") Boolean isMonth) { + return R.ok(); + } + + /** + * 创建用户服务订单(核销) + */ + @ApiOperation("创建用户服务订单(核销)") + @PostMapping("/createServiceOrder") + public R createServiceOrder() { + return R.ok(); + } +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java index ee7f963..93e00c2 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java @@ -1,12 +1,10 @@ package com.cpop.jambox.business.service; import com.cpop.jambox.business.bo.CardTemplateUnionBo; +import com.cpop.jambox.business.entity.CardTemplate; +import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; import com.mybatisflex.core.row.Row; import com.mybatisflex.core.service.IService; -import com.cpop.jambox.business.entity.CardTemplate; -import com.cpop.jambox.business.vo.CardTemplateListVo; - -import java.util.List; /** * 果酱-课卡模板 服务层。 @@ -34,4 +32,22 @@ public interface CardTemplateService extends IService { * @return String 旧模板id */ void insertCardTemplateUnion(CardTemplateUnionBo bo); + + /** + * 修改课卡模板(整合) + * @author DB + * @since 2024/1/18 + * @param bo 请求参数 + */ + void updateCardTemplateUnion(CardTemplateUnionBo bo); + + /** + * 获取支付分计划 + * @author DB + * @since 2024/1/18 + * @param oldTemplateId 旧模板id + * @param isMonth 是否月付 + * @return LearnNowPayLaterPlanDetailVo + */ + LearnNowPayLaterPlanDetailVo getWxPayScorePlan(String oldTemplateId, Boolean isMonth); } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java index 9654d20..4277dc0 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java @@ -1,10 +1,7 @@ package com.cpop.jambox.business.service.impl; -import com.alibaba.fastjson.JSONArray; import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.bean.BeanUtils; -import com.cpop.core.base.entity.LoginUser; -import com.cpop.core.utils.SecurityUtils; import com.cpop.core.utils.SpringUtils; import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.jambox.business.entity.BrandExtend; @@ -16,23 +13,24 @@ import com.cpop.jambox.business.service.BrandExtendService; import com.cpop.jambox.business.service.CardTemplateExtendService; import com.cpop.jambox.business.service.CardTemplateService; import com.cpop.jambox.business.service.StoreExtendService; +import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; import com.cpop.jambox.framework.tasks.LearnNowPayLaterTask; import com.cpop.system.business.entity.Store; import com.cpop.system.business.service.StoreService; import com.mybatisflex.core.datasource.DataSourceKey; import com.mybatisflex.core.query.QueryWrapper; -import com.mybatisflex.core.row.*; +import com.mybatisflex.core.row.Db; +import com.mybatisflex.core.row.Row; import com.mybatisflex.spring.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.io.File; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND; +import static com.cpop.jambox.business.entity.table.CardTemplateExtendTableDef.CARD_TEMPLATE_EXTEND; import static com.cpop.jambox.business.entity.table.CardTemplateTableDef.CARD_TEMPLATE; import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND; @@ -95,9 +93,9 @@ public class CardTemplateServiceImpl extends ServiceImpl cardTemplateExtends = new ArrayList<>(); //添加课卡模板拓展 bo.getPayType().forEach(item->{ + //TODO: 新增模板拓展 CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); - cardTemplateExtend.setTemplateId(cardTemplate.getId()) - .setPayType(item); + cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(item); cardTemplateExtends.add(cardTemplateExtend); }); SpringUtils.getBean(CardTemplateExtendService.class).saveBatch(cardTemplateExtends); @@ -111,4 +109,61 @@ public class CardTemplateServiceImpl extends ServiceImpl cardTemplateExtends = cardTemplateExtendService.list(QueryWrapper.create() + .where(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(bo.getOldTemplateId()))); + //添加课卡模板拓展 + List filterPayType = bo.getPayType().stream().filter(item -> item != 1 && item != 5).collect(Collectors.toList()); + //TODO: 新增或修改模板拓展 + + //次付 + List payTypeList = cardTemplateExtends.stream().map(CardTemplateExtend::getPayType).collect(Collectors.toList()); + if (bo.getPayType().contains(1) && !payTypeList.contains(1)) { + SpringUtils.getBean(LearnNowPayLaterTask.class).asyncCreateLearnNowPayLaterPlan(cardTemplate, bo.getLearnNowPayLaterPay(), 1); + } + if (!bo.getPayType().contains(1) && payTypeList.contains(1)){ + //停用先学后付 + SpringUtils.getBean(CardTemplateExtendService.class).updateChain() + .set(CARD_TEMPLATE_EXTEND.EXTEND_PARAM_ONE, false) + .where(CARD_TEMPLATE_EXTEND.PAY_TYPE.eq(1)) + .and(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(cardTemplate.getId())) + .update(); + } + //月付 + if (bo.getPayType().contains(5) && !payTypeList.contains(5)) { + SpringUtils.getBean(LearnNowPayLaterTask.class).asyncCreateLearnNowPayLaterPlan(cardTemplate, bo.getLearnNowPayLaterMonthPay(), 5); + } + if (!bo.getPayType().contains(1) && payTypeList.contains(1)){ + //停用先学后付 + SpringUtils.getBean(CardTemplateExtendService.class).updateChain() + .set(CARD_TEMPLATE_EXTEND.EXTEND_PARAM_ONE, false) + .where(CARD_TEMPLATE_EXTEND.PAY_TYPE.eq(5)) + .and(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(cardTemplate.getId())) + .update(); + } + } + + /** + * 获取支付分计划 + * @author DB + * @since 2024/1/18 + * @param oldTemplateId 旧模板id + * @param isMonth 是否月付 + * @return LearnNowPayLaterPlanDetailVo + */ + @Override + public LearnNowPayLaterPlanDetailVo getWxPayScorePlan(String oldTemplateId, Boolean isMonth) { + return null; + } + } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java new file mode 100644 index 0000000..9266ea4 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java @@ -0,0 +1,49 @@ +package com.cpop.jambox.business.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-08 9:54 + */ +@Data +@ApiModel(value = "先学后付计划详情") +public class LearnNowPayLaterPlanDetailVo { + + /** + * 计划明细优惠说明 + */ + @ApiModelProperty("计划明细优惠说明") + private String planDiscountDescription; + + /** + * 计划明细原支付金额(单位分) + */ + @ApiModelProperty("计划明细原支付金额(单位分)") + private Integer originalPrice; + + public void setOriginalPrice(BigDecimal originalPrice) { + this.originalPrice = originalPrice.scaleByPowerOfTen(2).intValue(); + } + + /** + * 计划明细实际支付金额(单位分) + */ + @ApiModelProperty("计划明细实际支付金额(单位分)") + private Long actualPrice; + + public void setActualPrice(BigDecimal actualPrice) { + this.actualPrice = actualPrice.scaleByPowerOfTen(2).longValue(); + } + + /** + * 计划明细名称 + */ + @ApiModelProperty("计划明细名称") + private String planDetailName; +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanVo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanVo.java new file mode 100644 index 0000000..ef453cb --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanVo.java @@ -0,0 +1,64 @@ +package com.cpop.jambox.business.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-05 16:13 + */ +@Data +@ApiModel("先学后付计划") +public class LearnNowPayLaterPlanVo { + + /** + * 支付分计划名称 + */ + @ApiModelProperty("支付分计划名称") + private String planName; + + /** + * 支付分计划有效期(单位天) + */ + @ApiModelProperty("支付分计划有效期(单位天)") + private Integer planDuration; + + /** + * 支付分计划扣费次数 + */ + @ApiModelProperty("支付分计划扣费次数") + private Integer deductionQuantity; + + + /** + * 支付分计划原总金额(单位分) + */ + @ApiModelProperty("支付分计划原总金额") + private Integer totalOriginalPrice; + + public void setTotalOriginalPrice(BigDecimal totalOriginalPrice) { + this.totalOriginalPrice = totalOriginalPrice.scaleByPowerOfTen(2).intValue(); + } + + /** + * 支付分计划实际扣费总金额(单位分) + */ + @ApiModelProperty("支付分计划实际扣费总金额(单位分)") + private Integer totalActualPrice; + + public void setTotalActualPrice(BigDecimal totalActualPrice) { + this.totalActualPrice = totalActualPrice.scaleByPowerOfTen(2).intValue(); + } + + /** + * 支付分计划明细列表 + */ + @ApiModelProperty("支付分计划明细列表") + private List planDetailList; + +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java index 965d87d..49635c4 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java @@ -3,10 +3,8 @@ package com.cpop.jambox.framework.tasks; import com.cpop.common.utils.bean.BeanUtils; import com.cpop.core.base.exception.ServiceException; import com.cpop.core.utils.SpringUtils; -import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.jambox.business.bo.LearnNowPayLaterPlanBo; import com.cpop.jambox.business.entity.CardTemplate; -import com.cpop.jambox.business.entity.CardTemplateExtend; import com.cpop.jambox.business.service.CardTemplateExtendService; import com.cpop.pay.framewok.handler.wxPay.WxPayHandler; import com.cpop.system.business.entity.WxPayScore; @@ -27,7 +25,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; import static com.cpop.jambox.business.entity.table.CardTemplateExtendTableDef.CARD_TEMPLATE_EXTEND; -import static com.cpop.jambox.business.entity.table.CardTemplateTableDef.CARD_TEMPLATE; import static com.cpop.system.business.entity.table.WxPayScoreTableDef.WX_PAY_SCORE; /** @@ -85,6 +82,7 @@ public class LearnNowPayLaterTask { //更新模板拓展 SpringUtils.getBean(CardTemplateExtendService.class).updateChain() .set(CARD_TEMPLATE_EXTEND.EXTEND_ID,wxPayScore.getId()) + .set(CARD_TEMPLATE_EXTEND.EXTEND_PARAM_ONE, true) .where(CARD_TEMPLATE_EXTEND.PAY_TYPE.eq(payType)) .and(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(cardTemplate.getId())) .update(); diff --git a/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java index eb61693..34faa32 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java +++ b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java @@ -51,19 +51,18 @@ public class CpopWxPayTests { WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount(); //退款金额(单位分) //int refund = order.getTotalAmount().scaleByPowerOfTen(2).intValue(); - int refund = 101; + int refund = 1; amount.setRefund(refund) .setTotal(refund) .setCurrency("CNY"); - request.setSubMchid(wxPayService.getConfig().getSubMchId()) - .setTransactionId("4200002126202312283733408828") - .setOutTradeNo("97945790336548864") + request.setTransactionId("4200002122202401129346519359") + //.setOutTradeNo("1000000000202401121937112562856") //.setTransactionId(order.getOutOrderNo()) //.setOutTradeNo(order.getId()) .setNotifyUrl(wxPayProperties.getNotifyRefund()) .setOutRefundNo(IdUtils.fastSimpleUUID()) .setSubMchid("1661323640") - .setReason("一次性支付退款") + .setReason("测试退款") .setAmount(amount); WxPayRefundV3Result result = wxPayService.refundV3(request); System.out.println(result); @@ -163,7 +162,7 @@ public class CpopWxPayTests { */ @Test public void getProfitSharingResult() throws WxPayException { - ProfitSharingV3Result profitSharingV3Result = wxPayService.getProfitSharingService().profitSharingQueryV3("1714609621691420672", "4200002015202310186547802213", "1650816616"); + ProfitSharingV3Result profitSharingV3Result = wxPayService.getProfitSharingService().profitSharingQueryV3("1745800085756895232", "4200002127202401122097980590", "1661323640"); System.out.println(profitSharingV3Result); } @@ -174,8 +173,8 @@ public class CpopWxPayTests { @Test public void profitSharingFinish() throws WxPayException { ProfitSharingUnfreezeRequest profitSharingFinishRequest = new ProfitSharingUnfreezeRequest(); - profitSharingFinishRequest.setTransactionId("4200002093202312282215936862"); - profitSharingFinishRequest.setOutOrderNo("97973671418667008"); + profitSharingFinishRequest.setTransactionId("4200002122202401129346519359"); + profitSharingFinishRequest.setOutOrderNo("1745820005743910912"); profitSharingFinishRequest.setDescription("结束分账"); profitSharingFinishRequest.setSubMchId("1661323640"); wxPayService.getProfitSharingService().profitSharingFinish(profitSharingFinishRequest); diff --git a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopEasyLearnTest.java b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopEasyLearnTest.java index 966f6ae..1481ca0 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopEasyLearnTest.java +++ b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopEasyLearnTest.java @@ -14,6 +14,7 @@ import com.cpop.pay.framewok.config.wxPay.WxPayProperties; import com.cpop.pay.framewok.handler.wxPay.WxPayHandler; import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingRequest; import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingResult; +import com.github.binarywang.wxpay.bean.request.WxPayPartnerOrderCloseV3Request; import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; @@ -43,7 +44,7 @@ import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EX * @since 2023-12-29 9:50 */ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles({"prod", "core", "jambox"}) +@ActiveProfiles({"dev", "core", "jambox"}) public class CpopEasyLearnTest { @Autowired @@ -199,4 +200,18 @@ public class CpopEasyLearnTest { } } } + + /** + * 关闭服务商订单 + * @author DB + * @since 2024/1/12 + */ + @Test + public void closePartnerOrderV3() throws WxPayException { + WxPayService wxPayService= wxPayHandler.getWxPayService(); + WxPayPartnerOrderCloseV3Request wxPayPartnerOrderCloseV3Request = new WxPayPartnerOrderCloseV3Request(); + wxPayPartnerOrderCloseV3Request.setSubMchId("1661323640"); + wxPayPartnerOrderCloseV3Request.setOutTradeNo("1745820005743910912"); + wxPayService.closePartnerOrderV3(wxPayPartnerOrderCloseV3Request); + } } From 792ac276c9ca6355982f930444b90ccdc1379f24 Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Fri, 19 Jan 2024 18:32:24 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=85=88=E5=AD=A6=E5=90=8E=E4=BB=98?= =?UTF-8?q?=E8=AF=A5=E8=BF=81=E7=A7=BB=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/bo/CardTemplateUnionBo.java | 12 ++ .../bo/EasyLearnDigitalCurrencyBo.java | 31 ++++ .../business/bo/EasyLearnOldContractBo.java | 37 ++++ .../backstage/CardTemplateController.java | 56 ------ .../mini/CardTemplateController.java | 82 +++++++++ .../mini/MiniEasyLearnController.java | 18 +- .../business/service/CardTemplateService.java | 3 +- .../service/impl/CardTemplateServiceImpl.java | 162 ++++++++++++++++-- .../vo/LearnNowPayLaterPlanDetailVo.java | 12 +- .../business/vo/LearnNowPayLaterPlanVo.java | 18 +- .../framework/tasks/LearnNowPayLaterTask.java | 50 +++++- .../src/main/resources/application.yml | 2 +- Cpop-Mall/pom.xml | 4 + .../mini/MiniProductController.java | 2 +- .../src/main/resources/application-dev.yml | 2 +- .../src/main/resources/application-prod.yml | 4 +- .../src/main/resources/application-test.yml | 14 +- .../src/main/resources/application.yml | 2 +- .../com/cpop/oam/web/CpopEasyLearnTest.java | 91 +++++++++- Cpop-Oam/pom.xml | 4 + .../service/impl/DataImportServiceImpl.java | 36 +++- .../service/impl/TaskServiceImpl.java | 90 ++++++---- .../framework/constant/OamRedisConstant.java | 19 ++ .../config/wxPay/WxPayProperties.java | 5 + .../framewok/handler/wxPay/WxPayHandler.java | 45 ----- .../src/main/resources/application-pay.yml | 2 + 26 files changed, 601 insertions(+), 202 deletions(-) create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/EasyLearnDigitalCurrencyBo.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/EasyLearnOldContractBo.java delete mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/CardTemplateController.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/framework/constant/OamRedisConstant.java diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java index 4d08e0b..263d5d2 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java @@ -146,4 +146,16 @@ public class CardTemplateUnionBo { */ @ApiModelProperty("先学后付(月付)") private LearnNowPayLaterPlanBo learnNowPayLaterMonthPay; + + /** + * 放心学旧合同 + */ + @ApiModelProperty("放心学旧合同") + private EasyLearnOldContractBo easyLearnOldContract; + + /** + * 放心学数币 + */ + @ApiModelProperty("放心学数币") + private EasyLearnDigitalCurrencyBo easyLearnDigitalCurrency; } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/EasyLearnDigitalCurrencyBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/EasyLearnDigitalCurrencyBo.java new file mode 100644 index 0000000..edfdfe7 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/EasyLearnDigitalCurrencyBo.java @@ -0,0 +1,31 @@ +package com.cpop.jambox.business.bo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-19 9:44 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "EasyLearnDigitalCurrencyBo对象", description = "放心学数币参数") +public class EasyLearnDigitalCurrencyBo { + + /** + * 是否是数币活动 + */ + private Boolean isActivity; + + /** + * 活动码 + */ + private String activityCode; + + /** + * 活动描述 + */ + private String activityDesc; +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/EasyLearnOldContractBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/EasyLearnOldContractBo.java new file mode 100644 index 0000000..eb1f145 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/EasyLearnOldContractBo.java @@ -0,0 +1,37 @@ +package com.cpop.jambox.business.bo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-19 9:36 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "EasyLearnOldContractBo对象", description = "放心学旧合同参数") +public class EasyLearnOldContractBo { + + /** + * 期数 + */ + @ApiModelProperty("期数") + private Integer stageNum; + + /** + * 押金 + */ + @ApiModelProperty("押金") + private BigDecimal deposit; + + /** + * 首期缓冲天数 + */ + @ApiModelProperty("首期缓冲天数") + private Integer firstBufferDay; +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java deleted file mode 100644 index fb9c8fb..0000000 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/backstage/CardTemplateController.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.cpop.jambox.business.controller.backstage; - -import com.cpop.core.base.R; -import com.cpop.jambox.business.bo.CardTemplateUnionBo; -import com.cpop.jambox.business.service.CardTemplateService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 果酱-课卡模板 控制层。 - * - * @author DB - * @since 2023-09-27 - */ -@RestController -@Api(tags = "果酱-课卡模板接口") -@RequestMapping("/cardTemplate") -public class CardTemplateController { - - @Autowired - private CardTemplateService cardTemplateService; - - /** - * 添加课卡模板(整合) - * @author DB - * @since 2023/10/07 9:59 - * @param bo 请求参数 - */ - //@SimpleSignatureCheck - @ApiOperation(value = "添加课卡模板(整合)") - @PostMapping("/insertCardTemplateUnion") - public R insertCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { - cardTemplateService.insertCardTemplateUnion(bo); - return R.ok(); - } - - /** - * 修改课卡模板(整合) - * @author DB - * @since 2023/10/07 9:59 - * @param bo 请求参数 - */ - //@SimpleSignatureCheck - @ApiOperation(value = "修改课卡模板(整合)") - @PostMapping("/updateCardTemplateUnion") - public R updateCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { - cardTemplateService.updateCardTemplateUnion(bo); - return R.ok(); - } -} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/CardTemplateController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/CardTemplateController.java new file mode 100644 index 0000000..0d594f9 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/CardTemplateController.java @@ -0,0 +1,82 @@ +package com.cpop.jambox.business.controller.mini; + +import com.cpop.core.annontation.SimpleSignatureCheck; +import com.cpop.core.base.R; +import com.cpop.core.utils.SpringUtils; +import com.cpop.jambox.business.bo.CardTemplateUnionBo; +import com.cpop.jambox.business.entity.CardTemplate; +import com.cpop.jambox.business.service.CardTemplateExtendService; +import com.cpop.jambox.business.service.CardTemplateService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.ibatis.annotations.Delete; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import static com.cpop.jambox.business.entity.table.CardTemplateExtendTableDef.CARD_TEMPLATE_EXTEND; +import static com.cpop.jambox.business.entity.table.CardTemplateTableDef.CARD_TEMPLATE; + +/** + * 果酱-课卡模板 控制层。 + * + * @author DB + * @since 2023-09-27 + */ +@RestController +@Api(tags = "果酱-课卡模板接口") +@RequestMapping("/mini/cardTemplate") +public class CardTemplateController { + + @Autowired + private CardTemplateService cardTemplateService; + + /** + * 添加课卡模板(整合) + * @author DB + * @since 2023/10/07 9:59 + * @param bo 请求参数 + */ + //@SimpleSignatureCheck + @ApiOperation(value = "添加课卡模板(整合)") + @PostMapping("/insertCardTemplateUnion") + public R insertCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { + cardTemplateService.insertCardTemplateUnion(bo); + return R.ok(); + } + + /** + * 修改课卡模板(整合) + * @author DB + * @since 2023/10/07 9:59 + * @param bo 请求参数 + */ + //@SimpleSignatureCheck + @ApiOperation(value = "修改课卡模板(整合)") + @PutMapping("/updateCardTemplateUnion") + public R updateCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) { + cardTemplateService.updateCardTemplateUnion(bo); + return R.ok(); + } + + /** + * 删除课卡模板 + * @author DB + * @since 2024/1/19 + * @param oldId 旧主键id + * @return R + */ + @Deprecated + @ApiOperation(value = "删除课卡模板") + @DeleteMapping("/removeCardTemplateById/{oldId}") + public R removeCardTemplateById(@PathVariable String oldId) { + CardTemplate cardTemplate = cardTemplateService.queryChain().where(CARD_TEMPLATE.OLD_TEMPLATE_ID.eq(oldId)).one(); + cardTemplateService.updateChain() + .where(CARD_TEMPLATE.OLD_TEMPLATE_ID.eq(oldId)) + .remove(); + SpringUtils.getBean(CardTemplateExtendService.class).updateChain() + .where(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(cardTemplate.getId())) + .remove(); + return R.ok(); + } +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java index 8f3d9b1..524af37 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java @@ -4,6 +4,7 @@ import com.cpop.core.base.R; import com.cpop.jambox.business.service.CardTemplateService; import com.cpop.jambox.business.service.EasyLearnOrderService; import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; +import com.cpop.jambox.business.vo.LearnNowPayLaterPlanVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -36,24 +37,25 @@ public class MiniEasyLearnController { */ @ApiOperation("获取支付分计划") @GetMapping("/getWxPayScorePlan") - public R getWxPayScorePlan(@ApiParam(value = "旧模板id",required = true) @RequestParam("oldTemplateId") String oldTemplateId, - @ApiParam(value = "是否月付(0否1是)",required = true) @RequestParam("isMonth") Boolean isMonth) { - LearnNowPayLaterPlanDetailVo vo = cardTemplateService.getWxPayScorePlan(oldTemplateId,isMonth); + public R getWxPayScorePlan(@ApiParam(value = "旧模板id", required = true) @RequestParam("oldTemplateId") String oldTemplateId, + @ApiParam(value = "是否月付(0否1是)", required = true) @RequestParam("isMonth") Boolean isMonth) { + LearnNowPayLaterPlanVo vo = cardTemplateService.getWxPayScorePlan(oldTemplateId, isMonth); return R.ok(vo); } /** * 获取支付分计划 + * + * @param oldTemplateId 旧模板id + * @param isMonth 是否月付 + * @return R * @author DB * @since 2024/1/18 - * @param oldTemplateId 旧模板id - * @param isMonth 是否月付 - * @return R */ @ApiOperation("创建用户签约计划") @PostMapping("/createUserSignPlans") - public R createUserSignPlans(@ApiParam(value = "旧模板id",required = true) @RequestParam("oldTemplateId") String oldTemplateId, - @ApiParam(value = "是否月付(0否1是)",required = true) @RequestParam("isMonth") Boolean isMonth) { + public R createUserSignPlans(@ApiParam(value = "旧模板id", required = true) @RequestParam("oldTemplateId") String oldTemplateId, + @ApiParam(value = "是否月付(0否1是)", required = true) @RequestParam("isMonth") Boolean isMonth) { return R.ok(); } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java index 93e00c2..c587f7e 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java @@ -3,6 +3,7 @@ package com.cpop.jambox.business.service; import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.jambox.business.entity.CardTemplate; import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; +import com.cpop.jambox.business.vo.LearnNowPayLaterPlanVo; import com.mybatisflex.core.row.Row; import com.mybatisflex.core.service.IService; @@ -49,5 +50,5 @@ public interface CardTemplateService extends IService { * @param isMonth 是否月付 * @return LearnNowPayLaterPlanDetailVo */ - LearnNowPayLaterPlanDetailVo getWxPayScorePlan(String oldTemplateId, Boolean isMonth); + LearnNowPayLaterPlanVo getWxPayScorePlan(String oldTemplateId, Boolean isMonth); } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java index 4277dc0..23b3417 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java @@ -4,6 +4,8 @@ import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.bean.BeanUtils; import com.cpop.core.utils.SpringUtils; import com.cpop.jambox.business.bo.CardTemplateUnionBo; +import com.cpop.jambox.business.bo.EasyLearnDigitalCurrencyBo; +import com.cpop.jambox.business.bo.EasyLearnOldContractBo; import com.cpop.jambox.business.entity.BrandExtend; import com.cpop.jambox.business.entity.CardTemplate; import com.cpop.jambox.business.entity.CardTemplateExtend; @@ -14,9 +16,13 @@ import com.cpop.jambox.business.service.CardTemplateExtendService; import com.cpop.jambox.business.service.CardTemplateService; import com.cpop.jambox.business.service.StoreExtendService; import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; +import com.cpop.jambox.business.vo.LearnNowPayLaterPlanVo; import com.cpop.jambox.framework.tasks.LearnNowPayLaterTask; import com.cpop.system.business.entity.Store; +import com.cpop.system.business.entity.WxPayScoreDetail; import com.cpop.system.business.service.StoreService; +import com.cpop.system.business.service.WxPayScoreDetailService; +import com.cpop.system.business.service.WxPayScoreService; import com.mybatisflex.core.datasource.DataSourceKey; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.row.Db; @@ -27,12 +33,15 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND; import static com.cpop.jambox.business.entity.table.CardTemplateExtendTableDef.CARD_TEMPLATE_EXTEND; import static com.cpop.jambox.business.entity.table.CardTemplateTableDef.CARD_TEMPLATE; import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND; +import static com.cpop.system.business.entity.table.WxPayScoreDetailTableDef.WX_PAY_SCORE_DETAIL; +import static com.cpop.system.business.entity.table.WxPayScoreTableDef.WX_PAY_SCORE; /** * 果酱-课卡模板 服务层实现。 @@ -90,15 +99,7 @@ public class CardTemplateServiceImpl extends ServiceImpl cardTemplateExtends = new ArrayList<>(); - //添加课卡模板拓展 - bo.getPayType().forEach(item->{ - //TODO: 新增模板拓展 - CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); - cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(item); - cardTemplateExtends.add(cardTemplateExtend); - }); - SpringUtils.getBean(CardTemplateExtendService.class).saveBatch(cardTemplateExtends); + saveTemplateExtend(cardTemplate,bo); //次付 if (bo.getPayType().contains(1)) { SpringUtils.getBean(LearnNowPayLaterTask.class).asyncCreateLearnNowPayLaterPlan(cardTemplate, bo.getLearnNowPayLaterPay(), 1); @@ -109,6 +110,51 @@ public class CardTemplateServiceImpl extends ServiceImpl cardTemplateExtends = new ArrayList<>(); + List payTypeList = bo.getPayType(); + //普通微信支付 + if (payTypeList.contains(0)){ + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(0); + cardTemplateExtends.add(cardTemplateExtend); + } + //放心学合约支付 + if (payTypeList.contains(2)){ + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + EasyLearnOldContractBo easyLearnOldContract = bo.getEasyLearnOldContract(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(2) + .setExtendParamOne(easyLearnOldContract.getStageNum().toString()) + .setExtendParamTwo(easyLearnOldContract.getDeposit().toString()) + .setExtendParamThree(easyLearnOldContract.getFirstBufferDay().toString()); + cardTemplateExtends.add(cardTemplateExtend); + } + //数字人民币支付 + if (payTypeList.contains(3)){ + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + EasyLearnDigitalCurrencyBo easyLearnDigitalCurrency = bo.getEasyLearnDigitalCurrency(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(3) + .setExtendParamOne(easyLearnDigitalCurrency.getIsActivity().toString()) + .setExtendParamTwo(easyLearnDigitalCurrency.getActivityCode()) + .setExtendParamThree(easyLearnDigitalCurrency.getActivityDesc()); + cardTemplateExtends.add(cardTemplateExtend); + } + //线下支付 + if (payTypeList.contains(4)){ + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(4); + cardTemplateExtends.add(cardTemplateExtend); + } + SpringUtils.getBean(CardTemplateExtendService.class).saveBatch(cardTemplateExtends); + } + /** * 修改课卡模板(整合) * @author DB @@ -122,10 +168,7 @@ public class CardTemplateServiceImpl extends ServiceImpl cardTemplateExtends = cardTemplateExtendService.list(QueryWrapper.create() .where(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(bo.getOldTemplateId()))); - //添加课卡模板拓展 - List filterPayType = bo.getPayType().stream().filter(item -> item != 1 && item != 5).collect(Collectors.toList()); - //TODO: 新增或修改模板拓展 - + updateTemplateExtend(cardTemplate, bo, cardTemplateExtends); //次付 List payTypeList = cardTemplateExtends.stream().map(CardTemplateExtend::getPayType).collect(Collectors.toList()); if (bo.getPayType().contains(1) && !payTypeList.contains(1)) { @@ -153,6 +196,83 @@ public class CardTemplateServiceImpl extends ServiceImpl cardTemplateExtends) { + List payTypeList = bo.getPayType(); + Map existExtends = cardTemplateExtends.stream().collect(Collectors.toMap(CardTemplateExtend::getPayType, item -> item)); + List removePayTypes = new ArrayList<>(); + //普通微信支付 + if (payTypeList.contains(0)) { + if (existExtends.get(0) == null) { + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(0); + cardTemplateExtends.add(cardTemplateExtend); + } + } else { + removePayTypes.add(0); + } + //放心学旧合约支付 + if (payTypeList.contains(2)) { + CardTemplateExtend cardTemplateExtend; + EasyLearnOldContractBo easyLearnOldContract = bo.getEasyLearnOldContract(); + if (existExtends.get(2) == null) { + cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(2) + .setExtendParamOne(easyLearnOldContract.getStageNum().toString()) + .setExtendParamTwo(easyLearnOldContract.getDeposit().toString()) + .setExtendParamThree(easyLearnOldContract.getFirstBufferDay().toString()); + } else { + cardTemplateExtend = existExtends.get(2); + cardTemplateExtend.setExtendParamOne(easyLearnOldContract.getStageNum().toString()) + .setExtendParamTwo(easyLearnOldContract.getDeposit().toString()) + .setExtendParamThree(easyLearnOldContract.getFirstBufferDay().toString()); + } + cardTemplateExtends.add(cardTemplateExtend); + } else { + removePayTypes.add(2); + } + //数字人民币支付 + if (payTypeList.contains(3)){ + CardTemplateExtend cardTemplateExtend; + EasyLearnDigitalCurrencyBo easyLearnDigitalCurrency = bo.getEasyLearnDigitalCurrency(); + if (existExtends.get(3) == null) { + cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(3) + .setExtendParamOne(easyLearnDigitalCurrency.getIsActivity().toString()) + .setExtendParamTwo(easyLearnDigitalCurrency.getActivityCode()) + .setExtendParamThree(easyLearnDigitalCurrency.getActivityDesc()); + } else { + cardTemplateExtend = existExtends.get(3); + cardTemplateExtend.setExtendParamOne(easyLearnDigitalCurrency.getIsActivity().toString()) + .setExtendParamTwo(easyLearnDigitalCurrency.getActivityCode()) + .setExtendParamThree(easyLearnDigitalCurrency.getActivityDesc()); + } + cardTemplateExtends.add(cardTemplateExtend); + } else { + removePayTypes.add(3); + } + //线下支付 + if (payTypeList.contains(4)) { + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()).setPayType(4); + cardTemplateExtends.add(cardTemplateExtend); + } else { + removePayTypes.add(4); + } + CardTemplateExtendService cardTemplateExtendService = SpringUtils.getBean(CardTemplateExtendService.class); + cardTemplateExtendService.saveBatch(cardTemplateExtends); + cardTemplateExtendService.updateChain() + .where(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(cardTemplate.getId())) + .and(CARD_TEMPLATE_EXTEND.PAY_TYPE.in(removePayTypes)) + .remove(); + } + /** * 获取支付分计划 * @author DB @@ -162,8 +282,20 @@ public class CardTemplateServiceImpl extends ServiceImpl detailVos = SpringUtils.getBean(WxPayScoreDetailService.class).listAs(QueryWrapper.create() + .where(WX_PAY_SCORE_DETAIL.SYS_WX_PAY_SCORE_ID.eq(vo.getId())), + LearnNowPayLaterPlanDetailVo.class); + vo.setPlanDetailList(detailVos); + return vo; } } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java index 9266ea4..1c9d2b0 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java @@ -25,20 +25,20 @@ public class LearnNowPayLaterPlanDetailVo { * 计划明细原支付金额(单位分) */ @ApiModelProperty("计划明细原支付金额(单位分)") - private Integer originalPrice; + private BigDecimal originalPrice; - public void setOriginalPrice(BigDecimal originalPrice) { - this.originalPrice = originalPrice.scaleByPowerOfTen(2).intValue(); + public void setOriginalPrice(Integer originalPrice) { + this.originalPrice = new BigDecimal(originalPrice).divide(BigDecimal.valueOf(100)); } /** * 计划明细实际支付金额(单位分) */ @ApiModelProperty("计划明细实际支付金额(单位分)") - private Long actualPrice; + private BigDecimal actualPrice; - public void setActualPrice(BigDecimal actualPrice) { - this.actualPrice = actualPrice.scaleByPowerOfTen(2).longValue(); + public void setActualPrice(Integer actualPrice) { + this.actualPrice = new BigDecimal(actualPrice).divide(BigDecimal.valueOf(100)); } /** diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanVo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanVo.java index ef453cb..7d14c17 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanVo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanVo.java @@ -16,6 +16,12 @@ import java.util.List; @ApiModel("先学后付计划") public class LearnNowPayLaterPlanVo { + /** + * 主键 + */ + @ApiModelProperty("计划分主键") + private String id; + /** * 支付分计划名称 */ @@ -39,20 +45,20 @@ public class LearnNowPayLaterPlanVo { * 支付分计划原总金额(单位分) */ @ApiModelProperty("支付分计划原总金额") - private Integer totalOriginalPrice; + private BigDecimal totalOriginalPrice; - public void setTotalOriginalPrice(BigDecimal totalOriginalPrice) { - this.totalOriginalPrice = totalOriginalPrice.scaleByPowerOfTen(2).intValue(); + public void setTotalOriginalPrice(Integer totalOriginalPrice) { + this.totalOriginalPrice = new BigDecimal(totalOriginalPrice).divide(BigDecimal.valueOf(100)); } /** * 支付分计划实际扣费总金额(单位分) */ @ApiModelProperty("支付分计划实际扣费总金额(单位分)") - private Integer totalActualPrice; + private BigDecimal totalActualPrice; - public void setTotalActualPrice(BigDecimal totalActualPrice) { - this.totalActualPrice = totalActualPrice.scaleByPowerOfTen(2).intValue(); + public void setTotalActualPrice(Integer totalActualPrice) { + this.totalActualPrice = new BigDecimal(totalActualPrice).divide(BigDecimal.valueOf(100)); } /** diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java index 49635c4..2474e68 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java @@ -1,11 +1,15 @@ package com.cpop.jambox.framework.tasks; +import com.alibaba.fastjson.JSONArray; +import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.bean.BeanUtils; import com.cpop.core.base.exception.ServiceException; import com.cpop.core.utils.SpringUtils; import com.cpop.jambox.business.bo.LearnNowPayLaterPlanBo; import com.cpop.jambox.business.entity.CardTemplate; +import com.cpop.jambox.business.entity.CardTemplateExtend; import com.cpop.jambox.business.service.CardTemplateExtendService; +import com.cpop.pay.framewok.config.wxPay.WxPayConfiguration; import com.cpop.pay.framewok.handler.wxPay.WxPayHandler; import com.cpop.system.business.entity.WxPayScore; import com.cpop.system.business.entity.WxPayScoreDetail; @@ -17,11 +21,16 @@ import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanResult import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.PartnerPayScoreSignPlanService; import com.github.binarywang.wxpay.service.WxPayService; +import com.mybatisflex.core.datasource.DataSourceKey; +import com.mybatisflex.core.row.DbChain; +import com.mybatisflex.core.row.Row; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.util.Arrays; import java.util.List; import static com.cpop.jambox.business.entity.table.CardTemplateExtendTableDef.CARD_TEMPLATE_EXTEND; @@ -33,11 +42,15 @@ import static com.cpop.system.business.entity.table.WxPayScoreTableDef.WX_PAY_SC * @since 2024-01-17 18:18 */ @Component +@Slf4j public class LearnNowPayLaterTask { @Autowired private WxPayHandler wxPayHandler; + @Autowired + private WxPayConfiguration wxPayConfiguration; + /** * 异步创建先学后付计划 * @author DB @@ -59,13 +72,36 @@ public class LearnNowPayLaterTask { PartnerPayScoreSignPlanService partnerPayScoreSignPlanService = wxPayService.getPartnerPayScoreSignPlanService(); WxPartnerPayScoreSignPlanRequest planRequest = BeanUtils.mapToClass(bo,WxPartnerPayScoreSignPlanRequest.class); List payScorePlanDetailRequests = BeanUtils.mapToList(bo.getPlanDetailList(), PayScorePlanDetailRequest.class); + planRequest.setAppid(wxPayConfiguration.getProperties().getServiceAppId()); + planRequest.setSubMchid(subMchId); planRequest.setPlanDetailList(payScorePlanDetailRequests); planRequest.setMerchantPlanNo(wxPayScore.getId()); WxPartnerPayScoreSignPlanResult result; + CardTemplateExtendService cardTemplateExtendService = SpringUtils.getBean(CardTemplateExtendService.class); //设置商户侧计划 try { result = partnerPayScoreSignPlanService.createPlans(planRequest); } catch (WxPayException e) { + //删除计划开通 + try { + //查询旧表 + DataSourceKey.use("jambox"); + Row oldTemplate = DbChain.table("t_card_template") + .select("template_id as oldTemplateId") + .select("pay_type as payTypes") + .from("t_card_template") + .where("template_id = ?", cardTemplate.getOldTemplateId()) + .one(); + //移除 + List payTypes = Arrays.asList(oldTemplate.getString("payTypes").split(",")); + payTypes.remove(payType.toString()); + DbChain.table("t_card_template") + .set("pay_type", StringUtils.join(payTypes, ",")) + .where("template_id = ?", cardTemplate.getOldTemplateId()) + .update(); + } finally { + DataSourceKey.clear(); + } throw new ServiceException(e.getMessage()); } List wxPayScoreDetails = BeanUtils.mapToList(result.getPlanDetailList(), WxPayScoreDetail.class); @@ -79,12 +115,12 @@ public class LearnNowPayLaterTask { .set(WX_PAY_SCORE.OUT_PLAN_ID,result.getPlanId()) .where(WX_PAY_SCORE.ID.eq(wxPayScore.getId())) .update(); - //更新模板拓展 - SpringUtils.getBean(CardTemplateExtendService.class).updateChain() - .set(CARD_TEMPLATE_EXTEND.EXTEND_ID,wxPayScore.getId()) - .set(CARD_TEMPLATE_EXTEND.EXTEND_PARAM_ONE, true) - .where(CARD_TEMPLATE_EXTEND.PAY_TYPE.eq(payType)) - .and(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(cardTemplate.getId())) - .update(); + //模板拓展 + CardTemplateExtend cardTemplateExtend = new CardTemplateExtend(); + cardTemplateExtend.setTemplateId(cardTemplate.getId()) + .setExtendId(wxPayScore.getId()) + .setExtendParamOne("1") + .setPayType(payType); + cardTemplateExtendService.save(cardTemplateExtend); } } diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application.yml index dc2e707..f792c14 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application.yml @@ -31,7 +31,7 @@ spring: max-file-size: 1024MB max-request-size: 300MB profiles: - active: dev,core,mall,system + active: dev,mall,core,jambox,system,pay datasource: type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/Cpop-Mall/pom.xml b/Cpop-Mall/pom.xml index c97662d..afdee19 100644 --- a/Cpop-Mall/pom.xml +++ b/Cpop-Mall/pom.xml @@ -27,6 +27,10 @@ com.cpop Cpop-Jambox + + com.cpop + Cpop-Pay + diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/mini/MiniProductController.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/mini/MiniProductController.java index 34d0bc3..1728e4c 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/mini/MiniProductController.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/mini/MiniProductController.java @@ -137,7 +137,7 @@ public class MiniProductController { public R> getCarouselList() { JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); List vos = carouselService.queryChain().where(CAROUSEL.BRAND_ID.eq(loginUserInfo.getString("brandId")) - .and(CAROUSEL.UP_STATUS.eq(true))).listAs(CarouselListVo.class); + .and(CAROUSEL.UP_STATUS.eq(true))).orderBy(CAROUSEL.ORDER_NO.asc()).listAs(CarouselListVo.class); return R.ok(vos); } } diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml index d1ec61d..6eda66c 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml @@ -4,7 +4,7 @@ cpop: profile: E:/Cpop/uploadPath jwt: #白名单 - whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/wxCp/*,/wxCp/portal/*/registerCode,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/*/*,/easyLearn/*,/cardTemplate/insertCardTemplateUnion + whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/wxCp/*,/wxCp/portal/*/registerCode,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/*/*,/easyLearn/*,/mini/cardTemplate/* gateway: rsa-keypair: # 公钥文件 diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-prod.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-prod.yml index 234e7f4..0902d5c 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-prod.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-prod.yml @@ -4,7 +4,7 @@ cpop: profile: /root/cpop-union/cpop-oam/upload jwt: #白名单 - whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*,/wxCp/*,/wxCp/portal/*/registerCode,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/*/*,/easyLearn/* + whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*,/wxCp/*,/wxCp/portal/*/registerCode,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/*/*,/easyLearn/*,/mini/cardTemplate/* #拦截 gateway: rsa-keypair: @@ -73,4 +73,4 @@ wx: # 私钥证书 privateKeyPath: /root/cpop-union/cpop-oam/script/secretKey/wxPay_key.pem # 私钥文件 - privateCertPath: /root/cpop-union/cpop-oam/script/secretKey/wxPay_cert.pem + privateCertPath: /root/cpop-union/cpop-oam/script/secretKey/wxPay_cert.pem \ No newline at end of file diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml index 8f005b9..d222961 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml @@ -4,7 +4,7 @@ cpop: profile: /root/cpop-union/cpop-mall/upload jwt: #白名单 - whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*,/wxCp/portal/*/registerCode,/wxCp/*,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/*/*,/easyLearn/* + whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*,/wxCp/portal/*/registerCode,/wxCp/*,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/*/*,/easyLearn/*,/mini/cardTemplate/* #拦截 gateway: rsa-keypair: @@ -12,10 +12,6 @@ cpop: publicKeyFile: /root/jambox-union/jambox-oam/script/secretKey/publicKey # 公钥文件 privateKeyFile: /root/jambox-union/jambox-oam/script/secretKey/privateKey - # 公钥文件 - #publicKeyFile: E:\Cpop\Cpop-Union\Cpop-Core\src\main\resources\static\keyPair\publicKey - # 公钥文件 - #privateKeyFile: E:\Cpop\Cpop-Union\Cpop-Core\src\main\resources\static\keyPair\privateKey # DataSource Config spring: @@ -98,10 +94,4 @@ wx: # 私钥证书 privateKeyPath: /root/cpop-union/cpop-oam/script/secretKey/wxPay_key.pem # 私钥文件 - privateCertPath: /root/cpop-union/cpop-oam/script/secretKey/wxPay_cert.pem - # p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头) - #keyPath: E:/Cpop/Cpop-Union/Cpop-Core/src/main/resources/static/keyPair/wxPay_cert.p12 - # 私钥证书 - #privateKeyPath: E:/Cpop/Cpop-Union/Cpop-Core/src/main/resources/static/keyPair/wxPay_key.pem - # 私钥文件 - #privateCertPath: E:/Cpop/Cpop-Union/Cpop-Core/src/main/resources/static/keyPair/wxPay_cert.pem \ No newline at end of file + privateCertPath: /root/cpop-union/cpop-oam/script/secretKey/wxPay_cert.pem \ No newline at end of file diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application.yml index 2163b9a..164a41d 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application.yml @@ -31,7 +31,7 @@ spring: max-file-size: 1024MB max-request-size: 300MB profiles: - active: dev,core,jambox,pay + active: dev,oam,core,jambox,system,pay datasource: type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopEasyLearnTest.java b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopEasyLearnTest.java index 1481ca0..1acadc5 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopEasyLearnTest.java +++ b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopEasyLearnTest.java @@ -12,11 +12,22 @@ import com.cpop.jambox.business.service.StoreExtendService; import com.cpop.jambox.framework.constant.JamboxCloudUrl; import com.cpop.pay.framewok.config.wxPay.WxPayProperties; import com.cpop.pay.framewok.handler.wxPay.WxPayHandler; +import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingBillV3Request; +import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingReceiverRequest; import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingRequest; +import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingBillV3Result; +import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingOrderAmountQueryV3Result; import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingResult; +import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingV3Result; +import com.github.binarywang.wxpay.bean.request.WxPayApplyTradeBillV3Request; +import com.github.binarywang.wxpay.bean.request.WxPayOrderQueryRequest; +import com.github.binarywang.wxpay.bean.request.WxPayOrderQueryV3Request; import com.github.binarywang.wxpay.bean.request.WxPayPartnerOrderCloseV3Request; +import com.github.binarywang.wxpay.bean.result.WxPayApplyBillV3Result; +import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult; import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.ProfitSharingService; import com.github.binarywang.wxpay.service.WxPayService; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.row.Db; @@ -29,6 +40,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.web.client.RestTemplate; +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashMap; @@ -44,7 +58,7 @@ import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EX * @since 2023-12-29 9:50 */ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles({"dev", "core", "jambox"}) +@ActiveProfiles({"dev", "core", "jambox", "pay"}) public class CpopEasyLearnTest { @Autowired @@ -214,4 +228,79 @@ public class CpopEasyLearnTest { wxPayPartnerOrderCloseV3Request.setOutTradeNo("1745820005743910912"); wxPayService.closePartnerOrderV3(wxPayPartnerOrderCloseV3Request); } + + /** + * 查询未完结订单 + * @author DB + * @since 2024/1/19 + */ + @Test + public void downloadBill() throws WxPayException { + WxPayService wxPayService = wxPayHandler.getWxPayService(null, "1663310469"); + ProfitSharingService profitSharingService = wxPayService.getProfitSharingService(); + ProfitSharingBillV3Request profitSharingBillV3Request = new ProfitSharingBillV3Request(); + profitSharingBillV3Request.setSubMchId("1663310469"); + String date = "2024-01-17"; + profitSharingBillV3Request.setBillDate(date); + WxPayApplyTradeBillV3Request wxPayApplyTradeBillV3Request = new WxPayApplyTradeBillV3Request(); + wxPayApplyTradeBillV3Request.setBillDate(date); + wxPayApplyTradeBillV3Request.setBillType("ALL"); + WxPayApplyBillV3Result wxPayApplyBillV3Result = wxPayService.applyTradeBill(wxPayApplyTradeBillV3Request); + //ProfitSharingBillV3Result profitSharingBillV3Result = profitSharingService.profitSharingBill(profitSharingBillV3Request); + InputStream inputStream = wxPayService.downloadBill(wxPayApplyBillV3Result.getDownloadUrl()); + new File(""); + // 创建输出文件的路径 + String filePath = "D:\\Lost\\下载\\" + date + ".txt"; + // 将输入流中的内容写入文件 + try (OutputStream outputStream = Files.newOutputStream(Paths.get(filePath))) { + byte[] buffer = new byte[8192]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + System.out.println("内容成功写入文件"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void queryOrderAndSharing() throws WxPayException { + WxPayService wxPayService = wxPayHandler.getWxPayService(null, "1663310469"); + WxPayOrderQueryRequest wxPayOrderQueryRequest = new WxPayOrderQueryRequest(); + wxPayOrderQueryRequest.setTransactionId("4200001925202401173471747106"); + WxPayOrderQueryResult wxPayOrderQueryResult = wxPayService.queryOrder(wxPayOrderQueryRequest); + ProfitSharingService profitSharingService = wxPayService.getProfitSharingService(); + ProfitSharingV3Result profitSharingV3Result = profitSharingService.profitSharingQueryV3("105490200209170432", "4200002126202401189482541307", "1663310469"); + ProfitSharingOrderAmountQueryV3Result profitSharingOrderAmountQueryV3Result = profitSharingService.profitSharingUnsplitAmountQueryV3("4200001925202401173471747106"); + System.out.println(JSONObject.toJSONString(wxPayOrderQueryResult)); + System.out.println(JSONObject.toJSONString(profitSharingV3Result)); + } + + @Test + public void orderProfitSharing() throws WxPayException { + //固定商户信息 + Map mapReceiver = new HashMap<>(4); + mapReceiver.put("type", "MERCHANT_ID"); + mapReceiver.put("account", wxPayProperties.getSharingAccount()); + mapReceiver.put("amount", 900); + mapReceiver.put("description","分账到服务商"); + List> receivers = new ArrayList<>(); + receivers.add(mapReceiver); + //分账请求参数 + ProfitSharingRequest profitSharingRequest = new ProfitSharingRequest(); + profitSharingRequest.setReceivers(JSONObject.toJSONString(receivers)); + profitSharingRequest.setOutOrderNo("105490200209170432"); + profitSharingRequest.setTransactionId("4200002126202401189482541307"); + profitSharingRequest.setSubMchId("1663310469"); + ProfitSharingResult profitSharingResult = wxPayService.getProfitSharingService().profitSharing(profitSharingRequest); + if (StringUtils.equals(profitSharingResult.getResultCode(), "SUCCESS")) { + //存入系统 + DbChain.table("cp_sys_profit_sharing") + .set("out_profit_sharing_id", profitSharingResult.getOrderId()) + .set("profit_sharing_status", 1) + .where("id = ?", profitSharingResult.getOutOrderNo()) + .update(); + } + } } diff --git a/Cpop-Oam/pom.xml b/Cpop-Oam/pom.xml index 5e2d5d8..df77285 100644 --- a/Cpop-Oam/pom.xml +++ b/Cpop-Oam/pom.xml @@ -27,6 +27,10 @@ com.cpop Cpop-System + + com.cpop + Cpop-Pay + com.github.binarywang diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java index 6bb2e04..05fe893 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DataImportServiceImpl.java @@ -1,5 +1,6 @@ package com.cpop.oam.business.service.impl; +import cn.hutool.core.util.IdUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.exception.ExcelDataConvertException; @@ -12,10 +13,12 @@ import com.cpop.core.base.entity.PageDomain; import com.cpop.core.base.enums.SourceType; import com.cpop.core.base.exception.ServiceException; import com.cpop.core.handler.TencentCosHandler; +import com.cpop.core.service.RedisService; import com.cpop.core.utils.SpringUtils; import com.cpop.core.utils.file.FileUploadUtils; import com.cpop.core.utils.file.FileUtils; import com.cpop.core.utils.sql.SqlUtils; +import com.cpop.core.utils.uuid.IdUtils; import com.cpop.jambox.business.entity.StoreExtend; import com.cpop.jambox.business.service.StoreExtendService; import com.cpop.jambox.framework.constant.JamboxCloudUrl; @@ -24,6 +27,7 @@ import com.cpop.oam.business.bo.DataImportPageBo; import com.cpop.oam.business.dto.DataImportDto; import com.cpop.oam.business.dto.DataImportParamsDto; import com.cpop.oam.business.vo.DataImportPageVo; +import com.cpop.oam.framework.constant.OamRedisConstant; import com.cpop.oam.framework.constant.WebHookKeyConstant; import com.cpop.system.business.vo.SysFileVo; import com.mybatisflex.core.paginate.Page; @@ -44,6 +48,7 @@ import java.io.IOException; import java.net.SocketTimeoutException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.locks.Lock; import static com.alibaba.excel.cache.Ehcache.BATCH_COUNT; import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND; @@ -103,9 +108,28 @@ public class DataImportServiceImpl extends ServiceImpl implements Ta @Override @Transactional(rollbackFor = Exception.class) public void claimTask(String id) { - // 查询任务 - Task task = this.getById(id); - // 进行中 接受时间 - task.setTaskStatus(2).setTaskReceiptTime(LocalDateTime.now()); - // 如果任务没有设置预期完成时间,则按照任务评级进行设置默认 - if (task.getExpectedCompletionDate() == null) { - // 获取任务评级 - String taskRating = task.getTaskRating(); - LocalDate now = LocalDate.now(); - String dictValue = DictUtils.getDictValue(OAM_TASK_RATING, taskRating); - task.setExpectedCompletionDate(now.plusDays(Integer.parseInt(dictValue.split(",")[1]))); - } - // 获取当前用户 - JSONObject loginUser = SecurityUtils.getInstance().getLoginUserInfo(); - if (!Constants.SUPER_ADMIN.equals(loginUser.getString("userName"))) { - // 获取当前员工 - Staff staff = SpringUtils.getBean(StaffService.class) - .getOne(QueryWrapper.create().where(STAFF.USER_ID.eq(loginUser.getString("userId")))); - task.setResponsibleStaffId(staff.getId()); - } - this.updateById(task); - // 添加主要负责人组 - TaskStaffGroup taskStaffGroup = new TaskStaffGroup(); - taskStaffGroup.setStaffId(task.getResponsibleStaffId()).setTaskId(id).setGradePoint(task.getTaskWeight()); - SpringUtils.getBean(TaskStaffGroupService.class).save(taskStaffGroup); - // 通知所有人 - try { - SpringUtils.getBean(WebHookSendHandler.class) - .webHookSendText(WebHookKeyConstant.PRODUCT_BOT, - Collections.singletonList(loginUser.getString("phoneNumber")), - "==========任务领取==========" + "\n" + task.getTaskContent(), - false); - } catch (IOException e) { - throw new ServiceException("发送任务领取通知失败!"); + //分布式锁进行幂等处理 + RedisService redisService = SpringUtils.getBean(RedisService.class); + //分布式锁进行幂等处理 + Lock userIdLock = redisService.distributedLock(OamRedisConstant.TASK_CLAIM_LOCK + id); + if (userIdLock.tryLock()) { + try { + // 查询任务 + Task task = this.getById(id); + if (task.getTaskStatus() == 2){ + throw new ServiceException("任务已领取,请刷新页面"); + } + // 进行中 接受时间 + task.setTaskStatus(2).setTaskReceiptTime(LocalDateTime.now()); + // 如果任务没有设置预期完成时间,则按照任务评级进行设置默认 + if (task.getExpectedCompletionDate() == null) { + // 获取任务评级 + String taskRating = task.getTaskRating(); + LocalDate now = LocalDate.now(); + String dictValue = DictUtils.getDictValue(OAM_TASK_RATING, taskRating); + task.setExpectedCompletionDate(now.plusDays(Integer.parseInt(dictValue.split(",")[1]))); + } + // 获取当前用户 + JSONObject loginUser = SecurityUtils.getInstance().getLoginUserInfo(); + if (!Constants.SUPER_ADMIN.equals(loginUser.getString("userName"))) { + // 获取当前员工 + Staff staff = SpringUtils.getBean(StaffService.class) + .getOne(QueryWrapper.create().where(STAFF.USER_ID.eq(loginUser.getString("userId")))); + task.setResponsibleStaffId(staff.getId()); + } + this.updateById(task); + // 添加主要负责人组 + TaskStaffGroup taskStaffGroup = new TaskStaffGroup(); + taskStaffGroup.setStaffId(task.getResponsibleStaffId()).setTaskId(id).setGradePoint(task.getTaskWeight()); + SpringUtils.getBean(TaskStaffGroupService.class).save(taskStaffGroup); + // 通知所有人 + try { + SpringUtils.getBean(WebHookSendHandler.class) + .webHookSendText(WebHookKeyConstant.PRODUCT_BOT, + Collections.singletonList(loginUser.getString("phoneNumber")), + "==========任务领取==========" + "\n" + task.getTaskContent(), + false); + } catch (IOException e) { + throw new ServiceException("发送任务领取通知失败!"); + } + } catch (Exception e) { + throw new ServiceException(e.getMessage()); + } finally { + //释放锁 + userIdLock.unlock(); + } + } else { + //获取锁失败,直接返回空 + throw new ServiceException("请勿重复领取"); } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/framework/constant/OamRedisConstant.java b/Cpop-Oam/src/main/java/com/cpop/oam/framework/constant/OamRedisConstant.java new file mode 100644 index 0000000..e2859e4 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/framework/constant/OamRedisConstant.java @@ -0,0 +1,19 @@ +package com.cpop.oam.framework.constant; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-19 14:51 + */ +public interface OamRedisConstant { + + /** + * 数据导入幂等锁 + */ + String DATA_IMPORT_LOCK = "oam:dataImportLock:dataImport:"; + + /** + * 任务领取幂等锁 + */ + String TASK_CLAIM_LOCK = "oam:taskClaimLock:task:"; +} diff --git a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java index 454800d..908ef9c 100644 --- a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java +++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java @@ -85,4 +85,9 @@ public class WxPayProperties { * 服务id */ private String serviceId; + + /** + * 服务商模式下的子商户公众账号ID + */ + private String serviceAppId; } diff --git a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java index a5a3cea..821da72 100644 --- a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java +++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java @@ -141,49 +141,4 @@ public class WxPayHandler { return wxMchId; } - /** - * 创建支付分计划 - * @author DB - * @since 2024/1/8 - * @param wxPayService 微信支付 - * @param dto 先学后付计划 - * @return WxPartnerPayScoreSignPlanResult - */ - @Transactional(rollbackFor = Exception.class) - public WxPartnerPayScoreSignPlanResult createPayScorePlan(WxPayService wxPayService, LearnNowPayLaterPlanDto dto) { - Row row = Row.ofKey(RowKey.SNOW_FLAKE_ID); - row.set("sign_account", wxPayService.getConfig().getSubMchId()); - row.set("plan_name", dto.getPlanName()); - row.set("plan_duration", dto.getPlanDuration()); - row.set("deduction_quantity", dto.getDeductionQuantity()); - row.set("total_original_price", dto.getTotalOriginalPrice()); - row.set("total_actual_price", dto.getTotalActualPrice()); - row.set("plan_source", dto.getOrderSource().toString()); - //插入计划 - Db.insert("cp_sys_wx_pay_score", row); - PartnerPayScoreSignPlanService partnerPayScoreSignPlanService = wxPayService.getPartnerPayScoreSignPlanService(); - WxPartnerPayScoreSignPlanRequest planRequest = BeanUtils.mapToClass(dto, WxPartnerPayScoreSignPlanRequest.class); - planRequest.setMerchantPlanNo(row.getString("id")); - WxPartnerPayScoreSignPlanResult plans; - try { - plans = partnerPayScoreSignPlanService.createPlans(planRequest); - } catch (WxPayException e) { - throw new UtilException(e); - } - ArrayList detailRows = new ArrayList<>(); - //更新计划详情 - plans.getPlanDetailList().forEach(item -> { - Row detailRow = Row.ofKey(RowKey.SNOW_FLAKE_ID); - detailRow.set("sys_wx_pay_score_id", row.getString("id")); - detailRow.set("plan_detail_no", item.getPlanDetailNo()); - detailRow.set("original_price", item.getOriginalPrice()); - detailRow.set("actual_price", item.getActualPrice()); - detailRow.set("plan_discount_description", item.getPlanDiscountDescription()); - detailRow.set("plan_detail_name", item.getPlanDetailName()); - detailRows.add(detailRow); - }); - //批量插入 - Db.insertBatch("cp_sys_wx_pay_score_detail", detailRows); - return plans; - } } diff --git a/Cpop-Pay/src/main/resources/application-pay.yml b/Cpop-Pay/src/main/resources/application-pay.yml index 65fd4b0..df43d1e 100644 --- a/Cpop-Pay/src/main/resources/application-pay.yml +++ b/Cpop-Pay/src/main/resources/application-pay.yml @@ -13,3 +13,5 @@ wx: #分账服务商账号 sharing-account: 1618884922 sharing-account-name: 果酱盒子 + #服务商appid + service-app-id: wx1eb0e5fb7dac3c05 \ No newline at end of file From 394fa8d8be7bdd59c9cb247cfcf45f2c30815819 Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Sat, 20 Jan 2024 22:03:35 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=85=88=E5=AD=A6=E5=90=8E=E4=BB=98?= =?UTF-8?q?=E7=AD=BE=E7=BA=A6,=E6=A0=B8=E9=94=80,=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E7=AD=BE=E7=BA=A6=EF=BC=9B=E8=B0=83=E6=95=B4=E4=BA=91=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=B7=BB=E5=8A=A0=E8=AF=BE=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/cloudDb/core/constant/CloudDbUrl.java | 2 +- .../cloudDb/core/dto/CloudClassCardDto.java | 73 ++++- .../handler/CloudClassCardHandler.java | 25 +- .../cloudDb/handler/CloudStoreHandler.java | 9 +- .../com/cpop/core/base/enums/OrderSource.java | 10 +- .../business/bo/LearnNowPayLaterPlanBo.java | 6 + .../bo/LearnNowPayLaterServiceOrderBo.java | 77 +++++ .../LearnNowPayLaterStopUserSignPlansBo.java | 26 ++ .../bo/LearnNowPayLaterUserSignPlansBo.java | 56 ++++ .../callback/CallBackEasyLearnController.java | 51 ++++ .../callback/EasyLearnCallBackController.java | 2 + ...r.java => MiniCardTemplateController.java} | 4 +- .../mini/MiniEasyLearnController.java | 36 ++- .../service/EasyLearnOrderService.java | 42 +++ .../service/impl/CardTemplateServiceImpl.java | 13 +- .../impl/EasyLearnOrderServiceImpl.java | 270 +++++++++++++++++- .../vo/LearnNowPayLaterPlanDetailVo.java | 8 +- .../framework/tasks/LearnNowPayLaterTask.java | 4 +- .../src/main/resources/application-dev.yml | 4 + .../com/cpop/oam/web/CpopDataSyncTests.java | 25 +- .../config/wxPay/WxPayProperties.java | 10 + .../framewok/handler/wxPay/WxPayHandler.java | 31 +- .../pay/framewok/task/WxPayAsyncTask.java | 2 +- .../system/business/entity/WxPayScore.java | 11 +- 24 files changed, 735 insertions(+), 62 deletions(-) create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterStopUserSignPlansBo.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterUserSignPlansBo.java create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/callback/CallBackEasyLearnController.java rename Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/{CardTemplateController.java => MiniCardTemplateController.java} (95%) diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/constant/CloudDbUrl.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/constant/CloudDbUrl.java index ed157d2..63af53c 100644 --- a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/constant/CloudDbUrl.java +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/constant/CloudDbUrl.java @@ -14,7 +14,7 @@ public interface CloudDbUrl { /** * 课卡相关云函数 */ - String COMMON_CARD_URL = BASE_URL + "/merchant_cloud"; + String COMMON_USE_URL = BASE_URL + "/merchant_cloud"; /** * 查询云数据专用 diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudClassCardDto.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudClassCardDto.java index e49c83c..2329351 100644 --- a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudClassCardDto.java +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudClassCardDto.java @@ -3,8 +3,6 @@ package com.cpop.api.cloudDb.core.dto; import com.google.gson.annotations.SerializedName; import lombok.Data; -import java.time.OffsetDateTime; - /** * @author DB * @version 1.0.0 @@ -101,4 +99,75 @@ public class CloudClassCardDto { @SerializedName("isDrainage") private boolean isDrainageCard; + /** + * 实收金额 + */ + @SerializedName("money") + private String payAmount; + + /** + * 云校区id + */ + @SerializedName("storeId") + private String storeCloudId; + + /** + * 客户手机号 + */ + @SerializedName("phone") + private String customerPhone; + + /** + * 模板id + */ + @SerializedName("templateId") + private String orderCloudId; + + /** + * 订单来源 + */ + private String orderSource; + + /** + * 子商户 + */ + private String subMchId; + + /** + * 模板路径 + */ + private String templateUrl; + + /** + * 客户openid + */ + @SerializedName("openid") + private String openId; + + /** + * 商户侧签约计划号 + */ + private String merchantSignPlanNo; + + /** + * 签约计划id + */ + private String signPlanId; + + /** + * 计划id + */ + private String planId; + + /** + * 每期课次 + */ + private Integer classHour; + + /** + * 签约计划详情,json格式 + */ + @SerializedName("signedDetailList") + private String signPlanDetails; + } diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudClassCardHandler.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudClassCardHandler.java index fee239d..f36e035 100644 --- a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudClassCardHandler.java +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudClassCardHandler.java @@ -4,9 +4,9 @@ import com.alibaba.fastjson.JSONObject; import com.cpop.api.cloudDb.core.constant.CloudDbUrl; import com.cpop.api.cloudDb.core.dto.CloudClassCardDto; import com.cpop.api.cloudDb.core.dto.CloudClassCardRecordDto; -import com.cpop.api.cloudDb.core.dto.CloudClassStudentDto; import com.cpop.common.utils.StringUtils; import com.cpop.core.base.entity.ExtendPage; +import com.cpop.core.base.exception.ServiceException; import com.cpop.core.base.exception.UtilException; import com.mybatisflex.core.paginate.Page; import org.springframework.beans.factory.annotation.Autowired; @@ -139,4 +139,27 @@ public class CloudClassCardHandler { return page; } } + + /** + * 添加课卡 + * @author DB + * @since 2024/1/20 + * @param dto 课卡中间表 + * @return String + */ + public String insertCloudClassCard(CloudClassCardDto dto){ + JSONObject jsonBody = JSONObject.parseObject(JSONObject.toJSONString(dto)); + jsonBody.put("_type", "addPeriod"); + JSONObject result = restTemplate.postForObject(CloudDbUrl.COMMON_USE_URL, jsonBody, JSONObject.class); + if (result != null) { + if (result.getBoolean("success")) { + return result.getString("data"); + } else { + throw new UtilException(result.getString("error")); + } + } else { + throw new ServiceException("办卡失败!"); + } + + } } diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudStoreHandler.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudStoreHandler.java index 25420ad..3f415ab 100644 --- a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudStoreHandler.java +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudStoreHandler.java @@ -2,20 +2,13 @@ package com.cpop.api.cloudDb.handler; import com.alibaba.fastjson.JSONObject; import com.cpop.api.cloudDb.core.constant.CloudDbUrl; -import com.cpop.api.cloudDb.core.dto.CloudOrderDto; import com.cpop.api.cloudDb.core.dto.CloudStoreDto; import com.cpop.common.utils.StringUtils; -import com.cpop.core.base.entity.ExtendPage; import com.cpop.core.base.exception.UtilException; -import com.mybatisflex.core.paginate.Page; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * 云校区工具类 * @author DB @@ -54,7 +47,7 @@ public class CloudStoreHandler { if (StringUtils.isNotBlank(dto.getStoreAddr())) { jsonBody.put("address", dto.getStoreAddr()); } - JSONObject jsonObject = restTemplate.postForObject(CloudDbUrl.COMMON_CARD_URL, jsonBody, JSONObject.class); + JSONObject jsonObject = restTemplate.postForObject(CloudDbUrl.COMMON_USE_URL, jsonBody, JSONObject.class); if (jsonObject != null) { if (!jsonObject.getBoolean("success")) { throw new UtilException(jsonObject.getString("error")); diff --git a/Cpop-Core/src/main/java/com/cpop/core/base/enums/OrderSource.java b/Cpop-Core/src/main/java/com/cpop/core/base/enums/OrderSource.java index 8b93cf7..fb981da 100644 --- a/Cpop-Core/src/main/java/com/cpop/core/base/enums/OrderSource.java +++ b/Cpop-Core/src/main/java/com/cpop/core/base/enums/OrderSource.java @@ -14,9 +14,15 @@ public enum OrderSource { MALL("Mall",0.002), /** - * 微信支付 + * 一次性支付 */ - EASY_LEARN("EasyLearn",0.002); + EASY_LEARN("EasyLearn",0.002), + + /** + * 先学后付 + */ + LEARN_NOW_PAY_LATER("LearnNowPayLater",0.06) + ; OrderSource(String name, Double rate) { this.rate = rate; diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterPlanBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterPlanBo.java index e2e8f9a..4a3c4c6 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterPlanBo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterPlanBo.java @@ -61,4 +61,10 @@ public class LearnNowPayLaterPlanBo { @ApiModelProperty("支付分计划明细列表") private List planDetailList; + /** + * 课次 + */ + @ApiModelProperty("支付分计划原总金额") + private String classHour; + } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java new file mode 100644 index 0000000..f811093 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java @@ -0,0 +1,77 @@ +package com.cpop.jambox.business.bo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-20 12:33 + */ +@Data +@ApiModel(value = "先学后付用户核销") +public class LearnNowPayLaterServiceOrderBo { + + /** + * 支付分订单在商户侧的订单号,必须和创建签约计划时传入的该笔订单对应的商户侧计划明细使用订单号(merchant\_plan\_detail\_no)一致 + */ + @NotBlank(message = "待创建服务订单对应的用户的签约计划不能为空") + @ApiModelProperty(value = "待创建服务订单对应的用户的签约计划",required = true) + private String signPlanId; + + /** + * 待创建服务订单对应的用户的签约计划详情序号 + */ + @NotNull(message = "planDetailNo不能为空") + @ApiModelProperty(value = "待创建服务订单对应的用户的签约计划详情序号",required = true) + private Integer planDetailNo; + + /** + * 服务商公众号下的用户标识 + */ + @NotBlank(message = "openid不能为空") + @ApiModelProperty(value = "服务商公众号下的用户标识",required = true) + private String openid; + + /** + * 支付分订单在商户侧的订单号,必须和创建签约计划时传入的该笔订单对应的商户侧计划明细使用订单号(merchant\_plan\_detail\_no)一致 + */ + @NotBlank(message = "outTradeNo不能为空") + @ApiModelProperty(value = "支付分订单在商户侧的订单号,必须和创建签约计划时传入的该笔订单对应的商户侧计划明细使用订单号(merchant_plan_detail_no)一致",required = true) + private String outTradeNo; + + /** + * 卡号 + */ + @NotBlank(message = "cardNo不能为空") + @ApiModelProperty(value = "卡号",required = true) + private String cardNo; + + + + /** + * 课程信息 + */ + @NotBlank(message = "课程信息不能为空") + @ApiModelProperty(value = "课程信息",required = true) + private String serviceIntroduction; + + /** + * 核销金额 + */ + @NotNull(message = "核销金额不能为空") + @ApiModelProperty(value = "核销金额",required = true) + private Integer price; + + /** + * 是否是旧卡 + */ + @ApiModelProperty(value = "是否是旧卡") + private Boolean isOldCard; + + +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterStopUserSignPlansBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterStopUserSignPlansBo.java new file mode 100644 index 0000000..6e10eb3 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterStopUserSignPlansBo.java @@ -0,0 +1,26 @@ +package com.cpop.jambox.business.bo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-20 15:01 + */ +@Data +@ApiModel(value = "停止用户签约计划") +public class LearnNowPayLaterStopUserSignPlansBo { + + /** + * 签约计划id + */ + @ApiModelProperty(value = "签约计划id") + private String signPlanId; + + /** + * 取消理由 + */ + private String stopReason; +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterUserSignPlansBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterUserSignPlansBo.java new file mode 100644 index 0000000..3ee1da8 --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterUserSignPlansBo.java @@ -0,0 +1,56 @@ +package com.cpop.jambox.business.bo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-19 22:40 + */ +@Data +@ApiModel(value = "先学后付用户签约计划") +public class LearnNowPayLaterUserSignPlansBo { + + /** + * 支付分id + */ + @NotBlank(message = "支付分id不能为空") + @ApiModelProperty(value = "支付分id",required = true) + private String id; + + /** + * 云校区id + */ + @NotBlank(message = "云校区id不能为空") + @ApiModelProperty(value = "云校区id",required = true) + private String storeCloudId; + + /** + * 子商户下用户openid + */ + @NotBlank(message = "子商户下用户openid不能为空") + @ApiModelProperty(value = "子商户下用户openid",required = true) + private String subOpenId; + + /** + * 支付分计划名称 + */ + @ApiModelProperty("支付分计划名称") + private String planName; + + /** + * 客户名 + */ + @ApiModelProperty("客户名") + private String customerName; + + /** + * 客户手机号 + */ + @ApiModelProperty("客户手机号") + private String customerPhone; +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/callback/CallBackEasyLearnController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/callback/CallBackEasyLearnController.java new file mode 100644 index 0000000..019efde --- /dev/null +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/callback/CallBackEasyLearnController.java @@ -0,0 +1,51 @@ +package com.cpop.jambox.business.controller.callback; + +import com.cpop.jambox.business.service.EasyLearnOrderService; +import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-20 0:22 + */ +@RestController +@Api(tags = "果酱-放心学回调接口") +@RequestMapping("/callback/easyLearn") +public class CallBackEasyLearnController { + + @Autowired + private EasyLearnOrderService easyLearnOrderService; + + /** + * 用户签约成功回调 + * @author DB + * @since 2024/1/20 + * @param notifyData 返回参数 + */ + @ApiOperation("放心学先学后付支付分回调通知") + @PostMapping("/learnNowPayLaterUserSignPlanNotify") + public String learnNowPayLaterUserSignPlanNotifyUrl(@RequestBody String notifyData) { + easyLearnOrderService.learnNowPayLaterUserSignPlanNotify(notifyData); + return WxPayNotifyResponse.success("成功"); + } + + /** + * 支付分用户核销成功回调 + * @author DB + * @since 2024/1/20 + * @param notifyData 返回参数 + */ + @ApiOperation("支付分用户核销成功回调") + @PostMapping("/userServiceOrderSuccess") + public String userServiceOrderSuccess(@RequestBody String notifyData) { + easyLearnOrderService.userServiceOrderSuccess(notifyData); + return WxPayNotifyResponse.success("成功"); + } +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/callback/EasyLearnCallBackController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/callback/EasyLearnCallBackController.java index 51fd1e3..15ec023 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/callback/EasyLearnCallBackController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/callback/EasyLearnCallBackController.java @@ -46,4 +46,6 @@ public class EasyLearnCallBackController { return WxPayNotifyResponse.success("成功"); } + + } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/CardTemplateController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniCardTemplateController.java similarity index 95% rename from Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/CardTemplateController.java rename to Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniCardTemplateController.java index 0d594f9..784add9 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/CardTemplateController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniCardTemplateController.java @@ -1,6 +1,5 @@ package com.cpop.jambox.business.controller.mini; -import com.cpop.core.annontation.SimpleSignatureCheck; import com.cpop.core.base.R; import com.cpop.core.utils.SpringUtils; import com.cpop.jambox.business.bo.CardTemplateUnionBo; @@ -9,7 +8,6 @@ import com.cpop.jambox.business.service.CardTemplateExtendService; import com.cpop.jambox.business.service.CardTemplateService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.apache.ibatis.annotations.Delete; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -26,7 +24,7 @@ import static com.cpop.jambox.business.entity.table.CardTemplateTableDef.CARD_TE @RestController @Api(tags = "果酱-课卡模板接口") @RequestMapping("/mini/cardTemplate") -public class CardTemplateController { +public class MiniCardTemplateController { @Autowired private CardTemplateService cardTemplateService; diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java index 524af37..14f4a93 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java @@ -1,14 +1,19 @@ package com.cpop.jambox.business.controller.mini; import com.cpop.core.base.R; +import com.cpop.jambox.business.bo.LearnNowPayLaterServiceOrderBo; +import com.cpop.jambox.business.bo.LearnNowPayLaterStopUserSignPlansBo; +import com.cpop.jambox.business.bo.LearnNowPayLaterUserSignPlansBo; import com.cpop.jambox.business.service.CardTemplateService; import com.cpop.jambox.business.service.EasyLearnOrderService; -import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; import com.cpop.jambox.business.vo.LearnNowPayLaterPlanVo; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanResult; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreUserSignPlanResult; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** @@ -46,25 +51,42 @@ public class MiniEasyLearnController { /** * 获取支付分计划 * - * @param oldTemplateId 旧模板id - * @param isMonth 是否月付 + * @param bo 请求参数 * @return R * @author DB * @since 2024/1/18 */ @ApiOperation("创建用户签约计划") @PostMapping("/createUserSignPlans") - public R createUserSignPlans(@ApiParam(value = "旧模板id", required = true) @RequestParam("oldTemplateId") String oldTemplateId, - @ApiParam(value = "是否月付(0否1是)", required = true) @RequestParam("isMonth") Boolean isMonth) { - return R.ok(); + public R createUserSignPlans(@RequestBody @Validated LearnNowPayLaterUserSignPlansBo bo) { + WxPartnerPayScoreUserSignPlanResult result = easyLearnOrderService.createUserSignPlans(bo); + return R.ok(result); } /** * 创建用户服务订单(核销) + * @author DB + * @since 2024/1/20 + * @param bo 请求参数 */ @ApiOperation("创建用户服务订单(核销)") @PostMapping("/createServiceOrder") - public R createServiceOrder() { + public R createServiceOrder(@RequestBody @Validated LearnNowPayLaterServiceOrderBo bo) { + WxPartnerPayScoreSignPlanResult result = easyLearnOrderService.createServiceOrder(bo); + return R.ok(result); + } + + /** + * 取消用户签约计划 + * @author DB + * @since 2024/1/20 + * @param bo 请求参数 + * @return R + */ + @ApiOperation("取消用户签约计划") + @PostMapping("/stopUserSignPlans/{signPlanId}") + public R stopUserSignPlans(@RequestBody @Validated LearnNowPayLaterStopUserSignPlansBo bo){ + easyLearnOrderService.stopUserSignPlans(bo); return R.ok(); } } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/EasyLearnOrderService.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/EasyLearnOrderService.java index 10d2035..16f206c 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/EasyLearnOrderService.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/EasyLearnOrderService.java @@ -4,6 +4,8 @@ import com.cpop.jambox.business.bo.*; import com.cpop.jambox.business.dto.EasyLearnPageDto; import com.cpop.jambox.business.entity.EasyLearnOrder; import com.cpop.jambox.business.vo.EasyLearnPageVo; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanResult; +import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreUserSignPlanResult; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.service.IService; @@ -75,4 +77,44 @@ public interface EasyLearnOrderService extends IService { */ Object unifiedPay(EasyLearnUnifiedPayBo bo); + /** + * 创建用户签约计划 + * @author DB + * @since 2024/1/19 + * @param bo 请求参数 + */ + WxPartnerPayScoreUserSignPlanResult createUserSignPlans(LearnNowPayLaterUserSignPlansBo bo); + + /** + * 用户签约成功回调 + * @author DB + * @since 2024/1/20 + * @param notifyData 返回参数 + */ + void learnNowPayLaterUserSignPlanNotify(String notifyData); + + /** + * 创建用户服务订单(核销) + * @author DB + * @since 2024/1/20 + * @param bo 请求参数 + * @return WxPartnerPayScoreSignPlanResult + */ + WxPartnerPayScoreSignPlanResult createServiceOrder(LearnNowPayLaterServiceOrderBo bo); + + /** + * 支付分用户核销成功回调 + * @author DB + * @since 2024/1/20 + * @param notifyData 返回数据 + */ + void userServiceOrderSuccess(String notifyData); + + /** + * 取消用户签约计划 + * @author DB + * @since 2024/1/20 + * @param bo 请求参数 + */ + void stopUserSignPlans(LearnNowPayLaterStopUserSignPlansBo bo); } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java index 23b3417..7ed2da7 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java @@ -19,6 +19,7 @@ import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; import com.cpop.jambox.business.vo.LearnNowPayLaterPlanVo; import com.cpop.jambox.framework.tasks.LearnNowPayLaterTask; import com.cpop.system.business.entity.Store; +import com.cpop.system.business.entity.WxPayScore; import com.cpop.system.business.entity.WxPayScoreDetail; import com.cpop.system.business.service.StoreService; import com.cpop.system.business.service.WxPayScoreDetailService; @@ -288,12 +289,12 @@ public class CardTemplateServiceImpl extends ServiceImpl detailVos = SpringUtils.getBean(WxPayScoreDetailService.class).listAs(QueryWrapper.create() - .where(WX_PAY_SCORE_DETAIL.SYS_WX_PAY_SCORE_ID.eq(vo.getId())), - LearnNowPayLaterPlanDetailVo.class); + WxPayScore wxPayScore = SpringUtils.getBean(WxPayScoreService.class).getOne(QueryWrapper.create() + .where(WX_PAY_SCORE.ID.eq(cardTemplateExtend.getExtendId()))); + LearnNowPayLaterPlanVo vo = BeanUtils.mapToClass(wxPayScore, LearnNowPayLaterPlanVo.class); + List wxPayScoreDetails = SpringUtils.getBean(WxPayScoreDetailService.class).list(QueryWrapper.create() + .where(WX_PAY_SCORE_DETAIL.SYS_WX_PAY_SCORE_ID.eq(vo.getId()))); + List detailVos = BeanUtils.mapToList(wxPayScoreDetails, LearnNowPayLaterPlanDetailVo.class); vo.setPlanDetailList(detailVos); return vo; } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java index 9d37bc7..b8252e9 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java @@ -1,6 +1,9 @@ package com.cpop.jambox.business.service.impl; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.cpop.api.cloudDb.core.dto.CloudClassCardDto; +import com.cpop.api.cloudDb.handler.CloudClassCardHandler; import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.bean.BeanUtils; import com.cpop.common.utils.http.HttpUtils; @@ -15,11 +18,12 @@ import com.cpop.core.utils.sql.SqlUtils; import com.cpop.jambox.business.bo.*; import com.cpop.jambox.business.dto.EasyLearnPageDto; import com.cpop.jambox.business.entity.BrandExtend; -import com.cpop.jambox.business.entity.CardTemplate; import com.cpop.jambox.business.entity.EasyLearnOrder; +import com.cpop.jambox.business.entity.EasyLearnOrderDetail; import com.cpop.jambox.business.entity.StoreExtend; import com.cpop.jambox.business.mapper.EasyLearnOrderMapper; import com.cpop.jambox.business.service.BrandExtendService; +import com.cpop.jambox.business.service.EasyLearnOrderDetailService; import com.cpop.jambox.business.service.EasyLearnOrderService; import com.cpop.jambox.business.service.StoreExtendService; import com.cpop.jambox.business.vo.EasyLearnPageVo; @@ -30,11 +34,18 @@ import com.cpop.pay.framewok.config.wxPay.WxPayConfiguration; import com.cpop.pay.framewok.handler.wxPay.WxPayHandler; import com.cpop.pay.framewok.task.WxPayAsyncTask; import com.cpop.system.business.entity.Store; +import com.cpop.system.business.entity.WxPayScore; +import com.cpop.system.business.entity.WxPayScoreDetail; import com.cpop.system.business.service.StoreService; +import com.cpop.system.business.service.WxPayScoreDetailService; +import com.cpop.system.business.service.WxPayScoreService; +import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; +import com.github.binarywang.wxpay.bean.payscore.*; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.PartnerPayScoreSignPlanService; import com.github.binarywang.wxpay.service.WxPayService; import com.mybatisflex.core.FlexGlobalConfig; import com.mybatisflex.core.datasource.DataSourceKey; @@ -53,13 +64,19 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.RestTemplate; import java.io.IOException; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.concurrent.locks.Lock; import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND; +import static com.cpop.jambox.business.entity.table.EasyLearnOrderDetailTableDef.EASY_LEARN_ORDER_DETAIL; import static com.cpop.jambox.business.entity.table.EasyLearnOrderTableDef.EASY_LEARN_ORDER; import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND; +import static com.cpop.system.business.entity.table.StoreTableDef.STORE; +import static com.cpop.system.business.entity.table.WxPayScoreDetailTableDef.WX_PAY_SCORE_DETAIL; /** * 果酱-放心学订单表 服务层实现。 @@ -77,6 +94,9 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl wxPayScoreDetails = SpringUtils.getBean(WxPayScoreDetailService.class).queryChain() + .where(WX_PAY_SCORE_DETAIL.SYS_WX_PAY_SCORE_ID.eq(bo.getId())) + .list(); + Row brandAndStore = Db.selectOneByQuery(QueryWrapper.create() + .select(STORE.ID,STORE.BRAND_ID) + .leftJoin(STORE_EXTEND).on(STORE_EXTEND.STORE_ID.eq(STORE.ID)) + .where(STORE_EXTEND.STORE_CLOUD_ID.eq(bo.getStoreCloudId()))); + //创建用户签约计划 + String orderId = createEasyLearnUserSignPlans(bo, brandAndStore, wxPayScore); + String subMchId = wxPayHandler.getSubMchId(brandAndStore.getString("brandId"), brandAndStore.getString("id")); + WxPayService wxPayService = wxPayHandler.getWxPayService(null, subMchId); + PartnerPayScoreSignPlanService partnerPayScoreSignPlanService = wxPayService.getPartnerPayScoreSignPlanService(); + List payScorePlanDetailRequests = BeanUtils.mapToList(wxPayScoreDetails, PayScorePlanDetailRequest.class); + WxPartnerPayScoreSignPlanRequest signPlanRequest = new WxPartnerPayScoreSignPlanRequest(); + signPlanRequest.setPlanId(wxPayScore.getOutPlanId()).setSubAppid(subMchId) + .setSubOpenid(bo.getSubOpenId()) + .setMerchantSignPlanNo(orderId) + .setPlanDetailList(payScorePlanDetailRequests) + .setNotifyUrl(wxPayConfiguration.getProperties().getLearnNowPayLaterUserSignPlanNotifyUrl()); + try { + return partnerPayScoreSignPlanService.createUserSignPlans(signPlanRequest); + } catch (WxPayException e) { + throw new ServiceException(e.getMessage()); + } + } + /** + * 创建用户支付计划 + * @author DB + * @since 2024/1/19 + * @param wxPayScore 支付分 + * @return String + */ + private String createEasyLearnUserSignPlans(LearnNowPayLaterUserSignPlansBo bo, Row brandAndStore, WxPayScore wxPayScore) { + EasyLearnOrder easyLearnOrder = new EasyLearnOrder(); + easyLearnOrder.setBrandId(brandAndStore.getString("brandId")) + .setStoreId(brandAndStore.getString("id")) + .setOrderContent(bo.getPlanName()) + .setOrderStatus(0) + .setCustomerName(bo.getCustomerName()) + .setCustomerPhone(bo.getCustomerPhone()) + .setTotalAmount(new BigDecimal(wxPayScore.getTotalOriginalPrice()).divide(BigDecimal.valueOf(100))) + .setTotalPayAmount(BigDecimal.ZERO) + .setOrderType(0) + .setRate(OrderSource.LEARN_NOW_PAY_LATER.getRate()); + this.save(easyLearnOrder); + return easyLearnOrder.getId(); + } + + /** + * 用户签约成功回调 + * @author DB + * @since 2024/1/20 + * @param notifyData 响应数据 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void learnNowPayLaterUserSignPlanNotify(String notifyData) { + try { + PayScoreNotifyData payScoreNotifyData = JSONObject.parseObject(notifyData, PayScoreNotifyData.class); + PartnerPayScoreSignPlanService partnerPayScoreSignPlanService = wxPayHandler.getWxPayService().getPartnerPayScoreSignPlanService(); + SignatureHeader signatureHeader = wxPayHandler.getSignatureHeader(); + PartnerUserSignPlanEntity result = partnerPayScoreSignPlanService.parseSignPlanNotifyResult(notifyData, signatureHeader); + String orderId = result.getMerchantSignPlanNo(); + EasyLearnOrder easyLearnOrder = this.getById(orderId); + //支付成功 + if (StringUtils.equals("PAYSCORE.USER_SIGN_PLAN", payScoreNotifyData.getEventType())) { + //订单已支付 + if (easyLearnOrder.getOrderStatus() == 1){ + return; + } + easyLearnOrder.setOrderStatus(1).setOutOrderNo(result.getSignPlanId()); + //添加支付分详情 + List easyLearnOrderDetails = new ArrayList<>(); + result.getSignedDetailList().forEach(item->{ + EasyLearnOrderDetail easyLearnOrderDetail = new EasyLearnOrderDetail(); + easyLearnOrderDetail.setOrderId(easyLearnOrder.getId()) + .setPeriodNo(item.getPlanDetailNo()) + .setAmount(new BigDecimal(item.getOriginalPrice()).divide(BigDecimal.valueOf(100))) + .setDetailDesc(item.getPlanDiscountDescription()) + .setActualPrice(new BigDecimal(item.getActualPrice()).divide(BigDecimal.valueOf(100))) + .setDetailStatus(0) + .setOutOrderNo(item.getOrderId()) + .setDetailName(item.getPlanDetailName()); + easyLearnOrderDetails.add(easyLearnOrderDetail); + }); + SpringUtils.getBean(EasyLearnOrderDetailService.class).saveBatch(easyLearnOrderDetails); + //云办卡 + CloudClassCardDto dto = new CloudClassCardDto(); + //TODO: 模板路径的用途 + //dto.setTemplateUrl(); + //jsonObject.put("templateUrl", templateUrl); + // jsonObject.put("templateUrl", "https://test.cpopsz.com/test/ass/"); + // jsonObject.put("templateUrl","https://api.jamboxsys.com/jambox/ass/"); + // 办卡 + dto.setOpenId(result.getSubOpenid()); + dto.setMerchantSignPlanNo(result.getMerchantSignPlanNo()); + dto.setSignPlanId(result.getSignPlanId()); + //TODO: 模板id + //dto.setOrderCloudId(easyLearnOrder); + StoreExtend storeExtend = SpringUtils.getBean(StoreExtendService.class).queryChain() + .where(STORE_EXTEND.STORE_ID.eq(easyLearnOrder.getStoreId())) + .one(); + dto.setStoreCloudId(storeExtend.getStoreCloudId()); + dto.setCustomerPhone(easyLearnOrder.getCustomerPhone()); + dto.setCustomerName(easyLearnOrder.getCustomerName()); + dto.setPlanId(result.getPlanId()); + dto.setSignPlanDetails(JSONArray.toJSONString(result.getSignedDetailList())); + //TODO: 课次 + String cloudCardId = SpringUtils.getBean(CloudClassCardHandler.class).insertCloudClassCard(dto); + easyLearnOrder.setProductId(cloudCardId); + this.updateById(easyLearnOrder); + } else if (StringUtils.equals("PAYSCORE.USER_CANCEL_SIGN_PLAN", payScoreNotifyData.getEventType())){ + //取消合约 + easyLearnOrder.setOrderStatus(2); + this.updateById(easyLearnOrder); + //批量修改订单详情状态 + SpringUtils.getBean(EasyLearnOrderDetailService.class).updateChain() + .set(EASY_LEARN_ORDER_DETAIL.DETAIL_STATUS, 3) + .where(EASY_LEARN_ORDER_DETAIL.ORDER_ID.eq(easyLearnOrder.getId())) + .and(EASY_LEARN_ORDER_DETAIL.DETAIL_STATUS.eq(0)) + .update(); + //TODO: 通知波哥取消课卡 + } + } catch (WxPayException e) { + throw new ServiceException(e.getMessage()); + } + } + + /** + * 创建用户服务订单(核销) + * @author DB + * @since 2024/1/20 + * @param bo 请求参数 + * @return WxPartnerPayScoreSignPlanResult + */ + @Override + @Transactional(rollbackFor = Exception.class) + public WxPartnerPayScoreSignPlanResult createServiceOrder(LearnNowPayLaterServiceOrderBo bo) { + EasyLearnOrder easyLearnOrder = this.queryChain().where(EASY_LEARN_ORDER.OUT_ORDER_NO.eq(bo.getSignPlanId())).one(); + EasyLearnOrderDetailService easyLearnOrderDetailService = SpringUtils.getBean(EasyLearnOrderDetailService.class); + EasyLearnOrderDetail easyLearnOrderDetail = easyLearnOrderDetailService.queryChain() + .where(EASY_LEARN_ORDER_DETAIL.ORDER_ID.eq(easyLearnOrder.getId())) + .and(EASY_LEARN_ORDER_DETAIL.PERIOD_NO.eq(bo.getPlanDetailNo())) + .one(); + String subMchId = wxPayHandler.getSubMchId(easyLearnOrder.getBrandId(), easyLearnOrder.getStoreId()); + WxPayService wxPayService = wxPayHandler.getWxPayService(null, subMchId); + PartnerPayScoreSignPlanService partnerPayScoreSignPlanService = wxPayService.getPartnerPayScoreSignPlanService(); + WxPartnerPayScoreSignPlanRequest signPlanRequest = new WxPartnerPayScoreSignPlanRequest(); + signPlanRequest.setSignPlanId(easyLearnOrder.getOutOrderNo()) + .setPlanDetailNo(easyLearnOrderDetail.getPeriodNo()) + .setSubMchid(subMchId) + .setSubOpenid(bo.getOpenid()) + .setNotifyUrl(wxPayConfiguration.getProperties().getLearnNowPayLaterServiceOrderNotifyUrl()) + .setServiceIntroduction(easyLearnOrderDetail.getDetailDesc()); + TimeRange timeRange = new TimeRange(); + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter yyyyMMddHHmmss = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); + String startTime = now.plusSeconds(10).format(yyyyMMddHHmmss); + timeRange.setStartTime(startTime); + String endTime = now.plusSeconds(60).format(yyyyMMddHHmmss); + timeRange.setEndTime(endTime); + signPlanRequest.setTimeRange(timeRange) + .setOutOrderNo(easyLearnOrderDetail.getId()); + easyLearnOrderDetail.setDetailStatus(1); + easyLearnOrderDetailService.updateById(easyLearnOrderDetail); + try { + return partnerPayScoreSignPlanService.signPlanServiceOrder(signPlanRequest); + } catch (WxPayException e) { + throw new ServiceException(e.getMessage()); + } + } + + /** + * 支付分用户核销成功回调 + * @author DB + * @since 2024/1/20 + * @param notifyData 返回数据 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void userServiceOrderSuccess(String notifyData) { + try { + WxPayOrderNotifyResult notifyResult = wxPayHandler.getWxPayService().parseOrderNotifyResult(notifyData); + EasyLearnOrderDetailService easyLearnOrderDetailService = SpringUtils.getBean(EasyLearnOrderDetailService.class); + EasyLearnOrderDetail easyLearnOrderDetail = easyLearnOrderDetailService.queryChain() + .where(EASY_LEARN_ORDER_DETAIL.ORDER_ID.eq(notifyResult.getOutTradeNo())) + .and(EASY_LEARN_ORDER_DETAIL.OUT_ORDER_NO.eq(notifyResult.getTransactionId())) + .one(); + EasyLearnOrder easyLearnOrder = this.getById(easyLearnOrderDetail.getOrderId()); + //需要分账 + String subMchId = wxPayHandler.getSubMchId(easyLearnOrder.getBrandId(), easyLearnOrder.getStoreId()); + if (notifyResult.getTotalFee() >= Math.ceil(1 / OrderSource.EASY_LEARN.getRate())) { + //设置子商户 + WxPayService wxPayService = wxPayHandler.getWxPayService(null, subMchId); + wxPayAsyncTask.asyncWxPayProfitSharing(notifyResult.getOutTradeNo(), notifyResult, wxPayService, OrderSource.LEARN_NOW_PAY_LATER); + } + BigDecimal payAmount = new BigDecimal(notifyResult.getTotalFee()).divide(BigDecimal.valueOf(100)); + easyLearnOrderDetail.setDetailStatus(2) + .setActualPrice(payAmount); + easyLearnOrderDetailService.updateById(easyLearnOrderDetail); + //修改订单实际支付金额 + easyLearnOrder.setTotalPayAmount(easyLearnOrder.getTotalPayAmount() == null ? payAmount : easyLearnOrder.getTotalPayAmount().add(payAmount)); + this.updateById(easyLearnOrder); + } catch (WxPayException e) { + throw new ServiceException(e.getMessage()); + } + } + + /** + * 取消用户签约计划 + * @author DB + * @since 2024/1/20 + * @param bo 请求参数 + */ + @Override + public void stopUserSignPlans(LearnNowPayLaterStopUserSignPlansBo bo) { + EasyLearnOrder easyLearnOrder = this.queryChain().where(EASY_LEARN_ORDER.OUT_ORDER_NO.eq(bo.getSignPlanId())).one(); + String subMchId = wxPayHandler.getSubMchId(easyLearnOrder.getBrandId(), easyLearnOrder.getStoreId()); + WxPayService wxPayService = wxPayHandler.getWxPayService(null, subMchId); + try { + wxPayService.getPartnerPayScoreSignPlanService().stopUserSignPlans(easyLearnOrder.getId(), subMchId, bo.getStopReason()); + //取消合约 + easyLearnOrder.setOrderStatus(2); + this.updateById(easyLearnOrder); + //批量修改订单详情状态 + SpringUtils.getBean(EasyLearnOrderDetailService.class).updateChain() + .set(EASY_LEARN_ORDER_DETAIL.DETAIL_STATUS, 3) + .where(EASY_LEARN_ORDER_DETAIL.ORDER_ID.eq(easyLearnOrder.getId())) + .and(EASY_LEARN_ORDER_DETAIL.DETAIL_STATUS.eq(0)) + .update(); + //TODO: 通知波哥取消课卡 + } catch (WxPayException e) { + throw new ServiceException(e.getMessage()); + } + } } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java index 1c9d2b0..7d0849e 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/LearnNowPayLaterPlanDetailVo.java @@ -37,7 +37,7 @@ public class LearnNowPayLaterPlanDetailVo { @ApiModelProperty("计划明细实际支付金额(单位分)") private BigDecimal actualPrice; - public void setActualPrice(Integer actualPrice) { + public void setActualPrice(Long actualPrice) { this.actualPrice = new BigDecimal(actualPrice).divide(BigDecimal.valueOf(100)); } @@ -46,4 +46,10 @@ public class LearnNowPayLaterPlanDetailVo { */ @ApiModelProperty("计划明细名称") private String planDetailName; + + /** + * 签约计划编号 + */ + @ApiModelProperty("签约计划编号") + private Integer planDetailNo; } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java index 2474e68..aa08360 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/tasks/LearnNowPayLaterTask.java @@ -1,6 +1,5 @@ package com.cpop.jambox.framework.tasks; -import com.alibaba.fastjson.JSONArray; import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.bean.BeanUtils; import com.cpop.core.base.exception.ServiceException; @@ -33,7 +32,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; -import static com.cpop.jambox.business.entity.table.CardTemplateExtendTableDef.CARD_TEMPLATE_EXTEND; import static com.cpop.system.business.entity.table.WxPayScoreTableDef.WX_PAY_SCORE; /** @@ -64,7 +62,7 @@ public class LearnNowPayLaterTask { String subMchId = wxPayHandler.getSubMchId(cardTemplate.getBrandId(), cardTemplate.getStoreId()); //录入计划与详情 WxPayScore wxPayScore = BeanUtils.mapToClass(bo, WxPayScore.class); - wxPayScore.setSignAccount(subMchId); + wxPayScore.setSignAccount(subMchId).setClassHour(bo.getClassHour()); WxPayScoreService wxPayScoreService = SpringUtils.getBean(WxPayScoreService.class); wxPayScoreService.save(wxPayScore); //创建计划 diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml index 6eda66c..2177965 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml @@ -108,3 +108,7 @@ wx: privateKeyPath: E:/Cpop/Cpop-Union/Cpop-Core/src/main/resources/static/keyPair/wxPay_key.pem # 私钥文件 privateCertPath: E:/Cpop/Cpop-Union/Cpop-Core/src/main/resources/static/keyPair/wxPay_cert.pem + # 先学后付用户签约通知地址 + learn-now-pay-later-user-sign-plan-notify-url: + # 先学后付用户核销通知地址 + learn-now-pay-later-service-order-notify-url: diff --git a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java index 11a0010..ad659c3 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java +++ b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java @@ -1,12 +1,15 @@ package com.cpop.oam.web; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.cpop.common.utils.StringUtils; import com.cpop.core.utils.SpringUtils; -import com.cpop.jambox.business.entity.*; -import com.cpop.jambox.business.service.*; -import com.cpop.oam.business.service.StaffService; +import com.cpop.jambox.business.entity.BrandExtend; +import com.cpop.jambox.business.entity.CardTemplate; +import com.cpop.jambox.business.entity.CardTemplateExtend; +import com.cpop.jambox.business.entity.StoreExtend; +import com.cpop.jambox.business.service.BrandExtendService; +import com.cpop.jambox.business.service.CardTemplateExtendService; +import com.cpop.jambox.business.service.CardTemplateService; +import com.cpop.jambox.business.service.StoreExtendService; import com.cpop.system.business.entity.Store; import com.cpop.system.business.entity.StoreSign; import com.cpop.system.business.entity.WxPayScore; @@ -15,18 +18,15 @@ import com.cpop.system.business.service.StoreService; import com.cpop.system.business.service.StoreSignService; import com.cpop.system.business.service.WxPayScoreService; import com.mybatisflex.core.datasource.DataSourceKey; -import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.row.Db; import com.mybatisflex.core.row.DbChain; import com.mybatisflex.core.row.Row; import com.mybatisflex.core.row.RowUtil; import com.mybatisflex.core.update.UpdateChain; -import org.apache.poi.ss.formula.functions.T; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; -import java.security.PublicKey; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; @@ -46,7 +46,7 @@ import static com.mybatisflex.core.query.QueryMethods.max; * @since 2024-01-16 17:17 */ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles(profiles = {"prod", "core"}) +@ActiveProfiles(profiles = {"prod", "core", "pay"}) public class CpopDataSyncTests { /** @@ -139,7 +139,6 @@ public class CpopDataSyncTests { .setPayType(4); cardTemplateExtends.add(cardTemplateExtend); } - }); List entityList = RowUtil.toEntityList(rowList, CardTemplate.class); SpringUtils.getBean(CardTemplateService.class).saveBatch(entityList); @@ -172,7 +171,8 @@ public class CpopDataSyncTests { if (StringUtils.isNotBlank(row.getString("oncePlanId"))){ WxPayScore oncePlan = wxPayScoreMap.get(row.getString("oncePlanId")); if (oncePlan != null){ - cardTemplateExtend.setExtendId(oncePlan.getId()) + cardTemplateExtend.setTemplateId(row.getString("oldTemplateId")) + .setExtendId(oncePlan.getId()) .setPayType(1); cardTemplateExtends.add(cardTemplateExtend); } @@ -192,7 +192,8 @@ public class CpopDataSyncTests { if (StringUtils.isNotBlank(row.getString("monthPlanId"))){ WxPayScore monthPlan = wxPayScoreMap.get(row.getString("monthPlanId")); if (monthPlan != null){ - cardTemplateExtend.setExtendId(monthPlan.getId()) + cardTemplateExtend.setTemplateId(row.getString("oldTemplateId")) + .setExtendId(monthPlan.getId()) .setPayType(5); cardTemplateExtends.add(cardTemplateExtend); } diff --git a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java index 908ef9c..1c63503 100644 --- a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java +++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java @@ -90,4 +90,14 @@ public class WxPayProperties { * 服务商模式下的子商户公众账号ID */ private String serviceAppId; + + /** + * 先学后付用户签约计划通知地址 + */ + private String learnNowPayLaterUserSignPlanNotifyUrl; + + /** + * 先学后付用户支付成功通知地址 + */ + private String learnNowPayLaterServiceOrderNotifyUrl; } diff --git a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java index 821da72..167b4df 100644 --- a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java +++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java @@ -1,27 +1,21 @@ package com.cpop.pay.framewok.handler.wxPay; import com.alibaba.fastjson.JSONObject; +import com.cpop.common.utils.ServletUtils; import com.cpop.common.utils.StringUtils; -import com.cpop.common.utils.bean.BeanUtils; import com.cpop.core.base.exception.ServiceException; -import com.cpop.core.base.exception.UtilException; import com.cpop.core.utils.SecurityUtils; -import com.cpop.pay.framewok.core.dto.LearnNowPayLaterPlanDto; -import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanRequest; -import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanResult; +import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.PartnerPayScoreSignPlanService; import com.github.binarywang.wxpay.service.WxPayService; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.row.Db; import com.mybatisflex.core.row.Row; -import com.mybatisflex.core.row.RowKey; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; +import javax.servlet.http.HttpServletRequest; /** * @author DB @@ -29,6 +23,7 @@ import java.util.ArrayList; * @description */ @Component +@Slf4j public class WxPayHandler { @Autowired @@ -141,4 +136,20 @@ public class WxPayHandler { return wxMchId; } + /** + * 获取签约头 + * @author DB + * @since 2024/1/20 + * @return SignatureHeader + */ + public SignatureHeader getSignatureHeader() { + HttpServletRequest request = ServletUtils.getRequest(); + SignatureHeader signatureHeader = new SignatureHeader(); + signatureHeader.setSigned(request.getHeader("Wechatpay-Signature")); + signatureHeader.setNonce(request.getHeader("Wechatpay-Nonce")); + signatureHeader.setSerialNo(request.getHeader("Wechatpay-Serial")); + signatureHeader.setTimeStamp(request.getHeader("Wechatpay-Timestamp")); + log.info("微信支付分回调ID:{}",request.getHeader("Request-ID")); + return signatureHeader; + } } diff --git a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/task/WxPayAsyncTask.java b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/task/WxPayAsyncTask.java index 2779422..e32dd1a 100644 --- a/Cpop-Pay/src/main/java/com/cpop/pay/framewok/task/WxPayAsyncTask.java +++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/task/WxPayAsyncTask.java @@ -142,7 +142,7 @@ public class WxPayAsyncTask { throw new ServiceException(profitSharingResult.getReturnMsg()); } } catch (WxPayException e) { - if (flag > 5) { + if (flag > 2) { if (OrderSource.MALL == orderSource) { //关闭商城支付 DbChain.table("cp_sys_brand") diff --git a/Cpop-System/src/main/java/com/cpop/system/business/entity/WxPayScore.java b/Cpop-System/src/main/java/com/cpop/system/business/entity/WxPayScore.java index c172d3a..834273c 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/entity/WxPayScore.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/entity/WxPayScore.java @@ -6,13 +6,11 @@ import com.cpop.core.base.entity.BaseUpdateListener; import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Table; -import java.io.Serializable; -import java.time.LocalDateTime; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.*; import lombok.experimental.Accessors; +import java.io.Serializable; + /** * 微信支付分计划表 实体类。 * @@ -74,6 +72,11 @@ public class WxPayScore extends BaseEntity implements Serializable { */ private String planSource; + /** + * 课次 + */ + private String classHour; + /** * 逻辑删除(0否1是) */ From 75ae70824270509659747b4113b9d99c568eeea7 Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Sun, 21 Jan 2024 22:53:15 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E8=AF=BE=E5=8D=A1=E6=8B=93=E5=B1=95?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bo/LearnNowPayLaterServiceOrderBo.java | 9 ------ .../LearnNowPayLaterStopUserSignPlansBo.java | 7 ++++- .../mini/MiniEasyLearnController.java | 2 +- .../impl/EasyLearnOrderServiceImpl.java | 31 ++++++++++++------- .../src/main/resources/application-prod.yml | 2 +- .../src/main/resources/application-test.yml | 2 +- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java index f811093..dc874c1 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java @@ -51,8 +51,6 @@ public class LearnNowPayLaterServiceOrderBo { @ApiModelProperty(value = "卡号",required = true) private String cardNo; - - /** * 课程信息 */ @@ -67,11 +65,4 @@ public class LearnNowPayLaterServiceOrderBo { @ApiModelProperty(value = "核销金额",required = true) private Integer price; - /** - * 是否是旧卡 - */ - @ApiModelProperty(value = "是否是旧卡") - private Boolean isOldCard; - - } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterStopUserSignPlansBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterStopUserSignPlansBo.java index 6e10eb3..8170ef5 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterStopUserSignPlansBo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterStopUserSignPlansBo.java @@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotBlank; + /** * @author DB * @version 1.0.0 @@ -16,11 +18,14 @@ public class LearnNowPayLaterStopUserSignPlansBo { /** * 签约计划id */ - @ApiModelProperty(value = "签约计划id") + @NotBlank(message = "签约计划id不能为空") + @ApiModelProperty(value = "签约计划id",required = true) private String signPlanId; /** * 取消理由 */ + @NotBlank(message = "取消理由不能为空") + @ApiModelProperty(value = "取消理由",required = true) private String stopReason; } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java index 14f4a93..1743b56 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java @@ -84,7 +84,7 @@ public class MiniEasyLearnController { * @return R */ @ApiOperation("取消用户签约计划") - @PostMapping("/stopUserSignPlans/{signPlanId}") + @PostMapping("/stopUserSignPlans") public R stopUserSignPlans(@RequestBody @Validated LearnNowPayLaterStopUserSignPlansBo bo){ easyLearnOrderService.stopUserSignPlans(bo); return R.ok(); diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java index b8252e9..9da9d65 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java @@ -17,15 +17,9 @@ import com.cpop.core.utils.SpringUtils; import com.cpop.core.utils.sql.SqlUtils; import com.cpop.jambox.business.bo.*; import com.cpop.jambox.business.dto.EasyLearnPageDto; -import com.cpop.jambox.business.entity.BrandExtend; -import com.cpop.jambox.business.entity.EasyLearnOrder; -import com.cpop.jambox.business.entity.EasyLearnOrderDetail; -import com.cpop.jambox.business.entity.StoreExtend; +import com.cpop.jambox.business.entity.*; import com.cpop.jambox.business.mapper.EasyLearnOrderMapper; -import com.cpop.jambox.business.service.BrandExtendService; -import com.cpop.jambox.business.service.EasyLearnOrderDetailService; -import com.cpop.jambox.business.service.EasyLearnOrderService; -import com.cpop.jambox.business.service.StoreExtendService; +import com.cpop.jambox.business.service.*; import com.cpop.jambox.business.vo.EasyLearnPageVo; import com.cpop.jambox.framework.constant.JamboxCloudUrl; import com.cpop.jambox.framework.constant.JamboxRedisConstant; @@ -73,6 +67,7 @@ import java.util.concurrent.locks.Lock; import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND; import static com.cpop.jambox.business.entity.table.EasyLearnOrderDetailTableDef.EASY_LEARN_ORDER_DETAIL; +import static com.cpop.jambox.business.entity.table.EasyLearnOrderExtendTableDef.EASY_LEARN_ORDER_EXTEND; import static com.cpop.jambox.business.entity.table.EasyLearnOrderTableDef.EASY_LEARN_ORDER; import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND; import static com.cpop.system.business.entity.table.StoreTableDef.STORE; @@ -774,6 +769,15 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl= Math.ceil(1 / OrderSource.EASY_LEARN.getRate())) { //设置子商户 WxPayService wxPayService = wxPayHandler.getWxPayService(null, subMchId); diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-prod.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-prod.yml index 0902d5c..f4364fc 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-prod.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-prod.yml @@ -56,7 +56,7 @@ mybatis-flex: configuration: log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl datasource: - mall: + oam: url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/cpop_union?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: Customer0401 diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml index d222961..fa09f93 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-test.yml @@ -56,7 +56,7 @@ mybatis-flex: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl datasource: - mall: + oam: url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/cpop_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: Customer0401 From 0abc786b1d3943292f529b857d53c9abf42223a2 Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Mon, 22 Jan 2024 22:28:27 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BA=8B=E5=8A=A1=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=BB=91=E5=AE=9A;=E8=AF=BE=E5=8D=A1=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E8=B0=83=E6=95=B4;=E4=B8=AA=E4=BA=BA=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloudDb/core/dto/CloudClassCardDto.java | 2 +- .../handler/CloudClassCardHandler.java | 19 ++ .../bo/LearnNowPayLaterServiceOrderBo.java | 7 - .../bo/LearnNowPayLaterUserSignPlansBo.java | 21 +- .../mini/MiniCardTemplateController.java | 17 ++ .../mini/MiniEasyLearnController.java | 7 +- .../business/entity/EasyLearnOrder.java | 5 + .../business/service/CardTemplateService.java | 11 +- .../service/impl/CardTemplateServiceImpl.java | 36 +++- .../impl/EasyLearnOrderServiceImpl.java | 197 +++++++++++------- .../business/vo/CardTemplateInfoVo.java | 135 ++++++++++++ .../constant/JamboxRedisConstant.java | 11 + .../src/main/resources/application-dev.yml | 2 +- .../com/cpop/oam/web/CpopDataSyncTests.java | 17 ++ .../oam/business/bo/BusinessDistributeBo.java | 26 +-- .../backstage/BusinessController.java | 33 ++- .../oam/business/service/BusinessService.java | 18 ++ .../service/impl/BrandManagerServiceImpl.java | 3 +- .../service/impl/BusinessServiceImpl.java | 158 +++++--------- .../service/impl/TaskServiceImpl.java | 17 +- .../oam/business/vo/BusinessUnSignPageVo.java | 71 +++++++ .../cpop/system/business/entity/Store.java | 5 + .../system/business/service/StoreService.java | 1 + 23 files changed, 590 insertions(+), 229 deletions(-) create mode 100644 Cpop-Jambox/src/main/java/com/cpop/jambox/business/vo/CardTemplateInfoVo.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/vo/BusinessUnSignPageVo.java diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudClassCardDto.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudClassCardDto.java index 2329351..5d3f259 100644 --- a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudClassCardDto.java +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/core/dto/CloudClassCardDto.java @@ -162,7 +162,7 @@ public class CloudClassCardDto { /** * 每期课次 */ - private Integer classHour; + private String classHour; /** * 签约计划详情,json格式 diff --git a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudClassCardHandler.java b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudClassCardHandler.java index f36e035..f5c3842 100644 --- a/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudClassCardHandler.java +++ b/Cpop-Api/src/main/java/com/cpop/api/cloudDb/handler/CloudClassCardHandler.java @@ -160,6 +160,25 @@ public class CloudClassCardHandler { } else { throw new ServiceException("办卡失败!"); } + } + + /** + * 通知退款退卡 + * @author DB + * @since 2024/1/22 + * @param dto 请求参数 + */ + public void refundCloudClassCard(CloudClassCardDto dto){ + JSONObject jsonBody = JSONObject.parseObject(JSONObject.toJSONString(dto)); + jsonBody.put("_type", "periodRefund"); + JSONObject result = restTemplate.postForObject(CloudDbUrl.COMMON_USE_URL, jsonBody, JSONObject.class); + if (result != null) { + if (!result.getBoolean("success")) { + throw new UtilException(result.getString("error")); + } + } else { + throw new ServiceException("操作失败!"); + } } } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java index dc874c1..e7c365c 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterServiceOrderBo.java @@ -37,13 +37,6 @@ public class LearnNowPayLaterServiceOrderBo { @ApiModelProperty(value = "服务商公众号下的用户标识",required = true) private String openid; - /** - * 支付分订单在商户侧的订单号,必须和创建签约计划时传入的该笔订单对应的商户侧计划明细使用订单号(merchant\_plan\_detail\_no)一致 - */ - @NotBlank(message = "outTradeNo不能为空") - @ApiModelProperty(value = "支付分订单在商户侧的订单号,必须和创建签约计划时传入的该笔订单对应的商户侧计划明细使用订单号(merchant_plan_detail_no)一致",required = true) - private String outTradeNo; - /** * 卡号 */ diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterUserSignPlansBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterUserSignPlansBo.java index 3ee1da8..b649bff 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterUserSignPlansBo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/LearnNowPayLaterUserSignPlansBo.java @@ -39,18 +39,33 @@ public class LearnNowPayLaterUserSignPlansBo { /** * 支付分计划名称 */ - @ApiModelProperty("支付分计划名称") + @NotBlank(message = "支付分计划名称不能为空") + @ApiModelProperty(value = "支付分计划名称",required = true) private String planName; /** * 客户名 */ - @ApiModelProperty("客户名") + @NotBlank(message = "客户名不能为空") + @ApiModelProperty(value = "客户名",required = true) private String customerName; /** * 客户手机号 */ - @ApiModelProperty("客户手机号") + @NotBlank(message = "客户手机号不能为空") + @ApiModelProperty(value = "客户手机号", required = true) private String customerPhone; + + /** + * 模板id + */ + @ApiModelProperty(value = "模板id") + private String templateId; + + /** + * 旧模板id + */ + @ApiModelProperty(value = "旧模板id") + private String oldTemplateId; } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniCardTemplateController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniCardTemplateController.java index 784add9..eff1d0a 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniCardTemplateController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniCardTemplateController.java @@ -6,8 +6,10 @@ import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.jambox.business.entity.CardTemplate; import com.cpop.jambox.business.service.CardTemplateExtendService; import com.cpop.jambox.business.service.CardTemplateService; +import com.cpop.jambox.business.vo.CardTemplateInfoVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -77,4 +79,19 @@ public class MiniCardTemplateController { .remove(); return R.ok(); } + + /** + * 获取模板信息 + * @author DB + * @since 2024/1/22 + * @param id 主键 + * @return R + */ + @ApiOperation(value = "获取模板信息") + @GetMapping("/getCardTemplateInfo") + public R getCardTemplateInfo(@ApiParam("id") @RequestParam(value = "id", required = false) String id, + @ApiParam("旧模板id") @RequestParam(value = "oldTemplateId", required = false) String oldTemplateId) { + CardTemplateInfoVo vo = cardTemplateService.getCardTemplateInfo(id, oldTemplateId); + return R.ok(vo); + } } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java index 1743b56..232b224 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/controller/mini/MiniEasyLearnController.java @@ -42,9 +42,10 @@ public class MiniEasyLearnController { */ @ApiOperation("获取支付分计划") @GetMapping("/getWxPayScorePlan") - public R getWxPayScorePlan(@ApiParam(value = "旧模板id", required = true) @RequestParam("oldTemplateId") String oldTemplateId, - @ApiParam(value = "是否月付(0否1是)", required = true) @RequestParam("isMonth") Boolean isMonth) { - LearnNowPayLaterPlanVo vo = cardTemplateService.getWxPayScorePlan(oldTemplateId, isMonth); + public R getWxPayScorePlan(@ApiParam(value = "旧模板id") @RequestParam(value = "oldTemplateId", required = false) String oldTemplateId, + @ApiParam(value = "模板id") @RequestParam(value = "templateId", required = false) String templateId, + @ApiParam(value = "是否月付(0否1是)", required = true) @RequestParam("isMonth") Boolean isMonth) { + LearnNowPayLaterPlanVo vo = cardTemplateService.getWxPayScorePlan(oldTemplateId, templateId, isMonth); return R.ok(vo); } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/EasyLearnOrder.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/EasyLearnOrder.java index 796e06b..f6964aa 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/EasyLearnOrder.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/entity/EasyLearnOrder.java @@ -104,6 +104,11 @@ public class EasyLearnOrder extends BaseEntity implements Serializable { */ private Double rate; + /** + * 模板id + */ + private String templateId; + /** * 逻辑删除(0否1是) */ diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java index c587f7e..dc3a79c 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/CardTemplateService.java @@ -2,6 +2,7 @@ package com.cpop.jambox.business.service; import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.jambox.business.entity.CardTemplate; +import com.cpop.jambox.business.vo.CardTemplateInfoVo; import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; import com.cpop.jambox.business.vo.LearnNowPayLaterPlanVo; import com.mybatisflex.core.row.Row; @@ -50,5 +51,13 @@ public interface CardTemplateService extends IService { * @param isMonth 是否月付 * @return LearnNowPayLaterPlanDetailVo */ - LearnNowPayLaterPlanVo getWxPayScorePlan(String oldTemplateId, Boolean isMonth); + LearnNowPayLaterPlanVo getWxPayScorePlan(String oldTemplateId,String templateId, Boolean isMonth); + + /** + * 获取模板信息 + * @author DB + * @since 2024/1/22 + * @param id 主键 + */ + CardTemplateInfoVo getCardTemplateInfo(String id,String oldTemplateId); } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java index 7ed2da7..8821148 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java @@ -15,6 +15,7 @@ import com.cpop.jambox.business.service.BrandExtendService; import com.cpop.jambox.business.service.CardTemplateExtendService; import com.cpop.jambox.business.service.CardTemplateService; import com.cpop.jambox.business.service.StoreExtendService; +import com.cpop.jambox.business.vo.CardTemplateInfoVo; import com.cpop.jambox.business.vo.LearnNowPayLaterPlanDetailVo; import com.cpop.jambox.business.vo.LearnNowPayLaterPlanVo; import com.cpop.jambox.framework.tasks.LearnNowPayLaterTask; @@ -283,8 +284,13 @@ public class CardTemplateServiceImpl extends ServiceImpl payTypeList = SpringUtils.getBean(CardTemplateExtendService.class).queryChain() + .where(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(vo.getId())) + .list().stream().map(CardTemplateExtend::getPayType) + .collect(Collectors.toList()); + vo.setPayType(payTypeList); + return vo; + } + } diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java index 9da9d65..a9469e3 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/EasyLearnOrderServiceImpl.java @@ -47,6 +47,7 @@ import com.mybatisflex.core.datasource.FlexDataSource; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.row.Db; +import com.mybatisflex.core.row.DbChain; import com.mybatisflex.core.row.Row; import com.mybatisflex.core.row.RowUtil; import com.mybatisflex.spring.service.impl.ServiceImpl; @@ -72,6 +73,7 @@ import static com.cpop.jambox.business.entity.table.EasyLearnOrderTableDef.EASY_ import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND; import static com.cpop.system.business.entity.table.StoreTableDef.STORE; import static com.cpop.system.business.entity.table.WxPayScoreDetailTableDef.WX_PAY_SCORE_DETAIL; +import static com.cpop.system.business.entity.table.WxPayScoreTableDef.WX_PAY_SCORE; /** * 果酱-放心学订单表 服务层实现。 @@ -679,33 +681,48 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl wxPayScoreDetails = SpringUtils.getBean(WxPayScoreDetailService.class).queryChain() - .where(WX_PAY_SCORE_DETAIL.SYS_WX_PAY_SCORE_ID.eq(bo.getId())) - .list(); - Row brandAndStore = Db.selectOneByQuery(QueryWrapper.create() - .select(STORE.ID,STORE.BRAND_ID) - .leftJoin(STORE_EXTEND).on(STORE_EXTEND.STORE_ID.eq(STORE.ID)) - .where(STORE_EXTEND.STORE_CLOUD_ID.eq(bo.getStoreCloudId()))); - //创建用户签约计划 - String orderId = createEasyLearnUserSignPlans(bo, brandAndStore, wxPayScore); - String subMchId = wxPayHandler.getSubMchId(brandAndStore.getString("brandId"), brandAndStore.getString("id")); - WxPayService wxPayService = wxPayHandler.getWxPayService(null, subMchId); - PartnerPayScoreSignPlanService partnerPayScoreSignPlanService = wxPayService.getPartnerPayScoreSignPlanService(); - List payScorePlanDetailRequests = BeanUtils.mapToList(wxPayScoreDetails, PayScorePlanDetailRequest.class); - WxPartnerPayScoreSignPlanRequest signPlanRequest = new WxPartnerPayScoreSignPlanRequest(); - signPlanRequest.setPlanId(wxPayScore.getOutPlanId()).setSubAppid(subMchId) - .setSubOpenid(bo.getSubOpenId()) - .setMerchantSignPlanNo(orderId) - .setPlanDetailList(payScorePlanDetailRequests) - .setNotifyUrl(wxPayConfiguration.getProperties().getLearnNowPayLaterUserSignPlanNotifyUrl()); - try { - return partnerPayScoreSignPlanService.createUserSignPlans(signPlanRequest); - } catch (WxPayException e) { - throw new ServiceException(e.getMessage()); + //分布式锁进行幂等处理 + RedisService redisService = SpringUtils.getBean(RedisService.class); + //分布式锁进行幂等处理 + Lock userIdLock = redisService.distributedLock(JamboxRedisConstant.LEARN_NOW_PAY_LATER_CREATE_USER_PLANS_LOCK_USER_PAY + bo.getId()); + if (userIdLock.tryLock()) { + try { + // 获取计划 + WxPayScore wxPayScore = SpringUtils.getBean(WxPayScoreService.class).getById(bo.getId()); + //获取计划详情 + List wxPayScoreDetails = SpringUtils.getBean(WxPayScoreDetailService.class).queryChain() + .where(WX_PAY_SCORE_DETAIL.SYS_WX_PAY_SCORE_ID.eq(bo.getId())) + .list(); + Row brandAndStore = Db.selectOneByQuery(QueryWrapper.create() + .select(STORE.ID, STORE.BRAND_ID) + .leftJoin(STORE_EXTEND).on(STORE_EXTEND.STORE_ID.eq(STORE.ID)) + .where(STORE_EXTEND.STORE_CLOUD_ID.eq(bo.getStoreCloudId()))); + //创建用户签约计划 + String orderId = createEasyLearnUserSignPlans(bo, brandAndStore, wxPayScore); + String subMchId = wxPayHandler.getSubMchId(brandAndStore.getString("brandId"), brandAndStore.getString("id")); + WxPayService wxPayService = wxPayHandler.getWxPayService(null, subMchId); + PartnerPayScoreSignPlanService partnerPayScoreSignPlanService = wxPayService.getPartnerPayScoreSignPlanService(); + List payScorePlanDetailRequests = BeanUtils.mapToList(wxPayScoreDetails, PayScorePlanDetailRequest.class); + WxPartnerPayScoreSignPlanRequest signPlanRequest = new WxPartnerPayScoreSignPlanRequest(); + signPlanRequest.setPlanId(wxPayScore.getOutPlanId()).setSubAppid(subMchId) + .setSubOpenid(bo.getSubOpenId()) + .setMerchantSignPlanNo(orderId) + .setPlanDetailList(payScorePlanDetailRequests) + .setNotifyUrl(wxPayConfiguration.getProperties().getLearnNowPayLaterUserSignPlanNotifyUrl()); + try { + return partnerPayScoreSignPlanService.createUserSignPlans(signPlanRequest); + } catch (WxPayException e) { + throw new ServiceException(e.getMessage()); + } + } finally { + //释放锁 + userIdLock.unlock(); + } + } else { + //获取锁失败,直接返回空 + throw new ServiceException("请勿重复提交"); } + } /** @@ -726,11 +743,18 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl payType; + + /** + * 是否是会员(0否1是) + */ + @ApiModelProperty(value = "是否是会员(0否1是)") + private Boolean isMember; + + /** + * 是否是引流卡 + */ + @ApiModelProperty(value = "是否是引流卡(0否1是)") + private Boolean isDrainage; + + /** + * 二维码 + */ + @ApiModelProperty(value = "二维码") + private String qrCode; +} diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/constant/JamboxRedisConstant.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/constant/JamboxRedisConstant.java index 2dc1188..7dbeb9f 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/constant/JamboxRedisConstant.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/framework/constant/JamboxRedisConstant.java @@ -11,4 +11,15 @@ public interface JamboxRedisConstant { * 一次性支付 */ String ONCE_PAY_LOCK_USER_PAY = "jambox:oncePayLock:userPay:"; + + /** + * 先学后付创建计划 + */ + String LEARN_NOW_PAY_LATER_CREATE_USER_PLANS_LOCK_USER_PAY = "jambox:learnNowPayLaterCreateUserPlansLock:userPay:"; + + /** + * 先学后付用户核销 + */ + String LEARN_NOW_PAY_LATER_SERVICE_ORDER_LOCK_USER_PAY = "jambox:learnNowPayLaterServiceOrderLock:userPay:"; + } diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml index 2177965..8112abe 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/resources/application-dev.yml @@ -111,4 +111,4 @@ wx: # 先学后付用户签约通知地址 learn-now-pay-later-user-sign-plan-notify-url: # 先学后付用户核销通知地址 - learn-now-pay-later-service-order-notify-url: + learn-now-pay-later-service-order-notify-url: \ No newline at end of file diff --git a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java index ad659c3..407a71b 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java +++ b/Cpop-Oam/Cpop-Oam-Web/src/test/java/com/cpop/oam/web/CpopDataSyncTests.java @@ -13,6 +13,7 @@ import com.cpop.jambox.business.service.StoreExtendService; import com.cpop.system.business.entity.Store; import com.cpop.system.business.entity.StoreSign; import com.cpop.system.business.entity.WxPayScore; +import com.cpop.system.business.mapper.StoreMapper; import com.cpop.system.business.mapper.StoreSignMapper; import com.cpop.system.business.service.StoreService; import com.cpop.system.business.service.StoreSignService; @@ -269,4 +270,20 @@ public class CpopDataSyncTests { String pattern = "[^a-zA-Z0-9]"; System.out.println(input.replaceAll(pattern, "")); } + + /** + * 同步校区签约数据 + */ + @Test + public void syncStoreSignData(){ + List list = SpringUtils.getBean(StoreSignService.class).list(); + List stores = new ArrayList<>(); + list.forEach(item->{ + Store store = new Store(); + store.setId(item.getStoreId()) + .setSignId(item.getId()); + stores.add(store); + }); + SpringUtils.getBean(StoreService.class).updateBatch(stores); + } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/BusinessDistributeBo.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/BusinessDistributeBo.java index 0ed582a..1b3c9e9 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/BusinessDistributeBo.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/BusinessDistributeBo.java @@ -30,12 +30,7 @@ public class BusinessDistributeBo { @NotNull(message = "业务等级不能为空") @ApiModelProperty(value = "业务等级") private Integer businessLevel; - /** - * 业务类型 - */ - @NotNull(message = "业务类型不能为空") - @ApiModelProperty(value = "业务类型") - private Integer businessType; + /** * 对接列表 */ @@ -58,11 +53,6 @@ public class BusinessDistributeBo { */ @ApiModelProperty(value = "备注") private String remark; - /** - * 签约列表 - */ - @ApiModelProperty(value = "签约列表") - private List sign; @Data public static class ButtJoint { @@ -77,18 +67,4 @@ public class BusinessDistributeBo { @ApiModelProperty(value = "接收员工id") private String staffId; } - - @Data - public static class Sign { - /** - * 接收员工id - */ - @ApiModelProperty(value = "接收员工id") - private String staffId; - /** - * 剩余数量 - */ - @ApiModelProperty(value = "剩余数量") - private Integer surplusQuantity; - } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/BusinessController.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/BusinessController.java index bc07085..3a187d2 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/BusinessController.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/BusinessController.java @@ -10,10 +10,7 @@ import com.cpop.oam.business.bo.BusinessRemoveBo; import com.cpop.oam.business.dto.BusinessDistributeDto; import com.cpop.oam.business.service.BusinessService; import com.cpop.oam.business.service.StaffService; -import com.cpop.oam.business.vo.BusinessInfoPageVo; -import com.cpop.oam.business.vo.BusinessPageVo; -import com.cpop.oam.business.vo.PersonBusinessInfoVo; -import com.cpop.oam.business.vo.StaffVo; +import com.cpop.oam.business.vo.*; import com.mybatisflex.core.paginate.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -163,4 +160,32 @@ public class BusinessController { return R.ok(); } + /** + * 查询未签约校区分页列表 + * @author DB + * @since 2024/1/22 + * @param params 请求参数 + * @return R> + */ + @ApiOperation("查询未签约校区分页列表") + @GetMapping("/getUnSignStorePage") + public R> getUnSignStorePage(@ApiParam("查询参数") @RequestParam(value = "params", required = false) String params) { + Page pageVo = businessService.getUnSignStorePage(params); + return R.ok(pageVo); + } + + /** + * 校区签约 + * @author DB + * @since 2024/1/22 + * @param id 校区id + * @return R + */ + @ApiOperation("校区签约") + @PutMapping("/storeSign") + public R storeSign(@ApiParam(value = "校区id", required = true) @RequestParam(value = "id") String id) { + businessService.storeSign(id); + return R.ok(); + } + } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/BusinessService.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/BusinessService.java index 97c0f34..83a1022 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/BusinessService.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/BusinessService.java @@ -6,6 +6,7 @@ import com.cpop.oam.business.bo.BusinessInfoPageBo; import com.cpop.oam.business.bo.BusinessRemoveBo; import com.cpop.oam.business.vo.BusinessInfoPageVo; import com.cpop.oam.business.vo.BusinessPageVo; +import com.cpop.oam.business.vo.BusinessUnSignPageVo; import com.cpop.oam.business.vo.PersonBusinessInfoVo; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.service.IService; @@ -69,4 +70,21 @@ public interface BusinessService extends IService { * @return PersonBusinessInfoVo */ PersonBusinessInfoVo getPersonBusinessInfoById(String id); + + /** + * 查询未签约校区分页列表 + * @author DB + * @since 2024/1/22 + * @param params 请求参数 + * @return Page + */ + Page getUnSignStorePage(String params); + + /** + * 校区签约 + * @author DB + * @since 2024/1/22 + * @param id 主键 + */ + void storeSign(String id); } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BrandManagerServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BrandManagerServiceImpl.java index 2369152..4b26bbf 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BrandManagerServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/BrandManagerServiceImpl.java @@ -83,7 +83,8 @@ public class BrandManagerServiceImpl extends ServiceImpl i .setStartDate(bo.getStartAndEnd().get(0)) .setEndDate(bo.getStartAndEnd().get(1)); this.save(business); - Integer allSurplusQuantity; - //机构对接 - if (business.getBusinessType() == 0){ - allSurplusQuantity = createButtJoint(bo, business.getId()); - } else { - allSurplusQuantity = createSign(bo,business.getId()); - } + Integer allSurplusQuantity = createButtJoint(bo, business.getId()); business.setAllSurplusQuantity(allSurplusQuantity); this.updateById(business); //TODO:定时检查事务过期? } - /** - * 事务签约 - * @author DB - * @since 2023/12/13 - * @param bo 请求 - * @param businessId 事务id - * @return Integer - */ - private Integer createSign(BusinessDistributeBo bo, String businessId) { - //事务详情数量标记 - AtomicReference flag = new AtomicReference<>(0); - if (bo.getSign().isEmpty()){ - throw new ServiceException("签约人不能为空"); - } - List businessStaffs = BeanUtils.mapToList(bo.getSign(), BusinessStaff.class); - businessStaffs.forEach(item -> { - item.setBusinessId(businessId); - flag.updateAndGet(v -> v + item.getSurplusQuantity()); - }); - //保存负责员工 - SpringUtils.getBean(BusinessStaffService.class).saveBatch(businessStaffs); - return flag.get(); - } - /** * 事务对接 * @author DB @@ -226,68 +199,7 @@ public class BusinessServiceImpl extends ServiceImpl i */ @Override public Page getBusinessInfoPage(BusinessInfoPageBo bo) { - //获取当前事务 - Business business = this.getById(bo.getId()); - //对接 - if (business.getBusinessType() == 0) { - return getButtJoint(bo); - } else { - //签约 - return getSign(bo); - } - } - - /** - * 获取签约数据 - * @author DB - * @since 2023/12/13 - * @param bo 请求 - * @return Page - */ - private Page getSign(BusinessInfoPageBo bo) { - //获取当前员工信息 - JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); - QueryWrapper queryWrapper = QueryWrapper.create(); - //运营人员 - if (loginUserInfo.getInteger("staffType") == 1) { - //查询自己处理中的校区的记录 - queryWrapper.and(BUSINESS_STAFF.STAFF_ID.eq(loginUserInfo.getString("id")) - //获取所有无人处理的校区 - .or(STORE.ID.notIn(select(distinct(BUSINESS_DETAIL.STORE_ID)) - .from(BUSINESS_DETAIL) - .leftJoin(BUSINESS_STAFF).on(BUSINESS_STAFF.ID.eq(BUSINESS_DETAIL.BUSINESS_STAFF_ID)) - .where(BUSINESS_STAFF.STAFF_ID.ne(loginUserInfo.getString("id")) - .and(BUSINESS_DETAIL.STORE_ID.isNotNull())) - ))); - } else { - queryWrapper.and(BUSINESS_STAFF.STAFF_ID.in(bo.getStaffIds())); - } - PageDomain pageDomain = SqlUtils.getInstance().getPageDomain(); - return SpringUtils.getBean(StoreService.class).getMapper().paginateAs(Page.of(pageDomain.getPageNum(), pageDomain.getPageSize()), - queryWrapper - .select(BUSINESS_DETAIL.ID.as(BusinessInfoPageVo::getId),BUSINESS_DETAIL.BUSINESS_ID, BUSINESS_DETAIL.DETAIL_STATUS, BUSINESS_DETAIL.DETAIL_DESC, BUSINESS_DETAIL.DETAIL_RECORD_TIME) - //品牌 - .select(BRAND.BRAND_NAME) - //校区 - .select(STORE.STORE_NAME, STORE.PERSON_CHARGE, STORE.PHONE, STORE.ID.as(BusinessInfoPageVo::getStoreId)) - //营业执照 - .select(STORE_LICENSE.LICENSE_NAME, STORE_LICENSE.LICENSE_USER_NAME, STORE_LICENSE.LICENSE_ADDR) - .leftJoin(BRAND).on(BRAND.ID.eq(STORE.BRAND_ID)) - .leftJoin(STORE_LICENSE).on(STORE_LICENSE.STORE_ID.eq(STORE.ID)) - .leftJoin(BUSINESS_DETAIL).on(BUSINESS_DETAIL.STORE_ID.eq(STORE.ID)) - .leftJoin(BUSINESS_STAFF).on(BUSINESS_STAFF.ID.eq(BUSINESS_DETAIL.BUSINESS_STAFF_ID)) - .leftJoin(STAFF).on(STAFF.ID.eq(BUSINESS_STAFF.STAFF_ID)) - //品牌或校区名模糊查询 - .and(BRAND.BRAND_NAME.like(bo.getBrandOrStore()).or(STORE.STORE_NAME.like(bo.getBrandOrStore()))) - //校区地址或校区名模糊查询 - .and(STORE_LICENSE.LICENSE_NAME.like(bo.getAddrOrName()).or(STORE_LICENSE.LICENSE_ADDR.like(bo.getAddrOrName()))) - //未签约-非测试 - .and(STORE.IS_TEST.eq(false)) - .and(STORE.HAVE_ACTIVE.eq(false)) - .and(BUSINESS_DETAIL.DETAIL_STATUS.eq(bo.getDetailStatus())) - .orderBy(BUSINESS_DETAIL.CREATE_TIME.asc()), - BusinessInfoPageVo.class); - + return getButtJoint(bo); } /** @@ -382,18 +294,7 @@ public class BusinessServiceImpl extends ServiceImpl i .where(BUSINESS_STAFF.BUSINESS_ID.eq(businessDetail.getBusinessId())) .and(BUSINESS_STAFF.STAFF_ID.eq(loginUserInfo.getString("id"))) .update(); - //机构签约 - if (business.getBusinessType()== 1){ - //校区自动延期一年 - StoreSignService storeSignService = SpringUtils.getBean(StoreSignService.class); - StoreSign storeSign = storeSignService.getOne(QueryWrapper.create().where(STORE_SIGN.STORE_ID.eq(bo.getStoreId()))); - if (storeSign == null) { - storeSign = new StoreSign(); - storeSign.setStoreId(bo.getStoreId()); - storeSign.setSignStaffId(loginUserInfo.getString("id")); - storeSignService.save(storeSign); - } - } + } } @@ -454,4 +355,51 @@ public class BusinessServiceImpl extends ServiceImpl i .and(BUSINESS_STAFF.STAFF_ID.eq(loginUserInfo.getString("id"))), PersonBusinessInfoVo.class); } + + /** + * 查询未签约校区分页列表 + * @author DB + * @since 2024/1/22 + * @param params 请求参数 + * @return Page + */ + @Override + public Page getUnSignStorePage(String params) { + PageDomain pageDomain = SqlUtils.getInstance().getPageDomain(); + return this.pageAs(Page.of(pageDomain.getPageNum(), pageDomain.getPageSize()), + QueryWrapper.create() + .select(STORE.ID, STORE.STORE_NAME, STORE.PERSON_CHARGE, STORE.PHONE, STORE.BRAND_ID) + .select(BRAND.BRAND_NAME) + .select(STORE_LICENSE.LICENSE_PIC_URL) + .select(BRAND_EXTEND.BRAND_CLOUD_ID) + .select(STORE_EXTEND.STORE_CLOUD_ID) + .from(STORE) + .leftJoin(BRAND).on(BRAND.ID.eq(STORE.BRAND_ID)) + .leftJoin(STORE_LICENSE).on(STORE_LICENSE.STORE_ID.eq(STORE.ID)) + .leftJoin(BRAND_EXTEND).on(BRAND_EXTEND.BRAND_ID.eq(BRAND.ID)) + .leftJoin(STORE_EXTEND).on(STORE_EXTEND.STORE_ID.eq(STORE.ID)) + .leftJoin(STORE_SIGN).on(STORE_SIGN.ID.eq(STORE.SIGN_ID)) + .where(STORE.SIGN_ID.isNull()) + .and(STORE.STORE_NAME.like(params) + .or(STORE.PERSON_CHARGE.like(params) + .or(STORE.PHONE.eq(params)))) + .orderBy(STORE.CREATE_TIME.desc()), + BusinessUnSignPageVo.class); + } + + /** + * 校区签约 + * @author DB + * @since 2024/1/22 + * @param id 主键 + */ + @Override + public void storeSign(String id) { + JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); + StoreSign storeSign = new StoreSign(); + storeSign.setStoreId(id); + storeSign.setSignStaffId(loginUserInfo.getString("id")); + StoreSignService storeSignService = SpringUtils.getBean(StoreSignService.class); + storeSignService.save(storeSign); + } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/TaskServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/TaskServiceImpl.java index e3095f1..ca79032 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/TaskServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/TaskServiceImpl.java @@ -353,27 +353,34 @@ public class TaskServiceImpl extends ServiceImpl implements Ta .where(STAFF.ID.eq(staffId))); //对比当前员工是否是测试管理员 if (!Arrays.asList(testStaffPhones.split(",")).contains(staff.getString("phoneNumber"))) { - queryWrapper.and(TASK.TASK_STATUS.in(2, 3)) + queryWrapper.and(TASK.TASK_STATUS.in(2, 3, 8, 9)) .and(TASK_STAFF_GROUP.STAFF_ID.eq(staffId)); } else { //测试人员 - queryWrapper.and(TASK.TASK_STATUS.eq(3)) + queryWrapper.and(TASK.TASK_STATUS.in(3, 8, 9)) .groupBy(TASK.ID); } } else { JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); //对比当前员工是否是测试管理员 if (!Arrays.asList(testStaffPhones.split(",")).contains(loginUserInfo.getString("phoneNumber"))) { - queryWrapper.and(TASK.TASK_STATUS.in(2, 3)) + queryWrapper.and(TASK.TASK_STATUS.in(2, 3, 8, 9)) .and(TASK_STAFF_GROUP.STAFF_ID.eq(loginUserInfo.getString("id"))); } else { //测试人员 - queryWrapper.and(TASK.TASK_STATUS.eq(3)) + queryWrapper.and(TASK.TASK_STATUS.in(3, 8, 9)) .groupBy(TASK.ID); } } if (startDate != null && endDate != null) { queryWrapper.and(dateFormat(TASK.TASK_RECEIPT_TIME, "%Y-%m-%d").between(startDate, endDate)); + } else { + LocalDate date = LocalDate.now(); + // 获取当前月的第一天 + LocalDate firstDay = date.with(TemporalAdjusters.firstDayOfMonth()); + // 获取当前月的最后一天 + LocalDate lastDay = date.with(TemporalAdjusters.lastDayOfMonth()); + queryWrapper.and(dateFormat(TASK.TASK_RECEIPT_TIME, "%Y-%m-%d").between(firstDay, lastDay)); } return this.mapper.paginateAs(pageDomain.getPageNum(), pageDomain.getPageSize(), @@ -791,7 +798,7 @@ public class TaskServiceImpl extends ServiceImpl implements Ta JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); queryWrapper.and(TASK_STAFF_GROUP.STAFF_ID.eq(loginUserInfo.getString("id"))); } - if (startDate!=null && endDate!=null){ + if (startDate != null && endDate != null) { queryWrapper.and(dateFormat(TASK.TASK_RECEIPT_TIME, "%Y-%m-%d").between(startDate, endDate)); } else { LocalDate now = LocalDate.now(); diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/vo/BusinessUnSignPageVo.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/vo/BusinessUnSignPageVo.java new file mode 100644 index 0000000..28df8ff --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/vo/BusinessUnSignPageVo.java @@ -0,0 +1,71 @@ +package com.cpop.oam.business.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author DB + * @version 1.0.0 + * @since 2024-01-22 13:47 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "校区/店铺未签约分页返回对象") +public class BusinessUnSignPageVo { + + /** + * 校区id + */ + @ApiModelProperty(value = "校区id") + private String id; + + /** + * 校区名 + */ + @ApiModelProperty(value = "校区名") + private String storeName; + + /** + * 负责人 + */ + @ApiModelProperty(value = "负责人") + private String personCharge; + + /** + * 手机号 + */ + @ApiModelProperty(value = "手机号") + private String phone; + + /** + * 营业执照地址 + */ + @ApiModelProperty(value = "营业执照地址") + private String licensePicUrl; + + /** + * 云校区id + */ + @ApiModelProperty(value = "云校区id") + private String storeCloudId; + + /** + * 品牌id + */ + @ApiModelProperty(value = "品牌id") + private String brandId; + + /** + * 云品牌id + */ + @ApiModelProperty(value = "云品牌id") + private String brandCloudId; + + /** + * 品牌名 + */ + @ApiModelProperty(value = "品牌名") + private String brandName; +} diff --git a/Cpop-System/src/main/java/com/cpop/system/business/entity/Store.java b/Cpop-System/src/main/java/com/cpop/system/business/entity/Store.java index 7499213..348eccb 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/entity/Store.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/entity/Store.java @@ -92,6 +92,11 @@ public class Store extends BaseEntity implements Serializable { */ private String latitude; + /** + * 签约id + */ + private String signId; + /** * 逻辑删除(0否1是) */ diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/StoreService.java b/Cpop-System/src/main/java/com/cpop/system/business/service/StoreService.java index 9da5be5..9e14f5a 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/service/StoreService.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/service/StoreService.java @@ -39,4 +39,5 @@ public interface StoreService extends IService { * @param bo 请求参数 */ void updateStore(StoreBo bo); + } From 3df0e72bf7b848b8f7a6f2993001b7b1480eecd7 Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Mon, 22 Jan 2024 23:43:44 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E7=94=9F=E6=88=90=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cpop-Jambox/pom.xml | 5 ++++ .../business/bo/CardTemplateUnionBo.java | 7 ----- .../service/impl/CardTemplateServiceImpl.java | 26 +++++++++++++++++++ Cpop-Oam/pom.xml | 5 ---- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Cpop-Jambox/pom.xml b/Cpop-Jambox/pom.xml index 213b6e1..d690f37 100644 --- a/Cpop-Jambox/pom.xml +++ b/Cpop-Jambox/pom.xml @@ -28,6 +28,11 @@ com.cpop Cpop-Pay + + + com.github.binarywang + weixin-java-miniapp + diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java index 263d5d2..2915d15 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/bo/CardTemplateUnionBo.java @@ -128,13 +128,6 @@ public class CardTemplateUnionBo { */ @ApiModelProperty(value = "是否是引流卡(0否1是)") private Boolean isDrainage; - - /** - * 二维码 - */ - @ApiModelProperty(value = "二维码") - private String qrCode; - /** * 先学后付支付 */ diff --git a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java index 8821148..7097416 100644 --- a/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java +++ b/Cpop-Jambox/src/main/java/com/cpop/jambox/business/service/impl/CardTemplateServiceImpl.java @@ -1,8 +1,13 @@ package com.cpop.jambox.business.service.impl; +import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; +import cn.binarywang.wx.miniapp.api.WxMaService; import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.bean.BeanUtils; +import com.cpop.core.base.exception.ServiceException; +import com.cpop.core.handler.TencentCosHandler; import com.cpop.core.utils.SpringUtils; +import com.cpop.core.utils.file.FileUtils; import com.cpop.jambox.business.bo.CardTemplateUnionBo; import com.cpop.jambox.business.bo.EasyLearnDigitalCurrencyBo; import com.cpop.jambox.business.bo.EasyLearnOldContractBo; @@ -30,9 +35,14 @@ import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.row.Db; import com.mybatisflex.core.row.Row; import com.mybatisflex.spring.service.impl.ServiceImpl; +import com.qcloud.cos.model.UploadResult; +import me.chanjar.weixin.common.error.WxErrorException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -110,6 +120,22 @@ public class CardTemplateServiceImpl extends ServiceImplcom.github.binarywang weixin-java-open - - - com.github.binarywang - weixin-java-miniapp - org.springframework spring-test