Просмотр исходного кода

//TTreciver

release_toaliyun_real
xhxu 4 лет назад
Родитель
Сommit
6910f32c72
10 измененных файлов: 274 добавлений и 5 удалений
  1. +53
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java
  2. +3
    -0
      mallinkAdmin/src/main/resources/db/migration/V2022031700001__sharingReceiver.sql
  3. +89
    -0
      mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java
  4. +6
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxProfitSharingReceiver.java
  5. +1
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxMerchantMapper.java
  6. +3
    -0
      mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java
  7. +4
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java
  8. +95
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java
  9. +14
    -0
      mallinkService/src/main/resources/mapper/WxMerchantMapper.xml
  10. +6
    -1
      mallinkService/src/main/resources/mapper/WxProfitSharingReceiverMapper.xml

+ 53
- 2
mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java Просмотреть файл

@@ -4,9 +4,12 @@ import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.annotation.UserDataRuleAnnotation;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxProfitSharingReceiver;
@@ -16,8 +19,7 @@ import com.iformall.domain.vo.WxMerchantVo;
import com.iformall.enums.EnumAppPlat;
import com.iformall.enums.EnumMerchantStatus;
import com.iformall.enums.EnumPayWay;
import com.iformall.service.QrCodeService;
import com.iformall.service.WxMerchantService;
import com.iformall.service.*;
import com.iformall.utils.Constant;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -45,6 +47,14 @@ public class WxMerchantController extends BaseController {
@Autowired
private QrCodeService qrCodeService;

@Autowired
private WxAppinfoService wxAppinfoService;
@Autowired
private WxPayAccountService payAccountService;

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;

@UserDataRuleAnnotation("merchant_list")
@ApiOperation("分页列表接口")
@GetMapping("listVo")
@@ -331,4 +341,45 @@ public class WxMerchantController extends BaseController {
wxMerchantService.exportUserTradeList(wxMerchant, request,response);
}

@ApiOperation("刷新进件页面")
@GetMapping("/updateTtReceiver")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "商户-删除")
public ResultData updateTtReceiver(Long id) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::updateTtReceiver");
WxMerchant merchant = wxMerchantService.selectById(id);
if(merchant == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxAppinfo appInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO);
if(appInfo == null) {
return new ResultData(ErrorCode.APP_ID_NOT_FOUND);
}
WxPayAccount payAcount = payAccountService.getById(appInfo.getPayId());
if(payAcount == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND);
}
return wxProfitSharingReceiverService.updateTtReceiver(merchant,appInfo.getAppId(),payAcount.getMerchantApiKey());
}

@ApiOperation("修改可用状态")
@GetMapping("/updateTtReceiverIsUse")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "商户-删除")
public ResultData updateTtReceiverIsUse(Long id) {
WxMerchant merchant = wxMerchantService.selectById(id);
if(merchant == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxAppinfo appInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO);
if(appInfo == null) {
return new ResultData(ErrorCode.APP_ID_NOT_FOUND);
}
WxPayAccount payAcount = payAccountService.getById(appInfo.getPayId());
if(payAcount == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND);
}
return wxProfitSharingReceiverService.updateTtReceiverIsUse(merchant,appInfo.getAppId(),payAcount.getMerchantApiKey());
}

}

+ 3
- 0
mallinkAdmin/src/main/resources/db/migration/V2022031700001__sharingReceiver.sql Просмотреть файл

@@ -0,0 +1,3 @@
ALTER TABLE `mallink`.`wx_profit_sharing_receiver`
ADD COLUMN `tt_import_url` varchar(500) COMMENT '进件页面' AFTER `plat`,
ADD COLUMN `tt_balance_url` varchar(500) COMMENT '余额页面' AFTER `tt_import_url`;

+ 89
- 0
mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java Просмотреть файл

@@ -0,0 +1,89 @@
package com.iformall.schedule;

