From 5dd83e3997c10b110727f449fdee0346be5ae63b Mon Sep 17 00:00:00 2001
From: DB <2502523450@qq.com>
Date: Thu, 21 Dec 2023 15:29:59 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9redis=E4=BD=8D=E7=BD=AE?=
=?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=90=8C=E6=AD=A5=E5=93=81=E7=89=8C?=
=?UTF-8?q?=E6=88=96=E6=A0=A1=E5=8C=BA=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/main/resources/application-dev.yml | 9 +-
.../src/main/resources/application-prod.yml | 8 +-
.../src/main/resources/application-test.yml | 8 +-
.../src/main/resources/application-dev.yml | 10 +-
.../src/main/resources/application-prod.yml | 8 +-
.../src/main/resources/application-test.yml | 10 +-
Cpop-Pay/pom.xml | 31 +++++
.../config/wxPay/WxPayConfiguration.java | 50 +++++++
.../config/wxPay/WxPayProperties.java | 78 +++++++++++
.../framewok/handler/wxPay/WxPayHandler.java | 75 +++++++++++
.../src/main/resources/application-pay.yml | 13 ++
.../business/bo/SyncBrandAndStoreBo.java | 122 ++++++++++++++++++
.../controller/SysCommonController.java | 20 +++
.../system/business/service/StoreService.java | 9 ++
.../service/impl/StoreServiceImpl.java | 72 ++++++++++-
pom.xml | 6 +
16 files changed, 501 insertions(+), 28 deletions(-)
create mode 100644 Cpop-Pay/pom.xml
create mode 100644 Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayConfiguration.java
create mode 100644 Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java
create mode 100644 Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java
create mode 100644 Cpop-Pay/src/main/resources/application-pay.yml
create mode 100644 Cpop-System/src/main/java/com/cpop/system/business/bo/SyncBrandAndStoreBo.java
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 2e75746..dde5b13 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
@@ -19,14 +19,13 @@ spring:
#redis配置
redis:
#地址
- host: 106.52.49.102
+ host: gz-crs-lv77ii2t.sql.tencentcdb.com
#端口
- port: 6333
+ port: 27714
#数据库
- #database: 10
- database: 0
+ database: 3
#密码
- password: Jambox.123*
+ password: Cpop2022@
#连接超时
timeout: 5000
jedis:
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 a07665d..63964b6 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
@@ -20,13 +20,13 @@ spring:
#redis配置
redis:
#地址
- host: 106.52.49.102
+ host: gz-crs-lv77ii2t.sql.tencentcdb.com
#端口
- port: 6333
+ port: 27714
#数据库
- database: 0
+ database: 2
#密码
- password: Jambox.123*
+ password: Cpop2022@
#连接超时
timeout: 5000
jedis:
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 4512723..3a96599 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
@@ -20,13 +20,13 @@ spring:
#redis配置
redis:
#地址
- host: 106.52.49.102
+ host: gz-crs-lv77ii2t.sql.tencentcdb.com
#端口
- port: 6333
+ port: 27714
#数据库
- database: 10
+ database: 3
#密码
- password: Jambox.123*
+ password: Cpop2022@
#连接超时
timeout: 5000
jedis:
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 ec48db4..cebb22a 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
+ whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/wxCp/*,/wxCp/portal/*/registerCode,/sysCommon/miniSyncBrandAndStore
gateway:
rsa-keypair:
# 公钥文件
@@ -19,13 +19,13 @@ spring:
#redis配置
redis:
#地址
- host: 106.52.49.102
+ host: gz-crs-lv77ii2t.sql.tencentcdb.com
#端口
- port: 6333
+ port: 27714
#数据库
- database: 10
+ database: 1
#密码
- password: Jambox.123*
+ password: Cpop2022@
#连接超时
timeout: 5000
jedis:
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 5bef3e0..f0a0c48 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
+ whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*,/wxCp/*,/wxCp/portal/*/registerCode,/sysCommon/miniSyncBrandAndStore
#拦截
gateway:
rsa-keypair:
@@ -20,13 +20,13 @@ spring:
#redis配置
redis:
#地址
- host: 106.52.49.102
+ host: gz-crs-lv77ii2t.sql.tencentcdb.com
#端口
- port: 6333
+ port: 27714
#数据库
database: 0
#密码
- password: Jambox.123*
+ password: Cpop2022@
#连接超时
timeout: 5000
lettuce:
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 5676351..3a15c64 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/*
+ 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
#拦截
gateway:
rsa-keypair:
@@ -24,13 +24,13 @@ spring:
#redis配置
redis:
#地址
- host: 106.52.49.102
+ host: gz-crs-lv77ii2t.sql.tencentcdb.com
#端口
- port: 6333
+ port: 27714
#数据库
- database: 5
+ database: 1
#密码
- password: Jambox.123*
+ password: Cpop2022@
#连接超时
timeout: 5000
lettuce:
diff --git a/Cpop-Pay/pom.xml b/Cpop-Pay/pom.xml
new file mode 100644
index 0000000..c7a6de5
--- /dev/null
+++ b/Cpop-Pay/pom.xml
@@ -0,0 +1,31 @@
+
+
+ 4.0.0
+
+ com.cpop
+ Cpop-Union
+ 1.0.0
+ ../pom.xml
+
+ Cpop-Pay
+ Cpop-Pay
+ Cpop-Pay
+ jar
+
+ 17
+
+
+
+
+ com.cpop
+ Cpop-Core
+
+
+
+ com.github.binarywang
+ weixin-java-pay
+
+
+
+
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
new file mode 100644
index 0000000..90ab1b8
--- /dev/null
+++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayConfiguration.java
@@ -0,0 +1,50 @@
+package com.cpop.pay.framewok.config.wxPay;
+
+import com.cpop.common.utils.StringUtils;
+import com.github.binarywang.wxpay.config.WxPayConfig;
+import com.github.binarywang.wxpay.service.WxPayService;
+import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author DB
+ * @Description:
+ * @create 2023-10-26 22:38
+ */
+@Getter
+@Configuration
+@ConditionalOnClass(WxPayService.class)
+@EnableConfigurationProperties(WxPayProperties.class)
+@AllArgsConstructor
+public class WxPayConfiguration {
+ private WxPayProperties properties;
+
+ @Bean
+ @ConditionalOnMissingBean
+ public WxPayService wxService() {
+ WxPayConfig payConfig = new WxPayConfig();
+ payConfig.setAppId(StringUtils.trimToNull(this.properties.getAppId()));
+ payConfig.setMchId(StringUtils.trimToNull(this.properties.getMchId()));
+ payConfig.setMchKey(StringUtils.trimToNull(this.properties.getMchKey()));
+ //服务商模式微信支付
+ payConfig.setApiV3Key(this.properties.getApiV3Key());
+ payConfig.setCertSerialNo(this.properties.getCertSerialNo());
+ payConfig.setKeyPath(this.properties.getKeyPath());
+ payConfig.setPrivateKeyPath(this.properties.getPrivateKeyPath());
+ payConfig.setPrivateCertPath(this.properties.getPrivateCertPath());
+ //通知地址
+ payConfig.setNotifyUrl(this.properties.getNotifyUrl());
+ // 可以指定是否使用沙箱环境
+ payConfig.setUseSandboxEnv(false);
+ WxPayService wxPayService = new WxPayServiceImpl();
+ wxPayService.setConfig(payConfig);
+ return wxPayService;
+ }
+
+}
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
new file mode 100644
index 0000000..1c4b100
--- /dev/null
+++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/config/wxPay/WxPayProperties.java
@@ -0,0 +1,78 @@
+package com.cpop.pay.framewok.config.wxPay;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * @author DB
+ * @Description:
+ * @create 2023-10-26 22:39
+ */
+@Data
+@ConfigurationProperties(prefix = "wx.pay")
+public class WxPayProperties {
+ /**
+ * 设置微信公众号或者小程序等的appid
+ */
+ private String appId;
+
+ /**
+ * 微信支付商户号
+ */
+ private String mchId;
+
+ /**
+ * 微信支付商户密钥
+ */
+ private String mchKey;
+
+ /**
+ * apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定
+ */
+ private String keyPath;
+
+ /**
+ * apiV3 秘钥值
+ */
+ private String apiV3Key;
+
+ /**
+ * apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径
+ */
+ private String privateKeyPath;
+
+ /**
+ * apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径
+ */
+ private String privateCertPath;
+
+ /**
+ * apiV3 证书序列号值
+ */
+ private String certSerialNo;
+
+ /**
+ * 支付通知地址
+ */
+ private String notifyUrl;
+
+ /**
+ * 退款通知
+ */
+ private String notifyRefund;
+
+ /**
+ * 分账账号
+ */
+ private String sharingAccount;
+
+ /**
+ * 分账账号名
+ */
+ private String sharingAccountName;
+
+ /**
+ * 分账通知
+ */
+ private String notifySharing;
+}
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
new file mode 100644
index 0000000..7829849
--- /dev/null
+++ b/Cpop-Pay/src/main/java/com/cpop/pay/framewok/handler/wxPay/WxPayHandler.java
@@ -0,0 +1,75 @@
+package com.cpop.pay.framewok.handler.wxPay;
+
+import com.alibaba.fastjson.JSONObject;
+import com.cpop.common.utils.StringUtils;
+import com.cpop.core.base.exception.ServiceException;
+import com.cpop.core.utils.SecurityUtils;
+import com.github.binarywang.wxpay.config.WxPayConfig;
+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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author DB
+ * @createTime 2023/10/27 15:47
+ * @description
+ */
+@Component
+public class WxPayHandler {
+
+ @Autowired
+ private WxPayService wxPayService;
+
+ /**
+ * @descriptions 获取微信支付service
+ * @author DB
+ * @date 2023/10/27 15:53
+ * @return: com.github.binarywang.wxpay.service.WxPayService
+ */
+ public WxPayService getWxPayService(){
+ //查询当前登陆用户所在品牌的商户id
+ JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo();
+ if (loginUserInfo == null) {
+ //直接返回
+ return wxPayService;
+ }
+ String brandId = loginUserInfo.getString("brandId");
+ Row brand = Db.selectOneByQuery("cp_sys_brand", QueryWrapper.create().where("id = ?", brandId));
+ if (brand.isEmpty()) {
+ throw new ServiceException("当前品牌暂未开通微信支付,请联系相关客服");
+ }
+ //检查是否开启分账
+ if (!brand.getBoolean("isOpenSharing")) {
+ throw new ServiceException("当前商户暂未开启分账,请联系相关客服");
+ }
+ WxPayConfig payConfig = wxPayService.getConfig();
+ //子商户信息
+ payConfig.setSubMchId(StringUtils.trimToNull(brand.getString("wxMchId")));
+ // 可以指定是否使用沙箱环境
+ payConfig.setUseSandboxEnv(false);
+ wxPayService.setConfig(payConfig);
+ return wxPayService;
+ }
+
+ /**
+ * @descriptions 根据商户appid或商户号获取对应微信支付接口
+ * @author DB
+ * @date 2023/10/18 10:34
+ * @param subAppId 子商户appid
+ * @param subMchId 子商户id
+ * @return: com.github.binarywang.wxpay.service.WxPayService
+ */
+ public WxPayService getWxPayService(String subAppId, String subMchId) {
+ WxPayConfig payConfig = wxPayService.getConfig();
+ //子商户信息
+ payConfig.setSubAppId(StringUtils.trimToNull(subAppId));
+ payConfig.setSubMchId(StringUtils.trimToNull(subMchId));
+ // 可以指定是否使用沙箱环境
+ payConfig.setUseSandboxEnv(false);
+ wxPayService.setConfig(payConfig);
+ return wxPayService;
+ }
+}
diff --git a/Cpop-Pay/src/main/resources/application-pay.yml b/Cpop-Pay/src/main/resources/application-pay.yml
new file mode 100644
index 0000000..c5f1be7
--- /dev/null
+++ b/Cpop-Pay/src/main/resources/application-pay.yml
@@ -0,0 +1,13 @@
+wx:
+ #微信支付
+ pay:
+ #微信公众号或者小程序等的appid
+ appId: wx20853d18c455e874
+ #微信支付商户号
+ mchId: 1618884922
+ #微信支付商户密钥
+ mchKey: JamBox20230919174000000000000002
+ apiV3Key: JamBox20230919174000000000000002
+ #分账服务商账号
+ sharingAccount: 1618884922
+ sharingAccountName: 果酱盒子
diff --git a/Cpop-System/src/main/java/com/cpop/system/business/bo/SyncBrandAndStoreBo.java b/Cpop-System/src/main/java/com/cpop/system/business/bo/SyncBrandAndStoreBo.java
new file mode 100644
index 0000000..9c79a88
--- /dev/null
+++ b/Cpop-System/src/main/java/com/cpop/system/business/bo/SyncBrandAndStoreBo.java
@@ -0,0 +1,122 @@
+package com.cpop.system.business.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.sql.Date;
+
+/**
+ * @author DB
+ * @version 1.0.0
+ * @since 2023-12-21 14:46
+ */
+@Data
+@ApiModel(value = "品牌与校区参数")
+public class SyncBrandAndStoreBo {
+
+ /**
+ * 品牌
+ */
+ @ApiModelProperty(value = "品牌")
+ private BrandInfo brandInfo;
+
+ /**
+ * 校区
+ */
+ @ApiModelProperty(value = "校区")
+ private StoreInfo storeInfo;
+
+
+ /**
+ * 品牌信息
+ */
+ @Data
+ public static class BrandInfo {
+
+ /**
+ * 云品牌id
+ */
+ @ApiModelProperty(value = "云品牌id")
+ private String brandCloudId;
+
+ /**
+ * 品牌名
+ */
+ @ApiModelProperty(value = "品牌名")
+ private String brandName;
+ }
+
+ /**
+ * 校区信息
+ */
+ @Data
+ public static 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;
+ }
+}
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 a3da6d4..e123bf1 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
@@ -6,6 +6,8 @@ import com.cpop.core.config.ServerConfig;
import com.cpop.core.handler.TencentCosHandler;
import com.cpop.core.utils.file.FileUploadUtils;
import com.cpop.core.utils.file.FileUtils;
+import com.cpop.system.business.bo.SyncBrandAndStoreBo;
+import com.cpop.system.business.service.StoreService;
import com.cpop.system.business.vo.SysFileVo;
import com.qcloud.cos.model.UploadResult;
import io.swagger.annotations.Api;
@@ -13,6 +15,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@@ -37,6 +40,9 @@ public class SysCommonController {
@Autowired
private TencentCosHandler tencentCosHandler;
+ @Autowired
+ private StoreService storeService;
+
/**
* 通用上传请求(单个)
*/
@@ -82,4 +88,18 @@ public class SysCommonController {
.setOriginalFilename(file.getOriginalFilename());
return R.ok(sysFileVo);
}
+
+ /**
+ * 小程序同步品牌和校区
+ * @author DB
+ * @since 2023/12/21
+ * @param bo 请求参数
+ * @return R
+ */
+ @ApiOperation("小程序同步品牌和校区")
+ @PostMapping("/miniSyncBrandAndStore")
+ public R miniSyncBrandAndStore(@RequestBody SyncBrandAndStoreBo bo) {
+ storeService.miniSyncBrandAndStore(bo);
+ return R.ok();
+ }
}
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 f75a4e0..b23e2a0 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,6 +1,7 @@
package com.cpop.system.business.service;
import com.cpop.system.business.bo.StorePageBo;
+import com.cpop.system.business.bo.SyncBrandAndStoreBo;
import com.cpop.system.business.vo.StorePageVo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
@@ -21,4 +22,12 @@ public interface StoreService extends IService {
* @return {*}
*/
Page getStorePage(StorePageBo bo);
+
+ /**
+ * 小程序同步品牌和校区
+ * @author DB
+ * @since 2023/12/21
+ * @param bo 请求参数
+ */
+ void miniSyncBrandAndStore(SyncBrandAndStoreBo bo);
}
diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreServiceImpl.java b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreServiceImpl.java
index 727410d..e40abfb 100644
--- a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreServiceImpl.java
+++ b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/StoreServiceImpl.java
@@ -7,17 +7,34 @@
*/
package com.cpop.system.business.service.impl;
+import com.cpop.common.utils.bean.BeanUtils;
+import com.cpop.core.base.entity.LoginUser;
import com.cpop.core.base.entity.PageDomain;
+import com.cpop.core.base.enums.SourceType;
+import com.cpop.core.utils.SecurityUtils;
+import com.cpop.core.utils.SpringUtils;
import com.cpop.core.utils.sql.SqlUtils;
import com.cpop.system.business.bo.StorePageBo;
+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.mapper.StoreMapper;
+import com.cpop.system.business.service.BrandService;
+import com.cpop.system.business.service.StoreLicenseService;
import com.cpop.system.business.service.StoreService;
import com.cpop.system.business.vo.StorePageVo;
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.RowKey;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
-import com.mybatisflex.core.query.QueryWrapper;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
import static com.cpop.system.business.entity.table.BrandTableDef.BRAND;
import static com.cpop.system.business.entity.table.StoreSignTableDef.STORE_SIGN;
@@ -52,4 +69,57 @@ public class StoreServiceImpl extends ServiceImpl implements
.and(STORE.STORE_NAME.like(bo.getName())),
StorePageVo.class);
}
+
+ /**
+ * 小程序同步品牌和校区
+ * @author DB
+ * @since 2023/12/21
+ * @param bo 请求参数
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void miniSyncBrandAndStore(SyncBrandAndStoreBo bo) {
+ SyncBrandAndStoreBo.BrandInfo brandInfo = bo.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.getName());
+ 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"));
+ }
+ Store store = BeanUtils.mapToClass(bo.getStoreInfo(), Store.class);
+ store.setBrandId(brand.getId()).setSourceType(SourceType.JAMBOX.getName());
+ this.save(store);
+ //拓展
+ SyncBrandAndStoreBo.StoreInfo storeInfo = bo.getStoreInfo();
+ 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(bo.getStoreInfo(), StoreLicense.class);
+ storeLicense.setStoreId(store.getId());
+ SpringUtils.getBean(StoreLicenseService.class).save(storeLicense);
+ }
}
diff --git a/pom.xml b/pom.xml
index 75fbe35..5f89b99 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,7 @@
Cpop-Mall/Cpop-Mall-Web
Cpop-System
Cpop-Mini
+ Cpop-Pay
@@ -125,6 +126,11 @@
Cpop-Mini
${cpop.version}
+
+ com.cpop
+ Cpop-Pay
+ ${cpop.version}
+
com.zaxxer