事务添加绑定;课卡模板调整;个人任务调整

This commit is contained in:
DB 2024-01-22 22:28:27 +08:00
parent 75ae708242
commit 0abc786b1d
23 changed files with 590 additions and 229 deletions

View File

@ -162,7 +162,7 @@ public class CloudClassCardDto {
/**
* 每期课次
*/
private Integer classHour;
private String classHour;
/**
* 签约计划详情,json格式

View File

@ -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("操作失败!");
}
}
}

View File

@ -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;
/**
* 卡号
*/

View File

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

View File

@ -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<Void>
*/
@ApiOperation(value = "获取模板信息")
@GetMapping("/getCardTemplateInfo")
public R<CardTemplateInfoVo> 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);
}
}

View File

@ -42,9 +42,10 @@ public class MiniEasyLearnController {
*/
@ApiOperation("获取支付分计划")
@GetMapping("/getWxPayScorePlan")
public R<LearnNowPayLaterPlanVo> getWxPayScorePlan(@ApiParam(value = "旧模板id", required = true) @RequestParam("oldTemplateId") String oldTemplateId,
public R<LearnNowPayLaterPlanVo> 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, isMonth);
LearnNowPayLaterPlanVo vo = cardTemplateService.getWxPayScorePlan(oldTemplateId, templateId, isMonth);
return R.ok(vo);
}

View File