import com.iformall.domain.po.*;
import com.iformall.enums.*;
import com.iformall.mapper.WxMerchantMapper;
import com.iformall.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @author gongbiao
*/
@Component
public class TtMerchantReciverSchedule {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMallService wxMallService;

@Autowired
private WxMerchantMapper wxMerchantMapper;

@Autowired
private WxAppinfoService wxAppinfoService;

@Autowired
private WxPayAccountService payAccountService;

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;


/**
* 每天0点执行
*/
@Scheduled(cron = "0 0 0 * * ?")
// @Scheduled(cron = "0 */5 * * * *?") //测试五分钟执行
public void updateMerchantReciverSchedule() {
WxMall mallQ = new WxMall();
mallQ.setSaleType(EnumSaleType.TT_ALL_ROUND.getCode());
List<WxMall> mallList = wxMallService.findList(mallQ);
if(mallList == null || mallList.isEmpty()){
return;
}
List<String> tenantIds = mallList.stream().map(m -> m.getTenantId()).collect(Collectors.toList());

List<WxMerchant> merchants = wxMerchantMapper.findByTenantIds(tenantIds);
if(merchants == null || merchants.isEmpty()){
return;
}

Map<String, String> appIdMap = new HashMap<>();
Map<String, String> payAccountKeyMap = new HashMap<>();
WxAppinfo appQ = new WxAppinfo();
appQ.setType(EnumAppType.C.getCode());
appQ.setPlat(EnumPayWay.PAY_WAY_TT.getPlat().getCode());
List<WxAppinfo> wxAppinfoList = wxAppinfoService.getList(appQ);
for (WxAppinfo wxAppinfo:wxAppinfoList) {
appIdMap.put(wxAppinfo.getTenantId(),wxAppinfo.getAppId());
WxPayAccount wxPayAccount = payAccountService.getById(wxAppinfo.getId());
payAccountKeyMap.put(wxAppinfo.getTenantId(),wxPayAccount.getApiKey());
}

for (WxMerchant m:merchants) {
try {
wxProfitSharingReceiverService.updateTtReceiver(m,appIdMap.get(m.getTenantId()),payAccountKeyMap.get(m.getTenantId()));
} catch (Exception e) {
e.printStackTrace();
logger.error("TtMerchantReciverSchedule error.updateTtReceiver:"+m.getId(),e);
}
try {
wxProfitSharingReceiverService.updateTtReceiverIsUse(m,appIdMap.get(m.getTenantId()),payAccountKeyMap.get(m.getTenantId()));
} catch (Exception e) {
e.printStackTrace();
logger.error("TtMerchantReciverSchedule error.updateTtReceiver:"+m.getId(),e);
}
}
}

}

+ 6
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxProfitSharingReceiver.java Просмотреть файл

@@ -49,4 +49,10 @@ public class WxProfitSharingReceiver extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value = "是否使用 0,不使用 1,使用", name = "isUse")
private Integer isUse;

@io.swagger.annotations.ApiModelProperty(value = "进件页面", name = "ttImportUrl")
private String ttImportUrl;

@io.swagger.annotations.ApiModelProperty(value = "余额页面", name = "ttBalanceUrl")
private String ttBalanceUrl;

}

+ 1
- 0
mallinkService/src/main/java/com/iformall/mapper/WxMerchantMapper.java Просмотреть файл

