修订Oam缺陷

This commit is contained in:
DB 2023-12-28 14:59:53 +08:00
parent 5e0039ea95
commit 8de9bd498f
27 changed files with 278 additions and 140 deletions

View File

@ -16,7 +16,7 @@ public enum OrderSource {
/**
* 微信支付
*/
EASY_LEARN("easyLearn",0.002);
EASY_LEARN("EasyLearn",0.002);
OrderSource(String name, Double rate) {
this.rate = rate;

View File

@ -2,8 +2,7 @@ package com.cpop.core.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
/**
@ -15,18 +14,15 @@ import org.springframework.web.client.RestTemplate;
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
return new RestTemplate(factory);
}
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setReadTimeout(5000);
factory.setConnectTimeout(15000);
// 设置代理
//factory.setProxy(null);
return factory;
public RestTemplate restTemplate() {
// 创建一个 HttpComponentsClientHttpRequestFactory 客户端请求工厂实例
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
// 设置连接超时时间为 5
requestFactory.setConnectTimeout(5000);
// 设置读取超时时间为 10
requestFactory.setReadTimeout(10000);
// 使用 HttpComponentsClientHttpRequestFactory 客户端请求工厂实例创建 RestTemplate 实例
return new RestTemplate(requestFactory);
}
}

View File

@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
@ -20,49 +22,62 @@ public class OncePlaceOrderBo {
/**
* 品牌id
*/
@ApiModelProperty("品牌id")
@NotBlank(message = "品牌id不能为空")
@ApiModelProperty(value = "品牌id",required = true)
private String brandCloudId;
/**
* 校区id
*/
@ApiModelProperty("校区id")
@NotBlank(message = "校区id不能为空")
@ApiModelProperty(value = "校区id",required = true)
private String storeCloudId;
/**
* 客户名
*/
@ApiModelProperty("客户名")
@NotBlank(message = "客户名不能为空")
@ApiModelProperty(value = "客户名",required = true)
private String customerName;
/**
* 客户电话
*/
@ApiModelProperty("客户电话")
@NotBlank(message = "客户电话不能为空")
@ApiModelProperty(value = "客户电话",required = true)
private String customerPhone;
/**
* 产品/课卡id
* id
*/
@ApiModelProperty("产品/课卡id")
private String productId;
@NotBlank(message = "云订单id不能为空")
@ApiModelProperty(value = "云订单id",required = true)
private String orderCloudId;
/**
* 总金额
*/
@ApiModelProperty("总金额")
@NotNull(message = "总金额不能为空")
@ApiModelProperty(value = "总金额",required = true)
private BigDecimal totalAmount;
/**
* 总支付金额
*/
@ApiModelProperty("总支付金额")
@NotNull(message = "总支付金额不能为空")
@ApiModelProperty(value = "总支付金额",required = true)
private BigDecimal totalPayAmount;
/**
* 员工id
* 校区/店铺员工id
*/
@ApiModelProperty("员工id")
private String staffId;
@ApiModelProperty("校区/店铺员工云id")
private String storeStaffCloudId;
/**
* openId
*/
@ApiModelProperty("openId")
private String openId;
}

View File

@ -93,9 +93,9 @@ public class EasyLearnController {
* @param bo 下单请求对象
* @return com.cpop.core.base.R<java.lang.Void>
*/
@PostMapping("/oncePlaceOrderBo")
@PostMapping("/oncePlaceOrder")
@ApiOperation("一次性支付下单")
public R<Object> oncePlaceOrderBo(@RequestBody @Validated @ApiParam("一次性支付") OncePlaceOrderBo bo) {
return R.ok(easyLearnOrderService.oncePlaceOrderBo(bo));
public R<Object> oncePlaceOrder(@RequestBody @Validated @ApiParam("一次性支付") OncePlaceOrderBo bo) {
return R.ok(easyLearnOrderService.oncePlaceOrder(bo));
}
}

View File

@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@Api(tags = "果酱-放心学回调接口")
@RequestMapping("/easyLearn/callBack")
@RequestMapping("/easyLearn/callback")
public class EasyLearnCallBackController {
@Autowired
@ -29,9 +29,9 @@ public class EasyLearnCallBackController {
* @param xmlData 数据
* @return java.lang.String
*/
@PostMapping("/notify/order")
public String parseOrderNotifyResult(@RequestBody String xmlData){
easyLearnOrderService.wxPayNotifyOrder(xmlData);
@PostMapping("/notify/oncePay")
public String oncePayResult(@RequestBody String xmlData){
easyLearnOrderService.oncePayResult(xmlData);
return WxPayNotifyResponse.success("成功");
}

View File

@ -33,6 +33,21 @@ public class EasyLearnOrder extends BaseEntity implements Serializable {
@Id
private String id;
/**
* 支付状态(0未支付1已支付)
*/
private Integer orderStatus;
/**
* 云id
*/
private String orderCloudId;
/**
* 校区/店铺员工云id
*/
private String storeStaffCloudId;
/**
* 外部订单号
*/

View File

@ -42,7 +42,7 @@ public interface EasyLearnOrderService extends IService<EasyLearnOrder> {
* @since 2023/12/21
* @param xmlData 数据
*/
void wxPayNotifyOrder(String xmlData);
void oncePayResult(String xmlData);
/**
* 一次性支付下单
@ -50,5 +50,5 @@ public interface EasyLearnOrderService extends IService<EasyLearnOrder> {
* @since 2023/10/23 12:15
* @param bo 下单请求对象
*/
Object oncePlaceOrderBo(OncePlaceOrderBo bo);
Object oncePlaceOrder(OncePlaceOrderBo bo);
}

View File

@ -22,7 +22,9 @@ import com.cpop.jambox.business.service.BrandExtendService;
import com.cpop.jambox.business.service.EasyLearnOrderService;
import com.cpop.jambox.business.service.StoreExtendService;
import com.cpop.jambox.business.vo.EasyLearnPageVo;
import com.cpop.jambox.framework.constant.JamboxCloudUrl;
import com.cpop.jambox.framework.constant.JamboxRedisConstant;
import com.cpop.pay.framewok.config.wxPay.WxPayConfiguration;
import com.cpop.pay.framewok.handler.wxPay.WxPayHandler;
import com.cpop.pay.framewok.task.WxPayAsyncTask;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
@ -40,6 +42,7 @@ import com.mybatisflex.core.row.Row;
import com.mybatisflex.core.row.RowUtil;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@ -59,6 +62,7 @@ import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EX
* @since 2023-12-14
*/
@Service("easyLearnOrderService")
@Slf4j
public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper, EasyLearnOrder> implements EasyLearnOrderService {
@Autowired
@ -68,9 +72,14 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
private WxPayAsyncTask wxPayAsyncTask;
/**
* 一次性支付回调地址
* 一次性支付回调地址本地内网穿透
*/
private final String ONCE_PAY_NOTIFY_URL = "https://api.jamboxsys.com/Cpop-Mall/easyLearn/callback/notify/order";
private final String ONCE_PAY_DEV_NOTIFY_URL = "https://frp-bid.top:60778/Cpop-Oam/easyLearn/callback/notify/oncePay";
/**
* 一次性支付回调地址测试地址
*/
private final String ONCE_PAY_TEST_NOTIFY_URL = "https://test.cpopsz.com/Cpop-Oam/easyLearn/callback/notify/oncePay";
/**
* 获取放心学分页
@ -347,13 +356,13 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
}
/**
* 微信支付订单通知
* 放心学一次性订单通知
* @author DB
* @since 2023/12/21
* @param xmlData 数据
*/
@Override
public void wxPayNotifyOrder(String xmlData) {
public void oncePayResult(String xmlData) {
try {
WxPayService wxPayService = wxPayHandler.getWxPayService();
WxPayOrderNotifyResult notifyResult = wxPayService.parseOrderNotifyResult(xmlData);
@ -361,19 +370,45 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
throw new ServiceException(notifyResult.getReturnMsg());
}
String orderId = notifyResult.getOutTradeNo();
//获取订单信息
EasyLearnOrder easyLearnOrder = this.getById(orderId);
//需要分账
if (notifyResult.getTotalFee() >= Math.ceil(1 / OrderSource.MALL.getRate())) {
//获取订单信息
EasyLearnOrder easyLearnOrder = this.getById(orderId);
String subMchId = wxPayHandler.getSubMchId(easyLearnOrder.getBrandId(), easyLearnOrder.getStoreId());
log.info("支付金额:{}", notifyResult.getTotalFee());
if (notifyResult.getTotalFee() >= Math.ceil(1 / OrderSource.EASY_LEARN.getRate())) {
//设置子商户
WxPayConfig config = wxPayService.getConfig();
config.setSubMchId(wxPayHandler.getSubMchId(easyLearnOrder.getBrandId(), easyLearnOrder.getStoreId()));
config.setSubMchId(subMchId);
wxPayAsyncTask.asyncWxPayProfitSharing(orderId, notifyResult, wxPayService, OrderSource.EASY_LEARN);
}
//更新订单
this.updateChain().set(EASY_LEARN_ORDER.OUT_ORDER_NO, notifyResult.getTransactionId()).where(EASY_LEARN_ORDER.ID.eq(orderId)).update();
//TODO: 通知波哥办卡
SpringUtils.getBean(RestTemplate.class);
//课卡信息
JSONObject jsonBody = new JSONObject();
jsonBody.put("_type", "addPeriod");
//办卡实收金额
jsonBody.put("money", easyLearnOrder.getTotalPayAmount());
//获取云校区id
StoreExtend storeExtend = SpringUtils.getBean(StoreExtendService.class).getOne(QueryWrapper.create().where(STORE_EXTEND.STORE_ID.eq(easyLearnOrder.getStoreId())));
//店铺/校区
jsonBody.put("storeId", storeExtend.getStoreCloudId());
//手机号
jsonBody.put("phone", easyLearnOrder.getCustomerPhone());
//客户名称
jsonBody.put("customerName", easyLearnOrder.getCustomerName());
//模板id
jsonBody.put("templateId", easyLearnOrder.getOrderCloudId());
//订单来源
jsonBody.put("orderSource", OrderSource.EASY_LEARN.toString());
//订单来源
jsonBody.put("subMchId", subMchId);
//获取课卡信息
JSONObject result = SpringUtils.getBean(RestTemplate.class).postForObject(JamboxCloudUrl.COMMON_CARD_URL, jsonBody, JSONObject.class);
if (result == null){
throw new ServiceException("放心学一次性支付办卡失败!");
}
easyLearnOrder.setProductId(result.getString("data")).setOrderStatus(1);
this.updateById(easyLearnOrder);
} catch (WxPayException e) {
throw new ServiceException(e.getMessage());
}
@ -386,25 +421,46 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
* @param bo 下单请求对象
*/
@Override
public Object oncePlaceOrderBo(OncePlaceOrderBo bo) {
//获取当前下单用户信息
JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo();
public Object oncePlaceOrder(OncePlaceOrderBo bo) {
//分布式锁进行幂等处理
RedisService redisService = SpringUtils.getBean(RedisService.class);
String openId;
if (StringUtils.isBlank(bo.getOpenId())){
//获取当前下单用户信息
JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo();
openId = loginUserInfo.getString("openId");
}else {
openId = bo.getOpenId();
}
//分布式锁进行幂等处理
Lock userIdLock = redisService.distributedLock(JamboxRedisConstant.ONCE_PAY_LOCK_USER_PAY + bo.getCustomerPhone());
if (userIdLock.tryLock()){
if (userIdLock.tryLock()) {
try {
//获取品牌
BrandExtend brandExtend = SpringUtils.getBean(BrandExtendService.class).queryChain().where(BRAND_EXTEND.BRAND_CLOUD_ID.eq(bo.getBrandCloudId())).one();
//获取校区
StoreExtend storeExtend = SpringUtils.getBean(StoreExtendService.class).queryChain().where(STORE_EXTEND.STORE_CLOUD_ID.eq(bo.getStoreCloudId())).one();
//创建订单
EasyLearnOrder easyLearnOrder = BeanUtils.mapToClass(bo, EasyLearnOrder.class);
easyLearnOrder.setOrderType(2).setBrandId(brandExtend.getBrandId()).setStoreId(storeExtend.getStoreId());
this.save(easyLearnOrder);
EasyLearnOrder easyLearnOrder = this.getOne(QueryWrapper.create().where(EASY_LEARN_ORDER.ORDER_CLOUD_ID.eq(bo.getOrderCloudId())));
if (easyLearnOrder == null) {
//创建订单
easyLearnOrder = BeanUtils.mapToClass(bo, EasyLearnOrder.class);
easyLearnOrder.setOrderType(2).setBrandId(brandExtend.getBrandId()).setStoreId(storeExtend.getStoreId());
this.save(easyLearnOrder);
} else {
if (easyLearnOrder.getOrderStatus() == 1){
throw new ServiceException("当前订单已支付,请勿重复支付");
}
}
String payNotifyUrl;
if (StringUtils.equals("prod", SpringUtils.getActiveProfile())) {
payNotifyUrl = SpringUtils.getBean(WxPayConfiguration.class).getProperties().getNotifyUrl();
} else if (StringUtils.equals("test", SpringUtils.getActiveProfile())){
payNotifyUrl = ONCE_PAY_TEST_NOTIFY_URL;
} else {
payNotifyUrl = ONCE_PAY_DEV_NOTIFY_URL;
}
//获取商户信息
WxPayService wxPayService = wxPayHandler.getWxPayService(null, wxPayHandler.getSubMchId(brandExtend.getBrandId(), storeExtend.getStoreId()), ONCE_PAY_NOTIFY_URL);
WxPayService wxPayService = wxPayHandler.getWxPayService(null, wxPayHandler.getSubMchId(brandExtend.getBrandId(), storeExtend.getStoreId()), payNotifyUrl);
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
//需要分账
if (bo.getTotalAmount().scaleByPowerOfTen(2).intValue() >= Math.ceil(1 / OrderSource.EASY_LEARN.getRate())) {
@ -412,7 +468,7 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
orderRequest.setProfitSharing("Y");
}
orderRequest.setSpbillCreateIp(IpUtils.getHostIp())
.setOpenid(loginUserInfo.getString("openId"))
.setOpenid(openId)
//商品描述
.setBody("一次性支付")
.setOutTradeNo(easyLearnOrder.getId())

View File

@ -1,4 +1,4 @@
wx:
pay:
#支付通知地址
notify-url: https://api.jamboxsys.com/Cpop-Mall/easyLearn/callback/notify/order
notify-url: https://oamapi.cpopsz.com/Cpop-Oam/easyLearn/callback/notify/oncePay

View File

@ -1,11 +1,8 @@
package com.cpop.mall.web;
import com.alibaba.fastjson.JSONObject;
import com.cpop.core.utils.SpringUtils;
import com.cpop.core.utils.uuid.IdUtils;
import com.cpop.pay.framewok.config.wxPay.WxPayProperties;
import com.cpop.system.business.entity.Brand;
import com.cpop.system.business.service.BrandService;
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingFinishRequest;
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingQueryRequest;
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingQueryResult;
@ -47,7 +44,7 @@ public class CpopWxPayTests {
*/
@Test
public void refund() throws WxPayException {
Brand brand = SpringUtils.getBean(BrandService.class).getById("75140168047210496");
//Brand brand = SpringUtils.getBean(BrandService.class).getById("75140168047210496");
//Order order = SpringUtils.getBean(OrderService.class).getById("78954327589658624");
WxPayRefundV3Request request = new WxPayRefundV3Request();
WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount();
@ -58,14 +55,14 @@ public class CpopWxPayTests {
.setTotal(refund)
.setCurrency("CNY");
request.setSubMchid(wxPayService.getConfig().getSubMchId())
.setTransactionId("4200002028202312069539269015")
.setOutTradeNo("89825115260416000")
.setTransactionId("4200002091202312282284574621")
.setOutTradeNo("97795855209209856")
//.setTransactionId(order.getOutOrderNo())
//.setOutTradeNo(order.getId())
.setNotifyUrl(wxPayProperties.getNotifyRefund())
.setOutRefundNo(IdUtils.fastSimpleUUID())
.setSubMchid("1661807764")
.setReason("接口测试退款")
.setSubMchid("1661323640")
.setReason("一次性支付退款")
.setAmount(amount);
WxPayRefundV3Result result = wxPayService.refundV3(request);
System.out.println(result);
@ -83,10 +80,10 @@ public class CpopWxPayTests {
//ProfitSharing profitSharing = SpringUtils.getBean(ProfitSharingService.class).getById("77860920238751744");
//profitSharingReturnRequest.setOrderId(profitSharing.getOutProfitSharingId());
//profitSharingReturnRequest.setOutReturnNo(profitSharing.getId());
profitSharingReturnRequest.setOrderId("4200002013202311178836140400");
profitSharingReturnRequest.setOutReturnNo("83058677266882560");
profitSharingReturnRequest.setOrderId("30000502582023122858656805224");
profitSharingReturnRequest.setOutReturnNo("97795889866743808");
profitSharingReturnRequest.setDescription("分账退款");
profitSharingReturnRequest.setSubMchId("1659765332");
profitSharingReturnRequest.setSubMchId("1661323640");
profitSharingReturnRequest.setReturnMchid("1618884922");
//profitSharingReturnRequest.setAmount(profitSharing.getAmount());
profitSharingReturnRequest.setAmount(1L);

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
whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/wxCp/*,/wxCp/portal/*/registerCode,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/**,/easyLearn/oncePlaceOrder
gateway:
rsa-keypair:
# 公钥文件
@ -38,6 +38,7 @@ spring:
max-active: 16
#
max-wait: -1ms
client-type: jedis
data:
mongodb:
host: localhost
@ -89,6 +90,12 @@ knife4j:
api-rule: package
api-rule-resources:
- com.cpop.system
#果酱
Jambox:
group-name: Jambox
api-rule: package
api-rule-resources:
- com.cpop.jambox
#微信
wx:

View File

@ -4,7 +4,7 @@ cpop:
profile: /root/cpop-union/cpop-oam/upload
jwt:
#白名单
whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*,/wxCp/*,/wxCp/portal/*/registerCode,/sysCommon/miniSyncBrandAndStore
whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*,/wxCp/*,/wxCp/portal/*/registerCode,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/**,/easyLearn/oncePlaceOrder
#拦截
gateway:
rsa-keypair:
@ -39,6 +39,7 @@ spring:
max-active: 16
#
max-wait: -1ms
client-type: jedis
data:
mongodb:
host: localhost

View File

@ -4,7 +4,7 @@ cpop:
profile: /root/cpop-union/cpop-mall/upload
jwt:
#白名单
whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*,/wxCp/portal/*/registerCode,/wxCp/*,/sysCommon/miniSyncBrandAndStore
whiteList: /websocket/*,/login,/getCaptcha,/profile/**,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*,/wxCp/portal/*/registerCode,/wxCp/*,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/**,/easyLearn/oncePlaceOrder
#拦截
gateway:
rsa-keypair:
@ -43,6 +43,7 @@ spring:
max-active: 16
#
max-wait: -1ms
client-type: jedis
data:
mongodb:
host: localhost

View File

@ -31,7 +31,7 @@ spring:
max-file-size: 1024MB
max-request-size: 300MB
profiles:
active: dev,core
active: dev,core,jambox
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver

View File

@ -22,13 +22,18 @@ import com.cpop.system.business.service.*;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.datasource.DataSourceKey;
import com.mybatisflex.core.datasource.FlexDataSource;
import com.mybatisflex.core.row.*;
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.zaxxer.hikari.HikariDataSource;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import java.io.*;
import java.time.LocalDate;
import java.util.*;
@ -57,11 +62,15 @@ public class CpopImportTests {
*/
@Test
public void importBrandJson() throws IOException {
String brandFileUrl = "C:\\Users\\Administrator\\Desktop\\brand.json";
/*String brandFileUrl = "C:\\Users\\Administrator\\Desktop\\brand.json";
List<String> filterList = new ArrayList<>();
filterList.add("b00064a760d0c4f121b0835d09b909ca");
filterList.add("ac1268b164d1d20700080aae1703ecf8");
filterList.add("41ae62ef621ee0f909da5583399ff318");
filterList.add("0122a5876468513f0d42569d389e8264");
filterList.add("0ab5303b62c68da00d302cc2079b7fbe");
filterList.add("41ae62ef6228587e0b430c3a16483a9a");
filterList.add("ac1268b164d1d20700080aae1703ecf8");
filterList.add("def1da45654259bc090e5054208e9b9c");
List<JsonBrand> jsonBrands = JSONArray.parseArray(readJson(brandFileUrl), JsonBrand.class);
//过滤已存在的品牌
List<JsonBrand> filterBrand = jsonBrands.stream().filter(item -> !filterList.contains(item.getBrandCloudId())).collect(Collectors.toList());
@ -69,18 +78,32 @@ public class CpopImportTests {
Map<BrandExtend, Brand> brandJsonBrandMap = new HashMap<>();
filterBrand.forEach(item -> {
Brand brand = new Brand();
brand.setSourceType(SourceType.JAMBOX.toString())
.setBrandName(item.getBrandName());
brand.setSourceType(SourceType.JAMBOX.toString()).setBrandName(item.getBrandName());
BrandExtend brandExtend = new BrandExtend();
brandExtend.setBrandCloudId(item.getBrandCloudId());
brandJsonBrandMap.put(brandExtend, brand);
});
SpringUtils.getBean(BrandService.class).saveBatch(brandJsonBrandMap.values()) ;
SpringUtils.getBean(BrandService.class).saveBatch(brandJsonBrandMap.values());
//批量插入拓展信息
brandJsonBrandMap.forEach((key, value) -> {
key.setBrandId(value.getId());
});
SpringUtils.getBean(BrandExtendService.class).saveBatch(brandJsonBrandMap.keySet());
SpringUtils.getBean(BrandExtendService.class).saveBatch(brandJsonBrandMap.keySet());*/
//更新商户号
try {
//查询旧表
DataSourceKey.use("jambox");
List<Row> rowList = DbChain.table("j_merchant_info")
.select("jmi.wx_mch_id as wxMchId")
.select("tbi.brand_id as brandCloudId")
.from("j_merchant_info").as("jmi")
.leftJoin("t_brand_info").as("tbi").on("tbi.id = jmi.main_id")
.where("jmi.main_type = 1")
.list();
log.info(JSONArray.toJSONString(rowList));
} finally {
DataSourceKey.clear();
}
}
/**
@ -92,10 +115,8 @@ public class CpopImportTests {
@Test
public void importStoreJson() throws IOException {
String storeFileUrl = "C:\\Users\\Administrator\\Desktop\\store.json";
List<String> filterList = new ArrayList<>();
filterList.add("b00064a760d0c4f121b0835d09b909ca");
filterList.add("ac1268b164d1d20700080aae1703ecf8");
filterList.add("0122a5876468513f0d42569d389e8264");
List<String> filterList = Db.selectListByQuery(STORE_EXTEND.getTableName(), QueryWrapper.create().select(STORE_EXTEND.STORE_CLOUD_ID))
.stream().map(item -> item.getString("storeCloudId")).collect(Collectors.toList());
List<JsonStore> jsonStores = JSONArray.parseArray(readJson(storeFileUrl), JsonStore.class);
//过滤已存在的品牌
List<JsonStore> filterStore = jsonStores.stream()
@ -257,8 +278,6 @@ public class CpopImportTests {
"ness_license_id as licenseCode", "corp_name as licenseUserName", "reg_pic as licensePicUrl")
.where("reg_addr is not null")
.list();
} finally {
DataSourceKey.clear();
}
@ -351,7 +370,16 @@ public class CpopImportTests {
DataSourceKey.clear();
}
getTestDynamicDataSource();
//获取校区
Map<String, String> storeMap = SpringUtils.getBean(StoreExtendService.class).list().stream().collect(Collectors.toMap(StoreExtend::getStoreCloudId, StoreExtend::getStoreId));
rowList.forEach(item->{
item.set("storeId",storeMap.get(item.getString("storeCloudId")));
});
List<StoreRenew> entityList = RowUtil.toEntityList(rowList, StoreRenew.class);
Set<StoreRenew> filterStoreList = entityList.stream().filter(item -> item.getStoreId() != null ).collect(Collectors.toSet());
SpringUtils.getBean(StoreRenewService.class).saveBatch(filterStoreList);
/*getTestDynamicDataSource();
try {
DataSourceKey.use("dev");
//获取校区
@ -364,7 +392,7 @@ public class CpopImportTests {
SpringUtils.getBean(StoreRenewService.class).saveBatch(filterStoreList);
} finally {
DataSourceKey.clear();
}
}*/
}
/**
@ -391,8 +419,21 @@ public class CpopImportTests {
} finally {
DataSourceKey.clear();
}
getTestDynamicDataSource();
//获取校区
Map<String, String> storeMap = SpringUtils.getBean(StoreExtendService.class).list().stream().collect(Collectors.toMap(StoreExtend::getStoreCloudId, StoreExtend::getStoreId));
Map<String, String> brandMap = SpringUtils.getBean(BrandExtendService.class).list().stream().collect(Collectors.toMap(BrandExtend::getBrandCloudId, BrandExtend::getBrandId));
rowList.forEach(item->{
item.set("orderType",3);
item.set("brandId",brandMap.get(item.getString("brandCloudId")));
item.set("storeId",storeMap.get(item.getString("storeCloudId")));
});
List<EasyLearnOrder> entityList = RowUtil.toEntityList(rowList, EasyLearnOrder.class);
SpringUtils.getBean(EasyLearnOrderService.class).saveBatch(entityList);
/*getTestDynamicDataSource();
try {
DataSourceKey.use("dev");
//获取校区
Map<String, String> storeMap = SpringUtils.getBean(StoreExtendService.class).list().stream().collect(Collectors.toMap(StoreExtend::getStoreCloudId, StoreExtend::getStoreId));
Map<String, String> brandMap = SpringUtils.getBean(BrandExtendService.class).list().stream().collect(Collectors.toMap(BrandExtend::getBrandCloudId, BrandExtend::getBrandId));
@ -406,7 +447,7 @@ public class CpopImportTests {
SpringUtils.getBean(EasyLearnOrderService.class).saveBatch(entityList);
}finally {
DataSourceKey.clear();
}
}*/
}
/**
@ -492,13 +533,11 @@ public class CpopImportTests {
/**
* 手机号
*/
@JSONField(name = "phone")
private String phoneNumber;
private String phone;
/**
* 姓名
*/
@JSONField(name = "name")
private String name;
/**

View File

@ -74,8 +74,7 @@ public class StaffBo implements Serializable {
/**
* 昵称
*/
@NotBlank(message = "昵称不能为空")
@ApiModelProperty(value = "昵称",required = true)
@ApiModelProperty(value = "昵称")
private String nickName;
/**

View File

@ -14,6 +14,7 @@ import com.cpop.oam.business.vo.BrandManagePageVo;
import com.cpop.system.business.vo.StoreListByBrandVo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
@ -50,6 +51,7 @@ public class BrandManagerController {
*/
@ApiOperation("查询品牌管理员分页")
@GetMapping("/getBrandManagePage")
@PreAuthorize("@aps.hasPermission('brandStore:brandStaff:list')")
public R<Page<BrandManagePageVo>> getBrandManagePage(BrandManagerPageBo bo) {
Page<BrandManagePageVo> page = brandManageService.getBrandManagerPage(bo);
return R.ok(page);

View File

@ -2,7 +2,6 @@ package com.cpop.oam.business.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import org.checkerframework.checker.units.qual.C;
/**
* @author DB
@ -26,5 +25,5 @@ public class DataImportParamsDto {
/**
* 是否清空
*/
private String emptyTag;
private Integer emptyTag;
}

View File

@ -106,7 +106,7 @@ public class DataImportServiceImpl extends ServiceImpl<DataImportMapper, DataImp
public void importNow(DataImport dataImport) {
//读取数据
DataImportParamsDto dataImportParamsDto = new DataImportParamsDto();
dataImportParamsDto.setFileUrl(dataImport.getFileUrl()).setEmptyTag(dataImport.getIsClear() ? "清空" : "不清空");
dataImportParamsDto.setFileUrl(dataImport.getFileUrl()).setEmptyTag(dataImport.getIsClear() ? 1 : 0);
if (SourceType.valueOf(dataImport.getSourceType()) == SourceType.JAMBOX) {
StoreExtend storeExtend = SpringUtils.getBean(StoreExtendService.class).queryChain().where(STORE_EXTEND.STORE_ID.eq(dataImport.getStoreId())).one();
dataImportParamsDto.setStoreId(storeExtend.getStoreCloudId());

View File

@ -1,26 +1,23 @@
package com.cpop.oam.business.service.impl;
import com.cpop.api.tencent.wxWork.handler.WebHookSendHandler;
import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.base.table.SysUser;
import com.cpop.oam.business.dto.StaffDto;
import com.cpop.oam.business.vo.StaffPageVo;
import com.cpop.oam.business.vo.StaffVo;
import com.cpop.oam.framework.constant.WebHookKeyConstant;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.DbChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.cpop.common.utils.DateUtils;
import com.cpop.common.utils.StringUtils;
import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.utils.SpringUtils;
import com.cpop.oam.business.bo.DutyBo;
import com.cpop.oam.business.bo.DutyListBo;
import com.cpop.oam.business.dto.StaffDto;
import com.cpop.oam.business.entity.Duty;
import com.cpop.oam.business.entity.Staff;
import com.cpop.oam.business.mapper.DutyMapper;
import com.cpop.oam.business.service.DutyService;
import com.cpop.oam.business.service.StaffService;
import com.cpop.oam.business.vo.DutyListVo;
import com.cpop.oam.framework.constant.WebHookKeyConstant;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.DbChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -148,17 +145,19 @@ public class DutyServiceImpl extends ServiceImpl<DutyMapper, Duty> implements Du
LocalDate now = LocalDate.now();
//获取当天值班员工
Duty one = this.queryChain().where(DUTY.DUTY_DATE.eq(now)).one();
//获取当天技术值班人员
StaffDto staff = DbChain.table(SYS_USER).select(SYS_USER.PHONE_NUMBER, STAFF.NAME).from(SYS_USER)
.leftJoin(STAFF).on(STAFF.USER_ID.eq(SYS_USER.ID))
.where(STAFF.ID.eq(one.getTechnologyStaffId())).oneAs(StaffDto.class);
//技术售后群提醒
try {
webHookSendHandler.webHookSendText(WebHookKeyConstant.ORDER_INFO_BOT, Collections.singletonList(staff.getPhoneNumber()),
"===今日值班" + staff.getName() + "==="
, false);
} catch (IOException e) {
throw new ServiceException(e.getMessage());
if (one != null){
//获取当天技术值班人员
StaffDto staff = DbChain.table(SYS_USER).select(SYS_USER.PHONE_NUMBER, STAFF.NAME).from(SYS_USER)
.leftJoin(STAFF).on(STAFF.USER_ID.eq(SYS_USER.ID))
.where(STAFF.ID.eq(one.getTechnologyStaffId())).oneAs(StaffDto.class);
//技术售后群提醒
try {
webHookSendHandler.webHookSendText(WebHookKeyConstant.ORDER_INFO_BOT, Collections.singletonList(staff.getPhoneNumber()),
"===今日值班" + staff.getName() + "==="
, false);
} catch (IOException e) {
throw new ServiceException(e.getMessage());
}
}
}
}

View File

@ -78,7 +78,8 @@ public class FinanceReimburseServiceImpl extends ServiceImpl<FinanceReimburseMap
//用户id
.where(SYS_USER.ID.eq(loginUser.getUserId()))
//类型
.and(FINANCE_REIMBURSE.TYPE_ID.eq(bo.getTypeId())),
.and(FINANCE_REIMBURSE.TYPE_ID.eq(bo.getTypeId()))
.orderBy(FINANCE_REIMBURSE.UPDATE_TIME.desc()),
FinanceReimbursePageVo.class);
}
@ -123,7 +124,7 @@ public class FinanceReimburseServiceImpl extends ServiceImpl<FinanceReimburseMap
LocalDateTime now = LocalDateTime.now();
List<FinanceReimburseStage> financeReimburseStages = new ArrayList<>();
//审批批量转下款
if (list.get(0).getStatus() == 1) {
if (list.get(0).getStatus() == 0) {
Map<String, FinanceReimburse> idToPrice = list.stream().collect(Collectors.toMap(FinanceReimburse::getId, item->item));
list.forEach(item -> {
FinanceReimburseStage entity = new FinanceReimburseStage();
@ -137,13 +138,15 @@ public class FinanceReimburseServiceImpl extends ServiceImpl<FinanceReimburseMap
Map<String, List<FinanceReimburseStage>> stageMap = SpringUtils.getBean(FinanceReimburseStageService.class).queryChain()
.where(FINANCE_REIMBURSE_STAGE.FINANCE_REIMBURSE_ID.in(finishReimburseIds)).list()
.stream().collect(Collectors.groupingBy(FinanceReimburseStage::getFinanceReimburseId));
list.forEach(item->{
list.forEach(item -> {
FinanceReimburseStage entity = new FinanceReimburseStage();
if (stageMap.get(item.getId()) != null) {
//减去已下发的
FinanceReimburseStage entity = new FinanceReimburseStage();
entity.setStageAmount(item.getPrice().subtract(stageMap.get(item.getId()).stream().map(FinanceReimburseStage::getStageAmount).reduce(BigDecimal.ZERO, BigDecimal::add)));
item.setStatus(2);
} else {
entity.setFinanceReimburseId(item.getId()).setPaymentTime(now).setStageAmount(item.getPrice());
}
item.setStatus(2);
});
}
//批量修改
@ -193,11 +196,11 @@ public class FinanceReimburseServiceImpl extends ServiceImpl<FinanceReimburseMap
JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo();
List<FinanceReimburse> list = this.list(QueryWrapper.create()
.where(FINANCE_REIMBURSE.STAFF_ID.eq(loginUserInfo.getString("id")))
.and(FINANCE_REIMBURSE.STATUS.ne(4)));
.and(FINANCE_REIMBURSE.STATUS.ne(-1)));
//统计
ReimbursePersonStatisticVo vo = new ReimbursePersonStatisticVo();
vo.setUnPay(list.stream().filter(s -> s.getStatus() != 3).map(FinanceReimburse::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add));
vo.setHavePay(list.stream().filter(s -> s.getStatus() == 3).map(FinanceReimburse::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add));
vo.setUnPay(list.stream().filter(s -> s.getStatus() != 2).map(FinanceReimburse::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add));
vo.setHavePay(list.stream().filter(s -> s.getStatus() == 2).map(FinanceReimburse::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add));
return vo;
}

View File

@ -479,7 +479,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
TaskStaffGroupService taskStaffGroupService = SpringUtils.getBean(TaskStaffGroupService.class);
List<TaskStaffGroup> taskStaffGroups = taskStaffGroupService.queryChain().where(TASK_STAFF_GROUP.TASK_ID.eq(taskId)).list();
//逾期完成3天内只计算有效绩点的80%
if (day < 3) {
if (day <= 3) {
//3天以上50%
taskStaffGroups.forEach(item -> {
//向下取整

View File

@ -192,7 +192,7 @@ public class TaskWorkOrderServiceImpl extends ServiceImpl<TaskWorkOrderMapper, T
PageDomain pageDomain = SqlUtils.getInstance().getPageDomain();
return this.mapper.paginateAs(Page.of(pageDomain.getPageNum(), pageDomain.getPageSize()),
QueryWrapper.create()
.select(TASK_WORK_ORDER.FINISH_STAFF_ID, TASK_WORK_ORDER.FINISH_TIME)
.select(TASK_WORK_ORDER.ID, TASK_WORK_ORDER.FINISH_STAFF_ID, TASK_WORK_ORDER.FINISH_TIME)
.select(TASK.TASK_CONTENT)
.from(TASK_WORK_ORDER)
.leftJoin(TASK)

View File

@ -6,7 +6,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
@ -19,6 +18,12 @@ import java.time.LocalDateTime;
@ApiModel(value = "TaskWorkOrderPageVo对象", description = "任务-工单-记录")
public class TaskWorkOrderPageVo {
/**
* 工单id
*/
@ApiModelProperty("工单id")
private String id;
/**
* 任务内容
*/

View File

@ -5,6 +5,7 @@ import com.cpop.system.business.bo.StorePageBo;
import com.cpop.system.business.vo.StorePageVo;
import com.mybatisflex.core.paginate.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
@ -33,6 +34,7 @@ public class StoreController {
* @Author Administrator
* @Date: 2023/6/7 0007 10:18
*/
@PreAuthorize("@aps.hasPermission('brandStore:store:list')")
@ApiOperation("查询校区分页列表")
@GetMapping("/getStorePage")
public R<Page<StorePageVo>> getStorePage(StorePageBo bo) {

View File

@ -6,20 +6,19 @@ import com.cpop.system.business.bo.StoreRenewPageBo;
import com.cpop.system.business.bo.StoreRenewXmlBo;
import com.cpop.system.business.bo.StoreRunOffBo;
import com.cpop.system.business.dto.StoreRenewDto;
import com.cpop.system.business.service.StoreSignService;
import com.cpop.system.business.vo.StoreRenewPageVo;
import com.mybatisflex.core.paginate.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.cpop.system.business.service.StoreSignService;
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.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
/**
* 校区-签约表 控制层

View File

@ -1,5 +1,6 @@
package com.cpop.system.business.service.impl;
import com.cpop.common.utils.StringUtils;
import com.cpop.core.base.entity.PageDomain;
import com.cpop.core.utils.SpringUtils;
import com.cpop.core.utils.sql.SqlUtils;
@ -46,6 +47,12 @@ public class StoreSignServiceImpl extends ServiceImpl<StoreSignMapper, StoreSign
public Page<StoreRenewPageVo> getStoreRenewPage(StoreRenewPageBo bo) {
PageDomain pageDomain = SqlUtils.getInstance().getPageDomain();
QueryWrapper queryWrapper = QueryWrapper.create();
if (StringUtils.isNotBlank(bo.getAddrOrName())){
queryWrapper.and(STORE_LICENSE.LICENSE_ADDR.like(bo.getAddrOrName()).or(STORE_LICENSE.LICENSE_NAME.like(bo.getAddrOrName())));
}
if (StringUtils.isNotBlank(bo.getBrandOrStore())){
queryWrapper.and(BRAND.BRAND_NAME.like(bo.getBrandOrStore()).or(STORE.STORE_NAME.like(bo.getBrandOrStore())));
}
switch (bo.getRenewStatus()){
//待续费
case 0:
@ -69,9 +76,7 @@ public class StoreSignServiceImpl extends ServiceImpl<StoreSignMapper, StoreSign
.leftJoin(BRAND).on(BRAND.ID.eq(STORE.BRAND_ID))
.leftJoin(STORE_LICENSE).on(STORE_LICENSE.STORE_ID.eq(STORE.ID))
.leftJoin(STORE_SIGN).on(STORE_SIGN.STORE_ID.eq(STORE.ID))
.leftJoin("cp_oam_staff").as("cos").on("`cos`.`id` = cp_sys_store_renew.renew_staff_id")
.and(BRAND.BRAND_NAME.like(bo.getBrandOrStore()).or(STORE.STORE_NAME.like(bo.getBrandOrStore())))
.and(STORE_LICENSE.LICENSE_ADDR.like(bo.getAddrOrName()).or(STORE_LICENSE.LICENSE_NAME.like(bo.getAddrOrName()))),
.leftJoin("cp_oam_staff").as("cos").on("`cos`.`id` = cp_sys_store_renew.renew_staff_id"),
StoreRenewPageVo.class);
//已流失
default:
@ -89,12 +94,10 @@ public class StoreSignServiceImpl extends ServiceImpl<StoreSignMapper, StoreSign
.leftJoin(BRAND).on(BRAND.ID.eq(STORE.BRAND_ID))
.leftJoin(STORE_LICENSE).on(STORE_LICENSE.STORE_ID.eq(STORE.ID))
.leftJoin(STORE_RENEW).on(STORE_RENEW.STORE_ID.eq(STORE.ID))
.leftJoin("cp_oam_staff").as("cos").on("`cos`.`id` = `cp_sys_store_renew`.`renew_staff_id`")
.and(BRAND.BRAND_NAME.like(bo.getBrandOrStore()).or(STORE.STORE_NAME.like(bo.getBrandOrStore())))
.and(STORE_LICENSE.LICENSE_ADDR.like(bo.getAddrOrName()).or(STORE_LICENSE.LICENSE_NAME.like(bo.getAddrOrName()))),
.leftJoin("cp_oam_staff").as("cos").on("`cos`.`id` = `cp_sys_store_renew`.`renew_staff_id`"),
StoreRenewPageVo.class,
//子查询
item -> item.field(StoreRenewPageVo::getLastUpdateUserId)
item -> item.field(StoreRenewPageVo::getLastUpdateStaffName)
.queryWrapper(updateStaff -> queryChain()
.select("name")
.from("cp_oam_staff")