@ -104,6 +104,11 @@ public class EasyLearnOrder extends BaseEntity implements Serializable {
*/
private Double rate;
/**
* 模板id
*/
private String templateId;
/**
* 逻辑删除0否1是
*/

View File

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

View File

@ -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<CardTemplateMapper, Car
* @return LearnNowPayLaterPlanDetailVo
*/
@Override
public LearnNowPayLaterPlanVo getWxPayScorePlan(String oldTemplateId, Boolean isMonth) {
CardTemplate cardTemplate = this.queryChain().where(CARD_TEMPLATE.OLD_TEMPLATE_ID.eq(oldTemplateId)).one();
public LearnNowPayLaterPlanVo getWxPayScorePlan(String oldTemplateId,String templateId, Boolean isMonth) {
CardTemplate cardTemplate;
if (StringUtils.isNotBlank(templateId)) {
cardTemplate = this.queryChain().where(CARD_TEMPLATE.OLD_TEMPLATE_ID.eq(oldTemplateId)).one();
} else {
cardTemplate = this.queryChain().where(CARD_TEMPLATE.ID.eq(templateId)).one();
}
CardTemplateExtendService cardTemplateExtendService = SpringUtils.getBean(CardTemplateExtendService.class);
CardTemplateExtend cardTemplateExtend = cardTemplateExtendService.getOne(QueryWrapper.create()
.where(CARD_TEMPLATE_EXTEND.TEMPLATE_ID.eq(cardTemplate.getId()))
@ -299,4 +305,30 @@ public class CardTemplateServiceImpl extends ServiceImpl<CardTemplateMapper, Car
return vo;
}
/**
* 获取模板信息
* @author DB
* @since 2024/1/22
* @param id 主键
*/
@Override
public CardTemplateInfoVo getCardTemplateInfo(String id, String oldTemplateId) {
//TODO: 模板详情信息调整
CardTemplateInfoVo vo;
if (StringUtils.isNotBlank(id)) {
vo = this.getOneAs(QueryWrapper.create().where(CARD_TEMPLATE.ID.eq(id))
, CardTemplateInfoVo.class);
} else {
vo = this.getOneAs(QueryWrapper.create().where(CARD_TEMPLATE.OLD_TEMPLATE_ID.eq(oldTemplateId))
, CardTemplateInfoVo.class);
}
//获取模板拓展
List<Integer> 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;
}
}

View File

@ -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,6 +681,12 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
@Override
@Transactional(rollbackFor = Exception.class)
public WxPartnerPayScoreUserSignPlanResult createUserSignPlans(LearnNowPayLaterUserSignPlansBo bo) {
//分布式锁进行幂等处理
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());
//获取计划详情
@ -706,6 +714,15 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
} catch (WxPayException e) {
throw new ServiceException(e.getMessage());
}
} finally {
//释放锁
userIdLock.unlock();
}
} else {
//获取锁失败直接返回空
throw new ServiceException("请勿重复提交");
}
}
/**
@ -726,11 +743,18 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
.setTotalAmount(new BigDecimal(wxPayScore.getTotalOriginalPrice()).divide(BigDecimal.valueOf(100)))
.setTotalPayAmount(BigDecimal.ZERO)
.setOrderType(0)
.setRate(OrderSource.LEARN_NOW_PAY_LATER.getRate());
.setRate(OrderSource.LEARN_NOW_PAY_LATER.getRate())
.setTemplateId(bo.getTemplateId() == null ? bo.getOldTemplateId() : bo.getTemplateId());
this.save(easyLearnOrder);
return easyLearnOrder.getId();
}
private final String LOCAL_TEMPLATE_URL = "http://localhost:9420/Cpop-Oam/";
private final String TEST_TEMPLATE_URL = "https://test.cpopsz.com/oam/Cpop-Oam/";
private final String PROD_TEMPLATE_URL = "https://oam.jamboxsys.com/Cpop-Oam/";
/**
* 用户签约成功回调
* @author DB
@ -780,17 +804,18 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
SpringUtils.getBean(EasyLearnOrderExtendService.class).save(orderExtend);
//云办卡
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/");
if (StringUtils.equals("prod", SpringUtils.getActiveProfile())) {
dto.setTemplateUrl(PROD_TEMPLATE_URL);
} else if (StringUtils.equals("test", SpringUtils.getActiveProfile())){
dto.setTemplateUrl(TEST_TEMPLATE_URL);
} else {
dto.setTemplateUrl(LOCAL_TEMPLATE_URL);
}
// 办卡
dto.setOpenId(result.getSubOpenid());
dto.setMerchantSignPlanNo(result.getMerchantSignPlanNo());
dto.setSignPlanId(result.getSignPlanId());
//TODO: 模板id
//dto.setOrderCloudId(easyLearnOrder);
dto.setOrderCloudId(easyLearnOrder.getTemplateId());
StoreExtend storeExtend = SpringUtils.getBean(StoreExtendService.class).queryChain()
.where(STORE_EXTEND.STORE_ID.eq(easyLearnOrder.getStoreId()))
.one();
@ -799,7 +824,12 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
dto.setCustomerName(easyLearnOrder.getCustomerName());
dto.setPlanId(result.getPlanId());
dto.setSignPlanDetails(JSONArray.toJSONString(result.getSignedDetailList()));
//TODO: 课次
//获取计划
Row payScorePlan = DbChain.table(WX_PAY_SCORE.getTableName()).select(WX_PAY_SCORE.CLASS_HOUR).where(WX_PAY_SCORE.OUT_PLAN_ID.eq(result.getPlanId())).one();
//获取支付分
if (payScorePlan != null && StringUtils.isNotBlank(payScorePlan.getString("classHour"))) {
dto.setClassHour(payScorePlan.getString("classHour"));
}
String cloudCardId = SpringUtils.getBean(CloudClassCardHandler.class).insertCloudClassCard(dto);
easyLearnOrder.setProductId(cloudCardId);
this.updateById(easyLearnOrder);
@ -813,7 +843,11 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
.where(EASY_LEARN_ORDER_DETAIL.ORDER_ID.eq(easyLearnOrder.getId()))
.and(EASY_LEARN_ORDER_DETAIL.DETAIL_STATUS.eq(0))
.update();
//TODO: 通知波哥取消课卡
//通知波哥取消课卡
CloudClassCardDto cloudClassCardDto = new CloudClassCardDto();
cloudClassCardDto.setSignPlanId(result.getSignPlanId());
cloudClassCardDto.setMerchantSignPlanNo(result.getMerchantSignPlanNo());
SpringUtils.getBean(CloudClassCardHandler.class).refundCloudClassCard(cloudClassCardDto);
}
} catch (WxPayException e) {
throw new ServiceException(e.getMessage());
@ -830,6 +864,12 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
@Override
@Transactional(rollbackFor = Exception.class)
public WxPartnerPayScoreSignPlanResult createServiceOrder(LearnNowPayLaterServiceOrderBo bo) {
//分布式锁进行幂等处理
RedisService redisService = SpringUtils.getBean(RedisService.class);
//分布式锁进行幂等处理
Lock userIdLock = redisService.distributedLock(JamboxRedisConstant.LEARN_NOW_PAY_LATER_SERVICE_ORDER_LOCK_USER_PAY + bo.getSignPlanId());
if (userIdLock.tryLock()) {
try {
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()
@ -856,8 +896,7 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
timeRange.setStartTime(startTime);
String endTime = now.plusSeconds(60).format(yyyyMMddHHmmss);
timeRange.setEndTime(endTime);
signPlanRequest.setTimeRange(timeRange)
.setOutOrderNo(easyLearnOrderDetail.getId());
signPlanRequest.setTimeRange(timeRange).setOutOrderNo(easyLearnOrderDetail.getId());
easyLearnOrderDetail.setDetailStatus(1);
easyLearnOrderDetailService.updateById(easyLearnOrderDetail);
try {
@ -865,6 +904,14 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
} catch (WxPayException e) {
throw new ServiceException(e.getMessage());
}
} finally {
//释放锁
userIdLock.unlock();
}
} else {
//获取锁失败直接返回空
throw new ServiceException("请勿重复提交");
}
}
/**
@ -925,7 +972,15 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
.where(EASY_LEARN_ORDER_DETAIL.ORDER_ID.eq(easyLearnOrder.getId()))
.and(EASY_LEARN_ORDER_DETAIL.DETAIL_STATUS.eq(0))
.update();
//TODO: 通知波哥取消课卡
//获取拓展信息
EasyLearnOrderExtend easyLearnOrderExtend = SpringUtils.getBean(EasyLearnOrderExtendService.class).queryChain()
.where(EASY_LEARN_ORDER_EXTEND.ORDER_ID.eq(easyLearnOrder.getId()))
.one();
//通知波哥取消课卡
CloudClassCardDto cloudClassCardDto = new CloudClassCardDto();
cloudClassCardDto.setSignPlanId(easyLearnOrderExtend.getSignPlanId());
cloudClassCardDto.setMerchantSignPlanNo(easyLearnOrder.getId());
SpringUtils.getBean(CloudClassCardHandler.class).refundCloudClassCard(cloudClassCardDto);
} catch (WxPayException e) {
throw new ServiceException(e.getMessage());
}

View File

@ -0,0 +1,135 @@
package com.cpop.jambox.business.vo;
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.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
/**
* @author DB
* @version 1.0.0
* @since 2024-01-22 10:40
*/
@Data
@Accessors(chain = true)
@ApiModel("课卡模板信息")
public class CardTemplateInfoVo {
/**
* 主键
*/
@ApiModelProperty(value = "主键")
private String id;
/**
* 旧课卡模板id
*/
@ApiModelProperty(value = "旧课卡模板id")
private String oldTemplateId;
/**
* 云品牌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 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:线下支付;5:先学后付月付;)
*/
@NotEmpty(message = "支付类型不能为空")
@ApiModelProperty(value = "支付类型(0:微信支付;1:先学后付次付;2:旧放心学合约支付;3:数字人民币支付;4:线下支付;5:先学后付月付;)")
private List<Integer> payType;
/**
* 是否是会员(0否1是)
*/
@ApiModelProperty(value = "是否是会员(0否1是)")
private Boolean isMember;
/**
* 是否是引流卡
*/
@ApiModelProperty(value = "是否是引流卡(0否1是)")
private Boolean isDrainage;
/**
* 二维码
*/
@ApiModelProperty(value = "二维码")
private String qrCode;
}