@@ -17,6 +17,7 @@ public interface WxMerchantMapper extends CommonMapper<WxMerchant, Long> {

List<WxMerchant> findList(WxMerchant wxMerchant);
List<Long> findIdList(WxMerchant wxMerchant);
List<WxMerchant> findByTenantIds(@Param("tenantIds")List<String> tenantIds);
List<WxMerchant> findIdNameList(WxMerchant wxMerchant);


+ 3
- 0
mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java Просмотреть файл

@@ -53,4 +53,7 @@ public interface WxProfitSharingReceiverService {

void sendMsg(String phone, String account, String merchant, String time, Integer modelType, TenantEntity tenantEntity);

ResultData updateTtReceiver(WxMerchant merchant, String appId, String payAccountKey);

ResultData updateTtReceiverIsUse(WxMerchant merchant, String appId, String payAccountKey);
}

+ 4
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java Просмотреть файл

@@ -251,6 +251,10 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
psReceiverQ.setMerchantId(sharingOrderDto.getMerchantId());
psReceiverQ.setSharingType(payServiceFactory.getPayShareAdapterService(payWay).getProfitSharingType());
psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
psReceiverQ.setPlat(EnumPayWay.getEnum(payWay).getPlat().getCode());
if(EnumAppPlat.TOUTIAO.getCode().equals(psReceiverQ.getPlat())){
psReceiverQ.setIsUse(EnumProfitSharingUse.YES.getCode());
}
List<WxProfitSharingReceiver> psReceiverList = wxProfitSharingReceiverMapper.findList(psReceiverQ);
if (psReceiverList.size() < 0 || psReceiverList.size() > 50) {
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID);


+ 95
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java Просмотреть файл

@@ -16,6 +16,11 @@ import com.iformall.domain.po.WxProfitSharingReceiver;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.po.msg.WxMsgRecord;
import com.iformall.domain.vo.WxMerchantVo;
import com.iformall.douyin.pay.DouYinPayHelper;
import com.iformall.douyin.pay.enums.AppAddSubMerchantUrlType;
import com.iformall.douyin.pay.orderQuery.QueryMerchantResult;
import com.iformall.douyin.pay.preOrder.AppAddSubMerchant;
import com.iformall.douyin.pay.preOrder.AppAddSubMerchantResult;
import com.iformall.enums.*;
import com.iformall.mapper.WxAppinfoMapper;
import com.iformall.mapper.WxMerchantMapper;
@@ -88,12 +93,16 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv

@Override
public void saveOrUpdate(WxProfitSharingReceiver record) {
Date date = new Date();
if (record.getId() == null) {
//record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateTime(date);
record.setUpdateTime(date);
wxProfitSharingReceiverMapper.insert(record);
} else {
record.setUpdateTime(date);
wxProfitSharingReceiverMapper.updateById(record);
}
}
@@ -104,14 +113,19 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
}


//todo 微信和抖音分账可能存在两个分账信息
@Override
public WxProfitSharingReceiver findReceiver(WxMerchant merchant) {
WxProfitSharingReceiver receiver = new WxProfitSharingReceiver();
receiver.updateTenantInfo(merchant);
receiver.setMerchantId(merchant.getId());
receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
// receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
return wxProfitSharingReceiverMapper.selectOne(new QueryWrapper(receiver));
List<WxProfitSharingReceiver> list = wxProfitSharingReceiverMapper.findList(receiver);
if(list != null && list.size() > 0){
return list.get(0);
}
return null;
}


@@ -230,6 +244,84 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
logger.info("》》》》》》》》》》》");
}

@Override
public ResultData updateTtReceiver(WxMerchant merchant, String appId, String payAccountKey) {
if(merchant == null || StringUtils.isBlank(appId) || StringUtils.isBlank(payAccountKey)) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxProfitSharingReceiver oldReceiver = new WxProfitSharingReceiver();
oldReceiver.updateTenantInfo(merchant);
oldReceiver.setMerchantId(merchant.getId());
oldReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN.getCode());
oldReceiver.setPlat(EnumAppPlat.TOUTIAO.getCode());
WxProfitSharingReceiver wxProfitSharingReceiver = wxProfitSharingReceiverMapper.selectOne(new QueryWrapper(oldReceiver));
if(wxProfitSharingReceiver == null){
wxProfitSharingReceiver = oldReceiver;
wxProfitSharingReceiver.setReceiverType(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getCode());
wxProfitSharingReceiver.setReceiverAccount("0");
wxProfitSharingReceiver.setIsUse(EnumProfitSharingUse.APPLY.getCode());
wxProfitSharingReceiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
this.saveOrUpdate(wxProfitSharingReceiver);
}
//进件页面
AppAddSubMerchantResult improt_URLResult = appAddSubMerchant(appId,payAccountKey,merchant.getId().toString(),AppAddSubMerchantUrlType.improt_URL);
if(improt_URLResult.isSuccess()){
wxProfitSharingReceiver.setReceiverAccount(improt_URLResult.getMerchantId());
wxProfitSharingReceiver.setTtImportUrl(improt_URLResult.getUrl());
}else{
logger.error("获取进件页面 error{}"+improt_URLResult.getMsg());
}
//余额页面
AppAddSubMerchantResult balance_URLResult = appAddSubMerchant(appId,payAccountKey,merchant.getId().toString(),AppAddSubMerchantUrlType.Balance_URL);
if(balance_URLResult.isSuccess()){
wxProfitSharingReceiver.setReceiverAccount(improt_URLResult.getMerchantId());
wxProfitSharingReceiver.setTtBalanceUrl(balance_URLResult.getMerchantId());
}else{
logger.error("获取余额页面 error{}"+improt_URLResult.getMsg());
}
this.saveOrUpdate(wxProfitSharingReceiver);
return new ResultData();
}

