添加拼团分账订单

This commit is contained in:
DB 2024-05-27 10:39:51 +08:00
parent b3346765e4
commit e1cfa8e6bb
8 changed files with 235 additions and 107 deletions

View File

@ -116,6 +116,4 @@ public class WebsiteController {
return websiteService.getDevelopmentCourse(); return websiteService.getDevelopmentCourse();
} }
} }

View File

@ -46,6 +46,11 @@ public class EasyLearnOrderDetail extends BaseEntity implements Serializable {
*/ */
private String outOrderNo; private String outOrderNo;
/**
* 外部订单号
*/
private String transactionId;
/** /**
* 期号 * 期号
*/ */

View File

@ -61,7 +61,7 @@ mybatis-flex:
username: root username: root
password: Customer0401 password: Customer0401
jambox: jambox:
url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/jambox_association?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/jambox_association?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: Customer0401 password: Customer0401

View File

@ -4,7 +4,13 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cpop.api.cloudDb.core.constant.CloudDbUrl; import com.cpop.api.cloudDb.core.constant.CloudDbUrl;
import com.cpop.core.utils.SpringUtils; import com.cpop.core.utils.SpringUtils;
import com.cpop.jambox.business.entity.BrandExtend;
import com.cpop.jambox.business.entity.StoreExtend;
import com.cpop.jambox.business.service.BrandExtendService;
import com.cpop.jambox.business.service.StoreExtendService;
import com.cpop.pay.framewok.handler.wxPay.WxPayHandler; import com.cpop.pay.framewok.handler.wxPay.WxPayHandler;
import com.cpop.system.business.entity.Store;
import com.cpop.system.business.service.StoreService;
import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult; import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult;
import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.service.WxPayService;
@ -20,6 +26,9 @@ import org.springframework.web.client.RestTemplate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND;
import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND;
/** /**
* @author DB * @author DB
* @version 1.0.0 * @version 1.0.0
@ -90,4 +99,31 @@ public class CpopEasyLearnDataAnalyseTest{
DataSourceKey.clear(); DataSourceKey.clear();
} }
} }
/**
* 获取子商户
*
* @author DB
* @since 2024/05/27
*/
@Test
public void getSubMchId() {
//获取校区
StoreExtend storeExtend = SpringUtils.getBean(StoreExtendService.class).queryChain().where(STORE_EXTEND.STORE_CLOUD_ID.eq("9e70c665649a9da70345cbe523284250")).one();
//获取品牌
BrandExtend brandExtend;
String brandId = null;
String storeId = null;
if (storeExtend == null) {
brandExtend = SpringUtils.getBean(BrandExtendService.class).queryChain().where(BRAND_EXTEND.BRAND_CLOUD_ID.eq("9e70c665649a9da70345cbe523284250")).one();
brandId = brandExtend.getBrandId();
} else {
//获取品牌
Store store = SpringUtils.getBean(StoreService.class).getById(storeExtend.getStoreId());
brandId = store.getBrandId();
storeId = storeExtend.getStoreId();
}
String subMchId = wxPayHandler.getSubMchId(brandId, storeId);
System.out.println(subMchId);
}
} }

View File