View File

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

View File

@ -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<StoreSign> list = SpringUtils.getBean(StoreSignService.class).list();
List<Store> 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);
}
}

View File

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

View File

@ -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<Page<StorePoolPageVo>>
*/
@ApiOperation("查询未签约校区分页列表")
@GetMapping("/getUnSignStorePage")
public R<Page<BusinessUnSignPageVo>> getUnSignStorePage(@ApiParam("查询参数") @RequestParam(value = "params", required = false) String params) {
Page<BusinessUnSignPageVo> pageVo = businessService.getUnSignStorePage(params);
return R.ok(pageVo);
}
/**
* 校区签约
* @author DB
* @since 2024/1/22
* @param id 校区id
* @return R<Void>
*/
@ApiOperation("校区签约")
@PutMapping("/storeSign")
public R<Void> storeSign(@ApiParam(value = "校区id", required = true) @RequestParam(value = "id") String id) {
businessService.storeSign(id);
return R.ok();
}
}

View File

@ -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<Business> {
* @return PersonBusinessInfoVo
*/
PersonBusinessInfoVo getPersonBusinessInfoById(String id);
/**
* 查询未签约校区分页列表
* @author DB
* @since 2024/1/22
* @param params 请求参数
* @return Page<BusinessUnSignPageVo>
*/
Page<BusinessUnSignPageVo> getUnSignStorePage(String params);
/**
* 校区签约
* @author DB
* @since 2024/1/22
* @param id 主键
*/
void storeSign(String id);
}