@Override
public ResultData updateTtReceiverIsUse(WxMerchant merchant, String appId, String payAccountKey) {
if(merchant == null || StringUtils.isBlank(appId) || StringUtils.isBlank(payAccountKey)) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxProfitSharingReceiver oldReceiver = new WxProfitSharingReceiver();
oldReceiver.updateTenantInfo(merchant);
oldReceiver.setMerchantId(merchant.getId());
oldReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN.getCode());
oldReceiver.setPlat(EnumAppPlat.TOUTIAO.getCode());
WxProfitSharingReceiver wxProfitSharingReceiver = wxProfitSharingReceiverMapper.selectOne(new QueryWrapper(oldReceiver));
if(wxProfitSharingReceiver == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到分账信息");
}
QueryMerchantResult queryMerchantResult = DouYinPayHelper.queryMerchantStatus(appId, payAccountKey, wxProfitSharingReceiver.getReceiverAccount(), wxProfitSharingReceiver.getMerchantId().toString(), null);
if(queryMerchantResult != null){
if(queryMerchantResult.getWx().intValue() != 1){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"微信渠道未进件成功!");
}
if(queryMerchantResult.getAlipay().intValue() != 1){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"支付宝渠道未进件成功!");
}
wxProfitSharingReceiver.setIsUse(EnumProfitSharingUse.YES.getCode());
this.saveOrUpdate(wxProfitSharingReceiver);
return new ResultData();
}else{
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"查询进件状态出错!");
}
}

private AppAddSubMerchantResult appAddSubMerchant(String appId, String payAccountKey, String merchantId, AppAddSubMerchantUrlType appAddSubMerchantUrlType){
AppAddSubMerchant appAddSubMerchant = new AppAddSubMerchant();
appAddSubMerchant.setAppId(appId);
appAddSubMerchant.setSalt(payAccountKey);
appAddSubMerchant.setSubMerchantId(merchantId);
appAddSubMerchant.setUrlType(appAddSubMerchantUrlType.getCode());
return DouYinPayHelper.appAddSubMerchant(appAddSubMerchant);
}

@Override
public ResultData delReceiver(WxProfitSharingReceiver receiver, Integer send) {
WxAppinfo appInfo = new WxAppinfo();
@@ -284,6 +376,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
oldReceiver.setMerchantId(merchant.getId());
oldReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
oldReceiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
oldReceiver.setPlat(payWay.getPlat().getCode());
List<WxProfitSharingReceiver> delList = wxProfitSharingReceiverMapper.selectList(new QueryWrapper(oldReceiver));
oldReceiver.setReceiverAccount(receiver.getReceiverAccount());
oldReceiver.setReceiverType(receiver.getReceiverType());


+ 14
- 0
mallinkService/src/main/resources/mapper/WxMerchantMapper.xml Просмотреть файл

@@ -182,6 +182,20 @@
from wx_merchant m
<include refid="dynamicWhereConditions"/>
</select>

<select id="findByTenantIds" parameterType="java.util.Map" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_merchant m
where m.is_del = 0
and m.`status` = 1
<if test=" null != tenantIds ">
and m.tenant_id in
<foreach collection="tenantIds" index="index" item="tenantId" open="(" separator="," close=")">
#{tenantId}
</foreach>
</if>
</select>
<select id="findIdList" parameterType="com.iformall.domain.po.WxMerchant" resultType="Long">
select id


+ 6
- 1
mallinkService/src/main/resources/mapper/WxProfitSharingReceiverMapper.xml Просмотреть файл

@@ -20,7 +20,7 @@
</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`receiver_type`,`receiver_account`,`receiver_comments`,`create_time`,`update_time`,`sharing_type`,`bank_no`,`true_name`,`bank_code`,`status`,`parameter`
`id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`receiver_type`,`receiver_account`,`receiver_comments`,`create_time`,`update_time`,`sharing_type`,`bank_no`,`true_name`,`bank_code`,`status`,`parameter`,`is_use`
</sql>

<sql id="dynamicWhereConditions">
@@ -93,6 +93,11 @@

</if>

<if test=" null !=isUse ">
and `is_use` = #{isUse}

</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


Загрузка…
Отмена
Сохранить