@ -16,6 +16,7 @@ import com.cpop.jambox.business.service.StoreExtendService;
import com.cpop.jambox.framework.constant.JamboxCloudUrl; import com.cpop.jambox.framework.constant.JamboxCloudUrl;
import com.cpop.pay.framewok.config.wxPay.WxPayProperties; import com.cpop.pay.framewok.config.wxPay.WxPayProperties;
import com.cpop.pay.framewok.handler.wxPay.WxPayHandler; import com.cpop.pay.framewok.handler.wxPay.WxPayHandler;
import com.cpop.pay.framewok.handler.wxPay.WxPayNormalHandler;
import com.github.binarywang.wxpay.bean.payscore.*; import com.github.binarywang.wxpay.bean.payscore.*;
import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingBillV3Request; import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingBillV3Request;
import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingReceiverRequest; import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingReceiverRequest;
@ -328,8 +329,8 @@ public class CpopEasyLearnTest {
@Test @Test
public void queryOrder() throws WxPayException { public void queryOrder() throws WxPayException {
WxPayService wxPayService = wxPayHandler.getWxPayService(null, "1666928264"); WxPayService wxPayService = wxPayHandler.getWxPayService(null, wxPayHandler.getSubMchId("97561677443530752", "97571696801128452"));
WxPayOrderQueryResult wxPayOrderQueryResult = wxPayService.queryOrder("4200002130202402224927801847",null); WxPayOrderQueryResult wxPayOrderQueryResult = wxPayService.queryOrder("4200002186202405135556568382",null);
System.out.println(JSONObject.toJSONString(wxPayOrderQueryResult)); System.out.println(JSONObject.toJSONString(wxPayOrderQueryResult));
} }

View File

@ -6,7 +6,9 @@ import com.cpop.common.utils.StringUtils;
import com.cpop.core.base.enums.OrderSource; import com.cpop.core.base.enums.OrderSource;
import com.cpop.core.utils.SpringUtils; import com.cpop.core.utils.SpringUtils;
import com.cpop.jambox.business.entity.*; import com.cpop.jambox.business.entity.*;
import com.cpop.jambox.business.mapper.EasyLearnOrderDetailMapper;
import com.cpop.jambox.business.service.*; import com.cpop.jambox.business.service.*;
import com.cpop.jambox.framework.constant.JamboxCloudUrl;
import com.cpop.pay.framewok.handler.wxPay.WxPayHandler; import com.cpop.pay.framewok.handler.wxPay.WxPayHandler;
import com.cpop.system.business.entity.Store; import com.cpop.system.business.entity.Store;
import com.cpop.system.business.entity.WxPayScore; import com.cpop.system.business.entity.WxPayScore;
@ -16,22 +18,27 @@ import com.cpop.system.business.service.WxPayScoreDetailService;
import com.cpop.system.business.service.WxPayScoreService; import com.cpop.system.business.service.WxPayScoreService;
import com.github.binarywang.wxpay.bean.payscore.PartnerUserSignPlanEntity; import com.github.binarywang.wxpay.bean.payscore.PartnerUserSignPlanEntity;
import com.github.binarywang.wxpay.bean.payscore.PayScorePlanDetailResult; import com.github.binarywang.wxpay.bean.payscore.PayScorePlanDetailResult;
import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreResult;
import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanResult; import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreSignPlanResult;
import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingV3Result; import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingV3Result;
import com.github.binarywang.wxpay.bean.request.WxPayPartnerOrderQueryV3Request; import com.github.binarywang.wxpay.bean.request.WxPayPartnerOrderQueryV3Request;
import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult; import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult;
import com.github.binarywang.wxpay.bean.result.WxPayPartnerOrderQueryV3Result; import com.github.binarywang.wxpay.bean.result.WxPayPartnerOrderQueryV3Result;
import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.PartnerPayScoreService;
import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.service.WxPayService;
import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.datasource.DataSourceKey; import com.mybatisflex.core.datasource.DataSourceKey;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.*; import com.mybatisflex.core.row.*;
import com.mybatisflex.core.update.UpdateChain;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
@ -42,6 +49,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.cpop.jambox.business.entity.table.EasyLearnOrderDetailTableDef.EASY_LEARN_ORDER_DETAIL;
import static com.cpop.jambox.business.entity.table.EasyLearnOrderExtendTableDef.EASY_LEARN_ORDER_EXTEND; import static com.cpop.jambox.business.entity.table.EasyLearnOrderExtendTableDef.EASY_LEARN_ORDER_EXTEND;
import static com.cpop.jambox.business.entity.table.EasyLearnOrderTableDef.EASY_LEARN_ORDER; import static com.cpop.jambox.business.entity.table.EasyLearnOrderTableDef.EASY_LEARN_ORDER;
import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND; import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND;
@ -110,7 +118,8 @@ public class CpopOldDataSyncTests {
.select("merchant_plan_no") .select("merchant_plan_no")
.select("sub_merch_id as subMchId") .select("sub_merch_id as subMchId")
.from("j_wechat_pay_plan") .from("j_wechat_pay_plan")
.where("is_month = 0") .where("create_time > '2024-05-08 11:25:30'")
//.where("is_month = 0")
.list(); .list();
} finally { } finally {
DataSourceKey.clear(); DataSourceKey.clear();
@ -175,7 +184,8 @@ public class CpopOldDataSyncTests {
.and("jct.pay_status = 'PAY'") .and("jct.pay_status = 'PAY'")
.and("jct.deleted = 1") .and("jct.deleted = 1")
.and("jct.card_no is not null") .and("jct.card_no is not null")
.and("jct.creation_time >= ?", LocalDateTime.of(2024, 1, 12, 16, 42)) .and("jct.creation_time > '2024-05-08 11:25:30'")
//.and("jct.creation_time >= ?", LocalDateTime.of(2024, 1, 12, 16, 42))
.list(); .list();
} finally { } finally {
DataSourceKey.clear(); DataSourceKey.clear();
@ -198,70 +208,120 @@ public class CpopOldDataSyncTests {
try { try {
PartnerUserSignPlanEntity partnerUserSignPlanEntity = wxPayService.getPartnerPayScoreSignPlanService() PartnerUserSignPlanEntity partnerUserSignPlanEntity = wxPayService.getPartnerPayScoreSignPlanService()
.queryUserSignPlans(item.getString("orderId"), item.getString("subMchId")); .queryUserSignPlans(item.getString("orderId"), item.getString("subMchId"));
EasyLearnOrder easyLearnOrder = new EasyLearnOrder(); if (partnerUserSignPlanEntity != null){
String storeCloudId = item.getString("storeCloudId"); EasyLearnOrder easyLearnOrder = new EasyLearnOrder();
Integer extendStatus = changeStatus(partnerUserSignPlanEntity.getSignState()); String storeCloudId = item.getString("storeCloudId");
partnerUserSignPlanEntity.getSignedDetailList().forEach(inner->{ Integer extendStatus = changeStatus(partnerUserSignPlanEntity.getSignState());
EasyLearnOrderDetail easyLearnOrderDetail = new EasyLearnOrderDetail(); partnerUserSignPlanEntity.getSignedDetailList().forEach(inner->{
BigDecimal payPrice = BigDecimal.valueOf(inner.getActualPayPrice()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); EasyLearnOrderDetail easyLearnOrderDetail = new EasyLearnOrderDetail();
easyLearnOrderDetail.setId(inner.getMerchantPlanDetailNo()) BigDecimal payPrice = BigDecimal.valueOf(inner.getActualPayPrice()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
.setOrderId(partnerUserSignPlanEntity.getMerchantSignPlanNo()) easyLearnOrderDetail.setId(inner.getMerchantPlanDetailNo())
.setOutOrderNo(inner.getOrderId()) .setOrderId(partnerUserSignPlanEntity.getMerchantSignPlanNo())
.setAmount(BigDecimal.valueOf(inner.getActualPrice()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)) .setOutOrderNo(inner.getOrderId())
.setActualPrice(payPrice) .setAmount(BigDecimal.valueOf(inner.getActualPrice()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP))
.setPeriodNo(inner.getPlanDetailNo()) .setActualPrice(payPrice)
.setDetailDesc(inner.getPlanDiscountDescription()) .setPeriodNo(inner.getPlanDetailNo())
.setDetailName(inner.getPlanDetailName()) .setDetailDesc(inner.getPlanDiscountDescription())
.setDetailStatus(changeDetailStatus(inner.getPlanDetailState())) .setDetailName(inner.getPlanDetailName())
.setCreateTime(LocalDateTime.now()); .setDetailStatus(changeDetailStatus(inner.getPlanDetailState()))
if (StringUtils.isNotBlank(inner.getUseTime())){ .setCreateTime(LocalDateTime.now());
easyLearnOrderDetail.setPayTime(LocalDateTime.parse(inner.getUseTime(),dateTimeFormatter)); if (StringUtils.isNotBlank(inner.getUseTime())){
} easyLearnOrderDetail.setPayTime(LocalDateTime.parse(inner.getUseTime(),dateTimeFormatter));
if (inner.getPlanDetailState().equals("FINISHED")) {
if (easyLearnOrder.getTotalPayAmount() == null) {
easyLearnOrder.setTotalPayAmount(payPrice);
} else {
easyLearnOrder.setTotalPayAmount(easyLearnOrder.getTotalPayAmount().add(payPrice));
} }
if (inner.getPlanDetailState().equals("FINISHED")) {
if (easyLearnOrder.getTotalPayAmount() == null) {
easyLearnOrder.setTotalPayAmount(payPrice);
} else {
easyLearnOrder.setTotalPayAmount(easyLearnOrder.getTotalPayAmount().add(payPrice));
}
}
easyLearnOrderDetails.add(easyLearnOrderDetail);
});
easyLearnOrder.setId(partnerUserSignPlanEntity.getMerchantSignPlanNo())
.setOrderContent(partnerUserSignPlanEntity.getPlanName())
.setOrderStatus(1)
.setOutOrderNo(partnerUserSignPlanEntity.getSignPlanId())
.setBrandId(storeMap.get(storeCloudId).getString("brandId"))
.setStoreId(storeMap.get(storeCloudId).getString("id"))
.setCustomerName(item.getString("customerName"))
.setCustomerPhone(item.getString("customerPhone"))
.setTotalAmount(BigDecimal.valueOf(partnerUserSignPlanEntity.getTotalActualPrice()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP))
.setTotalPayAmount(BigDecimal.ZERO)
.setOrderType(0)
.setRate(OrderSource.EASY_LEARN.getRate())
.setProductId(item.getString("productId"))
.setCreateTime(LocalDateTime.parse(partnerUserSignPlanEntity.getSignTime(),dateTimeFormatter));
easyLearnOrders.add(easyLearnOrder);
EasyLearnOrderExtend easyLearnOrderExtend = new EasyLearnOrderExtend();
easyLearnOrderExtend.setOrderId(partnerUserSignPlanEntity.getMerchantSignPlanNo())
.setGoingDetailNo(partnerUserSignPlanEntity.getGoingDetailNo())
.setPlanId(wxPayScoreMap.get(partnerUserSignPlanEntity.getPlanId()).getId())
.setSignPlanId(partnerUserSignPlanEntity.getSignPlanId())
.setSubMchId(partnerUserSignPlanEntity.getSubMchid())
.setExtendStatus(extendStatus)
.setExtendCancelType(changeCancelType(partnerUserSignPlanEntity.getCancelSignType()))
.setCancelReason(partnerUserSignPlanEntity.getCancelReason())
.setCreateTime(LocalDateTime.parse(partnerUserSignPlanEntity.getSignTime(),dateTimeFormatter));
if (StringUtils.isNotBlank(partnerUserSignPlanEntity.getCancelSignTime())){
easyLearnOrderExtend.setCancelTime(LocalDateTime.parse(partnerUserSignPlanEntity.getCancelSignTime(),dateTimeFormatter));
} }
easyLearnOrderDetails.add(easyLearnOrderDetail); easyLearnOrderExtends.add(easyLearnOrderExtend);
});
easyLearnOrder.setId(partnerUserSignPlanEntity.getMerchantSignPlanNo())
.setOrderContent(partnerUserSignPlanEntity.getPlanName())
.setOrderStatus(1)
.setOutOrderNo(partnerUserSignPlanEntity.getSignPlanId())
.setBrandId(storeMap.get(storeCloudId).getString("brandId"))
.setStoreId(storeMap.get(storeCloudId).getString("id"))
.setCustomerName(item.getString("customerName"))
.setCustomerPhone(item.getString("customerPhone"))
.setTotalAmount(BigDecimal.valueOf(partnerUserSignPlanEntity.getTotalActualPrice()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP))
.setTotalPayAmount(BigDecimal.ZERO)
.setOrderType(0)
.setRate(OrderSource.EASY_LEARN.getRate())
.setProductId(item.getString("productId"))
.setCreateTime(LocalDateTime.parse(partnerUserSignPlanEntity.getSignTime(),dateTimeFormatter));
easyLearnOrders.add(easyLearnOrder);
EasyLearnOrderExtend easyLearnOrderExtend = new EasyLearnOrderExtend();
easyLearnOrderExtend.setOrderId(partnerUserSignPlanEntity.getMerchantSignPlanNo())
.setGoingDetailNo(partnerUserSignPlanEntity.getGoingDetailNo())
.setPlanId(wxPayScoreMap.get(partnerUserSignPlanEntity.getPlanId()).getId())
.setSignPlanId(partnerUserSignPlanEntity.getSignPlanId())
.setSubMchId(partnerUserSignPlanEntity.getSubMchid())
.setExtendStatus(extendStatus)
.setExtendCancelType(changeCancelType(partnerUserSignPlanEntity.getCancelSignType()))
.setCancelReason(partnerUserSignPlanEntity.getCancelReason())
.setCreateTime(LocalDateTime.parse(partnerUserSignPlanEntity.getSignTime(),dateTimeFormatter));
if (StringUtils.isNotBlank(partnerUserSignPlanEntity.getCancelSignTime())){
easyLearnOrderExtend.setCancelTime(LocalDateTime.parse(partnerUserSignPlanEntity.getCancelSignTime(),dateTimeFormatter));
} }
easyLearnOrderExtends.add(easyLearnOrderExtend);
} catch (WxPayException e) { } catch (WxPayException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}); });
SpringUtils.getBean(EasyLearnOrderService.class).saveBatch(easyLearnOrders); //去重
SpringUtils.getBean(EasyLearnOrderExtendService.class).saveBatch(easyLearnOrderExtends); SpringUtils.getBean(EasyLearnOrderService.class).saveBatch(easyLearnOrders.stream().distinct().collect(Collectors.toList()));
SpringUtils.getBean(EasyLearnOrderDetailService.class).saveBatch(easyLearnOrderDetails); SpringUtils.getBean(EasyLearnOrderExtendService.class).saveBatch(easyLearnOrderExtends.stream().distinct().collect(Collectors.toList()));
SpringUtils.getBean(EasyLearnOrderDetailService.class).saveBatch(easyLearnOrderDetails.stream().distinct().collect(Collectors.toList()));
}
/**
* 更新支付分支付时间
* @author DB
* @since 2024/5/13
*/
@Test
public void updatePayScoreDetailData() throws WxPayException {
//查询云函数
JSONObject jsonBody = new JSONObject();
jsonBody.put("_type", "merchantPayPlanList");
//订单id
jsonBody.put("startTime", "2024-05-08 11:25:30");
//获取课卡信息
JSONObject result = SpringUtils.getBean(RestTemplate.class).postForObject(JamboxCloudUrl.COMMON_CARD_URL, jsonBody, JSONObject.class);
assert result != null;
JSONArray data = result.getJSONArray("data");
List<Row> list = DbChain.table(EASY_LEARN_ORDER_DETAIL)
.select(EASY_LEARN_ORDER_DETAIL.ID, EASY_LEARN_ORDER_EXTEND.SUB_MCH_ID)
.from(EASY_LEARN_ORDER_DETAIL)
.leftJoin(EASY_LEARN_ORDER_EXTEND).on(EASY_LEARN_ORDER_EXTEND.ORDER_ID.eq(EASY_LEARN_ORDER_DETAIL.ORDER_ID))
.where(EASY_LEARN_ORDER_DETAIL.ID.in(data))
.list();
WxPayService wxPayService = wxPayHandler.getWxPayService();
PartnerPayScoreService partnerPayScoreService = wxPayService.getPartnerPayScoreService();
list.forEach(item -> {
WxPartnerPayScoreResult wxPartnerPayScoreResult = null;
try {
wxPartnerPayScoreResult = partnerPayScoreService.queryServiceOrder(null, item.getString("subMchId"), item.getString("id"), null);
item.put("transactionId", wxPartnerPayScoreResult.getCollection().getDetails().get(0).getTransactionId());
item.put("outOrderNo", wxPartnerPayScoreResult.getOrderId());
item.put("payTime", LocalDateTime.parse(wxPartnerPayScoreResult.getCollection().getDetails().get(0).getPaidTime(), DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
item.put("actualPrice", BigDecimal.valueOf(Long.valueOf(wxPartnerPayScoreResult.getCollection().getDetails().get(0).getAmount())).divide(new BigDecimal(100)));
} catch (WxPayException e) {
throw new RuntimeException(e);
}
});
Db.executeBatch(list, EasyLearnOrderDetailMapper.class, (mapper, item) -> {
UpdateChain.of(mapper)
.set(EASY_LEARN_ORDER_DETAIL.TRANSACTION_ID, item.getString("transactionId"))
.set(EASY_LEARN_ORDER_DETAIL.PAY_TIME, item.getLocalDateTime("payTime"))
.set(EASY_LEARN_ORDER_DETAIL.OUT_ORDER_NO, item.getString("outOrderNo"))
.set(EASY_LEARN_ORDER_DETAIL.ACTUAL_PRICE, item.getBigDecimal("actualPrice"))
.where(EASY_LEARN_ORDER_DETAIL.ID.eq(item.getString("id")))
.update();
});
} }
private Integer changeStatus(String signStatus) { private Integer changeStatus(String signStatus) {

View File

@ -105,31 +105,33 @@ public class MiniSummitController {
@ApiOperation("峰会报名") @ApiOperation("峰会报名")
@PostMapping("/summitApply") @PostMapping("/summitApply")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Deprecated
public R<String> summitApply(@RequestBody @Validated SummitApplyBo bo) { public R<String> summitApply(@RequestBody @Validated SummitApplyBo bo) {
long count = summitApplyService.count(QueryWrapper.create().where(SUMMIT_APPLY.OPEN_ID.eq(bo.getOpenId()))); // long count = summitApplyService.count(QueryWrapper.create().where(SUMMIT_APPLY.OPEN_ID.eq(bo.getOpenId())));
if (count > 0) { // if (count > 0) {
throw new ServiceException("您已报名,请勿重复提交!"); // throw new ServiceException("您已报名,请勿重复提交!");
} // }
SummitApply summitApply = BeanUtils.mapToClass(bo, SummitApply.class); // SummitApply summitApply = BeanUtils.mapToClass(bo, SummitApply.class);
summitApplyService.save(summitApply); // summitApplyService.save(summitApply);
List<SummitApplyUser> summitApplyUsers = BeanUtils.mapToList(bo.getUsers(), SummitApplyUser.class); // List<SummitApplyUser> summitApplyUsers = BeanUtils.mapToList(bo.getUsers(), SummitApplyUser.class);
summitApplyUsers.forEach(item->{ // summitApplyUsers.forEach(item->{
item.setSummitApplyId(summitApply.getId()); // item.setSummitApplyId(summitApply.getId());
}); // });
summitApplyUserService.saveBatch(summitApplyUsers); // summitApplyUserService.saveBatch(summitApplyUsers);
// 企微通知值班人员 // // 企微通知值班人员
List<String> phoneList = new ArrayList<String>(); // List<String> phoneList = new ArrayList<String>();
try { // try {
SpringUtils.getBean(WebHookSendHandler.class) // SpringUtils.getBean(WebHookSendHandler.class)
.webHookSendText(WebHookKeyConstant.MARKET_BOT, // .webHookSendText(WebHookKeyConstant.MARKET_BOT,
phoneList, // phoneList,
"==========2024峰会报名==========\n" + // "==========2024峰会报名==========\n" +
"机构" + bo.getStoreName() + "报名成功", // "机构" + bo.getStoreName() + "报名成功",
true); // true);
} catch (IOException e) { // } catch (IOException e) {
throw new ServiceException("发送消息通知失败!"); // throw new ServiceException("发送消息通知失败!");
} // }
return R.ok(); // return R.ok();
return R.fail("峰会报名已关闭");
} }
/** /**

View File

@ -5,19 +5,20 @@ import com.cpop.common.utils.ServletUtils;
import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.StringUtils;
import com.cpop.core.base.exception.ServiceException; import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.utils.SecurityUtils; import com.cpop.core.utils.SecurityUtils;
import com.cpop.core.utils.SpringUtils;
import com.cpop.pay.framewok.config.wxPay.WxPayConfiguration;
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.service.WxPayService;
import com.mybatisflex.core.datasource.DataSourceKey;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Db; import com.mybatisflex.core.row.Db;
import com.mybatisflex.core.row.DbChain;
import com.mybatisflex.core.row.Row; import com.mybatisflex.core.row.Row;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* @author DB * @author DB
@ -111,31 +112,56 @@ public class WxPayHandler {
* @return String * @return String
*/ */
public String getSubMchId(String brandId, String storeId) { public String getSubMchId(String brandId, String storeId) {
String wxMchId; AtomicReference<String> subMchId = new AtomicReference<>("1618436087");
if (StringUtils.isNotEmpty(storeId)){ if (StringUtils.isNotEmpty(storeId)){
//先查校区 //先查校区
Row store = Db.selectOneByQuery("cp_sys_store", QueryWrapper.create().where("id = ?", storeId)); Row store = Db.selectOneByQuery("cp_j_store_extend", QueryWrapper.create().select("store_cloud_id as storeCloudId").where("store_id = ?", storeId));
if (store != null && StringUtils.isNotBlank(store.getString("wxMchId"))){ if (store != null && StringUtils.isNotBlank(store.getString("storeCloudId"))) {
wxMchId = store.getString("wxMchId"); AtomicReference<Row> row = new AtomicReference<>();
} else { DataSourceKey.use("jambox", () -> {
//查询品牌 row.set(Db.selectOneByQuery("j_merchant_info", QueryWrapper.create()
Row brand = Db.selectOneByQuery("cp_sys_brand", QueryWrapper.create().where("id = ?", brandId)); .select("j_merchant_info.wx_mch_id as wxMchId")
if (brand != null && StringUtils.isNotBlank(brand.getString("wxMchId"))){ .from("j_merchant_info")
wxMchId = brand.getString("wxMchId"); .leftJoin("t_mechanism_info").on("t_mechanism_info.mechanism_id = j_merchant_info.main_id")
}else { .where("t_mechanism_info.store_id = ?", store.getString("storeCloudId"))
wxMchId = null; .and("j_merchant_info.main_type = 2")));
});
if (row.get() == null){
//查询品牌
Row brand = Db.selectOneByQuery("cp_j_brand_extend", QueryWrapper.create().select("brand_cloud_id as brandCloudId").where("brand_id = ?", brandId));
if (brand != null && StringUtils.isNotBlank(brand.getString("brandCloudId"))){
DataSourceKey.use("jambox", () -> {
row.set(DbChain.table("j_merchant_info")
.select("j_merchant_info.wx_mch_id as wxMchId")
.leftJoin("t_brand_info").on("t_brand_info.id = j_merchant_info.main_id")
.where("t_brand_info.brand_id = ?", brand.getString("brandCloudId"))
.and("j_merchant_info.main_type = 1").one());
if (row.get() != null){
subMchId.set(row.get().getString("wxMchId"));
}
});
}
} else {
subMchId.set(row.get().getString("wxMchId"));
} }
} }
} else { } else {
//查询品牌 //查询品牌
Row brand = Db.selectOneByQuery("cp_sys_brand", QueryWrapper.create().where("id = ?", brandId)); Row brand = Db.selectOneByQuery("cp_j_brand_extend", QueryWrapper.create().select("brand_cloud_id as brandCloudId").where("brand_id = ?", brandId));
if (brand != null && StringUtils.isNotBlank(brand.getString("wxMchId"))){ if (brand != null && StringUtils.isNotBlank(brand.getString("brandCloudId"))){
wxMchId = brand.getString("wxMchId"); DataSourceKey.use("jambox", () -> {
}else { Row row = DbChain.table("j_merchant_info")
wxMchId = null; .select("j_merchant_info.wx_mch_id as wxMchId")
.leftJoin("t_brand_info").on("t_brand_info.id = j_merchant_info.main_id")
.where("t_brand_info.brand_id = ?", brand.getString("brandCloudId"))
.and("j_merchant_info.main_type = 1").one();
if (row != null){
subMchId.set(row.getString("wxMchId"));
}
});
} }
} }
return wxMchId; return subMchId.get();
} }
/** /**