View File

@ -83,7 +83,8 @@ public class BrandManagerServiceImpl extends ServiceImpl<BrandManagerMapper, Bra
.and(BRAND_MANAGER.PHONE.like(bo.getPhoneNumber()))
.and(BRAND_MANAGER.NAME.like(bo.getName()))
.and(BRAND.BRAND_NAME.like(bo.getBrandName()))
.groupBy(BRAND_MANAGER.ID),
.groupBy(BRAND_MANAGER.ID)
.orderBy(BRAND_MANAGER.CREATE_TIME.desc()),
BrandManagePageVo.class);
}

View File

@ -26,6 +26,7 @@ import com.cpop.oam.business.service.BusinessService;
import com.cpop.oam.business.service.BusinessStaffService;
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.cpop.system.business.bo.StoreRenewBo;
import com.cpop.system.business.entity.Store;
@ -49,6 +50,8 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND;
import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND;
import static com.cpop.oam.business.entity.table.BusinessDetailTableDef.BUSINESS_DETAIL;
import static com.cpop.oam.business.entity.table.BusinessStaffTableDef.BUSINESS_STAFF;
import static com.cpop.oam.business.entity.table.BusinessTableDef.BUSINESS;
@ -112,42 +115,12 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> 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<Integer> flag = new AtomicReference<>(0);
if (bo.getSign().isEmpty()){
throw new ServiceException("签约人不能为空");
}
List<BusinessStaff> 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<BusinessMapper, Business> i
*/
@Override
public Page<BusinessInfoPageVo> 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<BusinessInfoPageVo>
*/
private Page<BusinessInfoPageVo> 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);
}
/**
@ -382,18 +294,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> 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<BusinessMapper, Business> i
.and(BUSINESS_STAFF.STAFF_ID.eq(loginUserInfo.getString("id"))),
PersonBusinessInfoVo.class);
}
/**
* 查询未签约校区分页列表
* @author DB
* @since 2024/1/22
* @param params 请求参数
* @return Page<BusinessUnSignPageVo>
*/
@Override
public Page<BusinessUnSignPageVo> 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);
}
}

View File

@ -353,27 +353,34 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> 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(),

View File

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

View File

@ -92,6 +92,11 @@ public class Store extends BaseEntity implements Serializable {
*/
private String latitude;
/**
* 签约id
*/
private String signId;
/**
* 逻辑删除0否1是
*/

View File

@ -39,4 +39,5 @@ public interface StoreService extends IService<Store> {
* @param bo 请求参数
*/
void updateStore(StoreBo bo);
}