集成微信支付;修订商城jedis连接池;添加临时白名单;商城轮播图;课卡模板拓展;数据导入为空检查;同步校区检查;微信支付添加支付分服务

This commit is contained in:
DB 2024-01-18 22:10:36 +08:00
parent d87cd066de
commit 37d2f50b33
34 changed files with 561 additions and 105 deletions

View File

@ -123,11 +123,11 @@ public class CloudCourseStudentDto {
* 扣除课卡名
*/
@SerializedName("periodName")
private String cardName;
private String deductionCardName;
/**
* 状态操作时间
*/
@SerializedName("_createTime")
private String createTime;
private String entryTime;
}

View File

@ -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_";
/**
* 主入口

View File

@ -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<Integer> 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;
/**
* 先学后付支付
*/

View File

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

View File

@ -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<String> insertCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) {
String templateId = cardTemplateService.insertCardTemplateUnion(bo);
return R.ok(templateId);
public R<Validated> insertCardTemplateUnion(@RequestBody @Validated CardTemplateUnionBo bo) {
cardTemplateService.insertCardTemplateUnion(bo);
return R.ok();
}
}

View File

@ -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是)
*/

View File

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

View File

@ -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<CardTemplateExtend> {
}

View File

@ -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<CardTemplateExtend> {
}

View File

@ -33,5 +33,5 @@ public interface CardTemplateService extends IService<CardTemplate> {
* @param bo 请求参数
* @return String 旧模板id
*/
String insertCardTemplateUnion(CardTemplateUnionBo bo);
void insertCardTemplateUnion(CardTemplateUnionBo bo);
}

View File

@ -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<CardTemplateExtendMapper, CardTemplateExtend> implements CardTemplateExtendService {
}

View File

@ -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<CardTemplateMapper, Car
* @return String 旧模板id
*/
@Override
public String insertCardTemplateUnion(CardTemplateUnionBo bo) {
@Transactional(rollbackFor = Exception.class)
public void insertCardTemplateUnion(CardTemplateUnionBo bo) {
CardTemplate cardTemplate = BeanUtils.mapToClass(bo, CardTemplate.class);
//品牌
if (StringUtils.isNotBlank(bo.getBrandCloudId())){
@ -82,7 +91,24 @@ public class CardTemplateServiceImpl extends ServiceImpl<CardTemplateMapper, Car
Store store = SpringUtils.getBean(StoreService.class).getById(storeExtend.getStoreId());
cardTemplate.setStoreId(store.getId()).setBrandId(store.getBrandId());
}
return null;
this.save(cardTemplate);
List<CardTemplateExtend> 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);
}
}
}

View File

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

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cpop.jambox.business.mapper.CardTemplateExtendMapper">
</mapper>

View File

@ -38,6 +38,7 @@ spring:
max-active: 8
#
max-wait: -1ms
client-type: jedis
data:
mongodb:
host: localhost

View File

@ -38,6 +38,7 @@ spring:
max-active: 8
#
max-wait: -1ms
client-type: jedis
data:
mongodb:
host: localhost

View File

@ -39,6 +39,7 @@ spring:
max-active: 8
#
max-wait: -1ms
client-type: jedis
data:
mongodb:
host: localhost

View File

@ -39,6 +39,7 @@ spring:
max-active: 8
#
max-wait: -1ms
client-type: jedis
data:
mongodb:
host: localhost

View File

