先学后付调整代码提交

This commit is contained in:
DB 2024-01-19 09:08:58 +08:00
parent 37d2f50b33
commit 04b930504d
9 changed files with 308 additions and 28 deletions

View File

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

View File

@ -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<LearnNowPayLaterPlanDetailVo>
*/
@ApiOperation("获取支付分计划")
@GetMapping("/getWxPayScorePlan")
public R<LearnNowPayLaterPlanDetailVo> 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<LearnNowPayLaterPlanDetailVo>
*/
@ApiOperation("创建用户签约计划")
@PostMapping("/createUserSignPlans")
public R<Void> 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<Void> createServiceOrder() {
return R.ok();
}
}

View File

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

View File

@ -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<CardTemplateMapper, Car
List<CardTemplateExtend> 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<CardTemplateMapper, Car
}
}
/**
* 修改课卡模板(整合)
* @author DB
* @since 2024/1/18
* @param bo 请求参数
*/
@Override
public void updateCardTemplateUnion(CardTemplateUnionBo bo) {
CardTemplate cardTemplate = BeanUtils.mapToClass(bo, CardTemplate.class);
this.update(cardTemplate, QueryWrapper.create().where(CARD_TEMPLATE.OLD_TEMPLATE_ID.eq(bo.getOldTemplateId())));
CardTemplateExtendService cardTemplateExtendService = SpringUtils.getBean(CardTemplateExtendService.class);
List<CardTemplateExtend> cardTemplateExtends = cardTemplateExtendService.list(QueryWrapper.create()
.where(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(bo.getOldTemplateId())));
//添加课卡模板拓展
List<Integer> filterPayType = bo.getPayType().stream().filter(item -> item != 1 && item != 5).collect(Collectors.toList());
//TODO: 新增或修改模板拓展
//次付
List<Integer> 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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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