@ -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<List<ProductSimpleVo>> getUpProductList(@ApiParam("品牌id") @RequestParam(value = "brandId", required = false) String brandId) {
public R<List<ProductSimpleVo>> getUpProductList() {
JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo();
List<ProductSimpleVo> 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);

View File

@ -87,6 +87,7 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
profitSharingReturnRequest.setDescription("分账退款");
profitSharingReturnRequest.setSubMchId(profitSharing.getPayAccount());
profitSharingReturnRequest.setReturnAccount(wxPayProperties.getSharingAccount());
profitSharingReturnRequest.setReturnAccountType("MERCHANT_ID");
profitSharingReturnRequest.setReturnAmount(profitSharing.getAmount().intValue());
wxPayService.getProfitSharingService().profitSharingReturn(profitSharingReturnRequest);
//分账退款记录设置退款

View File

@ -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/*
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
gateway:
rsa-keypair:
# 公钥文件

View File

@ -31,7 +31,7 @@ spring:
max-file-size: 1024MB
max-request-size: 300MB
profiles:
active: dev,core,jambox
active: dev,core,jambox,pay
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
@ -158,18 +158,7 @@ wx:
componentToken: jambox
componentAesKey: 1a3NBxmCFwkCJvfoQ7WhJHB6iX3qHPsc9JbaDznE1i0
redirectUri: https://empower.oamapi.cpopsz.com/test/openPlatform/thirdPartyPlatform/redirectUrl
#微信支付
pay:
#微信公众号或者小程序等的appid
appId: wx20853d18c455e874
#微信支付商户号
mchId: 1618884922
#微信支付商户密钥
mchKey: JamBox20230919174000000000000002
apiV3Key: JamBox20230919174000000000000002
#分账服务商账号
sharingAccount: 1618884922
sharingAccountName: 果酱盒子
#小程序
miniapp:
configs:
#微信小程序的appid

View File

@ -1,31 +1,52 @@
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.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.jambox.business.entity.*;
import com.cpop.jambox.business.service.*;
import com.cpop.oam.business.service.StaffService;
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.StoreSignMapper;
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;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER;
import static com.cpop.oam.business.entity.table.StaffTableDef.STAFF;
import static com.cpop.system.business.entity.table.StoreSignTableDef.STORE_SIGN;
import static com.mybatisflex.core.query.QueryMethods.count;
import static com.mybatisflex.core.query.QueryMethods.max;
/**
* @author DB
* @version 1.0.0
* @since 2024-01-16 17:17
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles(profiles = {"prod", "core"})
public class CpopDataSyncTests {
/**
@ -59,4 +80,192 @@ public class CpopDataSyncTests {
List<Store> 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<Row> 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<String, WxPayScore> wxPayScoreMap = SpringUtils.getBean(WxPayScoreService.class).list().stream().collect(Collectors.toMap(WxPayScore::getOutPlanId, item -> item));
Map<String, String> brandMap = SpringUtils.getBean(BrandExtendService.class).list().stream().collect(Collectors.toMap(BrandExtend::getBrandCloudId, BrandExtend::getBrandId));
Map<String, String> storeMap = SpringUtils.getBean(StoreExtendService.class).list().stream().collect(Collectors.toMap(StoreExtend::getStoreCloudId, StoreExtend::getStoreId));
List<CardTemplateExtend> 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<String> 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<CardTemplate> entityList = RowUtil.toEntityList(rowList, CardTemplate.class);
SpringUtils.getBean(CardTemplateService.class).saveBatch(entityList);
Map<String, String> 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<CardTemplateExtend> cardTemplateExtends,Row row,Map<String, WxPayScore> 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<Row> 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<String, String> 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<String, String> 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<StoreSign> 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<StoreSign> 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, ""));
}
}

View File

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

View File

@ -47,6 +47,10 @@ public class TaskAuditCommentsBo {
@ApiModelProperty("任务权重(任务绩点)")
private Integer taskWeight;
public void setTaskWeight(String taskWeight) {
this.taskWeight = Integer.parseInt(taskWeight.split(",")[0]);
}
/**
* 备注(不通过时可以写入备注)
*/

View File

@ -393,7 +393,6 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
storeSign.setSignStaffId(loginUserInfo.getString("id"));
storeSignService.save(storeSign);
}
}
}
}

View File

@ -225,6 +225,9 @@ public class DataImportServiceImpl extends ServiceImpl<DataImportMapper, DataImp
}
}
}).sheet().doRead();
if (cachedDataList.isEmpty()){
throw new ServiceException("导入数据为空,请检查文件内容,按照模板格式导入");
}
tempFile = File.createTempFile(fileName, ".xlsx");
log.info("文件名:{};临时文件地址: {}", fileName, tempFile.getPath());
EasyExcel.write(tempFile.getPath(), DataImportDto.class)

View File

@ -27,6 +27,10 @@ import com.cpop.oam.business.vo.*;
import com.cpop.oam.framework.constant.OamConfigKey;
import com.cpop.oam.framework.constant.WebHookKeyConstant;
import com.cpop.oam.framework.enums.OamConfigEnum;
import com.cpop.system.business.entity.DictData;
import com.cpop.system.business.service.DictDataService;
import com.cpop.system.business.service.DictTypeService;
import com.cpop.system.framework.utils.DictUtils;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Db;
@ -225,6 +229,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
}
}
/**
* 任务评级
*/
private final String OAM_TASK_RATING = "oam_task_rating";
/**
* 技术模块-任务领取-技术人员领取任务
*
@ -244,32 +253,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> 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();

View File

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

View File

@ -81,4 +81,8 @@ public class WxPayProperties {
*/
private String easyLearnUnionPayNotifyUrl;
/**
* 服务id
*/
private String serviceId;
}

View File

@ -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: 果酱盒子

View File

@ -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<StoreRenewMapper, StoreRe
JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo();
storeRenew.setRenewStaffId(loginUserInfo.getString("id"));
this.save(storeRenew);
SpringUtils.getBean(StoreService.class).updateChain()
.set(STORE.HAVE_ACTIVE, true)
.where(STORE.ID.eq(bo.getStoreId()))
.update();
//修改校区签约到期时间
SpringUtils.getBean(StoreSignService.class).updateChain()
.set(STORE_SIGN.EXPIRE_DATE, storeRenew.getRenewDate())
@ -95,11 +102,18 @@ public class StoreRenewServiceImpl extends ServiceImpl<StoreRenewMapper, StoreRe
.where("deleted = 1")
.and("store_id = ?", storeExtend.getString("storeCloudId"))
.update();
//TODO: 添加到旧库`t_signContract_mechanism_reason`
//添加到旧库`t_signContract_mechanism_reason`
LocalDateTime now = LocalDateTime.now();
Row row = Row.ofKey("reason_id", RowKey.AUTO);
row.set("store_id", storeExtend.getString("storeCloudId"));
row.set("reason", storeRenew.getRenewDesc());
row.set("pic_url",storeRenew.getAnnexUrl());
row.set("pic_url", storeRenew.getAnnexUrl());
row.set("end_time", storeRenew.getRenewDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
row.set("deleted", 1);
row.set("creation_time", now);
row.set("creation_by", loginUserInfo.getString("id"));
row.set("last_modification_date", now);
row.set("last_modified", loginUserInfo.getString("id"));
} finally {
DataSourceKey.clear();
}

View File

@ -92,7 +92,7 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> 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<StoreMapper, Store> 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);

View File

@ -19,6 +19,7 @@ import java.util.stream.Collectors;
/**
* 字典工具类
* @author Lost
*/
public class DictUtils {
/**