parent
0a7e1a7eb4
commit
5a715dcb9f
@ -0,0 +1,42 @@ |
|||||||
|
package com.hfkj.service; |
||||||
|
|
||||||
|
import com.hfkj.entity.BsBankActivityRosterRate; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: BsBankActivityRosterRateService |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2023/5/18 |
||||||
|
**/ |
||||||
|
public interface BsBankActivityRosterRateService { |
||||||
|
|
||||||
|
/** |
||||||
|
* 编辑数据 |
||||||
|
* @param bankActivityRosterRate |
||||||
|
*/ |
||||||
|
void editData(BsBankActivityRosterRate bankActivityRosterRate); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询费率列表 |
||||||
|
* @param rosterId |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
List<BsBankActivityRosterRate> getListByRosterId(Long rosterId); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询费率列表 |
||||||
|
* @param activityId |
||||||
|
* @param merId |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
List<BsBankActivityRosterRate> getListByMerId(Long activityId,Long merId); |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据id查询 |
||||||
|
* @param id |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
BsBankActivityRosterRate getRosterRateById(Long id); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
package com.hfkj.service; |
||||||
|
|
||||||
|
import com.hfkj.entity.BsBankActivityRoster; |
||||||
|
import com.hfkj.entity.BsBankActivityRosterRate; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: BsBankActivityRosterService |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2023/5/18 |
||||||
|
**/ |
||||||
|
public interface BsBankActivityRosterService { |
||||||
|
|
||||||
|
/** |
||||||
|
* 编辑数据 |
||||||
|
* @param bankActivityRoster |
||||||
|
*/ |
||||||
|
void editData(BsBankActivityRoster bankActivityRoster); |
||||||
|
|
||||||
|
/** |
||||||
|
* 报名活动 |
||||||
|
* @param bankActivityId |
||||||
|
* @param merId |
||||||
|
*/ |
||||||
|
void enrollActivity(Long bankActivityId, Long merId) throws Exception; |
||||||
|
|
||||||
|
/** |
||||||
|
* 配置费率 |
||||||
|
* @param bankActivityRosterRateList |
||||||
|
*/ |
||||||
|
void configRosterRate(Long bankActivityId, Long merId, List<BsBankActivityRosterRate> bankActivityRosterRateList) throws Exception; |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询报名列表 |
||||||
|
* @param param |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
List<BsBankActivityRoster> getActivityRosterList(Map<String, Object> param); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询报名 |
||||||
|
* @param bankActivityId |
||||||
|
* @param merId |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
BsBankActivityRoster getActivityRoster(Long bankActivityId, Long merId); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,74 @@ |
|||||||
|
package com.hfkj.service.impl; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray; |
||||||
|
import com.hfkj.dao.BsBankActivityRosterRateMapper; |
||||||
|
import com.hfkj.entity.BsBankActivityRosterRate; |
||||||
|
import com.hfkj.entity.BsBankActivityRosterRateExample; |
||||||
|
import com.hfkj.service.BsBankActivityRosterRateService; |
||||||
|
import jdk.nashorn.internal.ir.annotations.Reference; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: BsBankActivityRosterRateServiceImpl |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2023/5/18 |
||||||
|
**/ |
||||||
|
@Service("bankActivityRosterRateService") |
||||||
|
public class BsBankActivityRosterRateServiceImpl implements BsBankActivityRosterRateService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsBankActivityRosterRateMapper bsBankActivityRosterRateMapper; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void editData(BsBankActivityRosterRate bankActivityRosterRate) { |
||||||
|
if (bankActivityRosterRate.getId() == null) { |
||||||
|
bankActivityRosterRate.setCreateTime(new Date()); |
||||||
|
bankActivityRosterRate.setUpdateTime(new Date()); |
||||||
|
bsBankActivityRosterRateMapper.insert(bankActivityRosterRate); |
||||||
|
} else { |
||||||
|
bankActivityRosterRate.setUpdateTime(new Date()); |
||||||
|
bsBankActivityRosterRateMapper.updateByPrimaryKey(bankActivityRosterRate); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<BsBankActivityRosterRate> getListByRosterId(Long rosterId) { |
||||||
|
BsBankActivityRosterRateExample example = new BsBankActivityRosterRateExample(); |
||||||
|
example.createCriteria().andBankActivityRosterIdEqualTo(rosterId); |
||||||
|
example.setOrderByClause("start_time"); |
||||||
|
List<BsBankActivityRosterRate> rates = bsBankActivityRosterRateMapper.selectByExample(example); |
||||||
|
for (BsBankActivityRosterRate bankActivityRosterRate : rates) { |
||||||
|
JSONArray rateArray = JSONArray.parseArray(bankActivityRosterRate.getRates()); |
||||||
|
bankActivityRosterRate.setRateArray(rateArray); |
||||||
|
|
||||||
|
if (StringUtils.isBlank(bankActivityRosterRate.getPreferentialRates())) { |
||||||
|
if (rateArray.size() > 0) { |
||||||
|
bankActivityRosterRate.setExt1(rateArray.get(0).toString()); |
||||||
|
} else { |
||||||
|
bankActivityRosterRate.setExt1("0"); |
||||||
|
} |
||||||
|
} else { |
||||||
|
bankActivityRosterRate.setExt1(bankActivityRosterRate.getPreferentialRates()); |
||||||
|
} |
||||||
|
} |
||||||
|
return rates; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<BsBankActivityRosterRate> getListByMerId(Long activityId, Long merId) { |
||||||
|
BsBankActivityRosterRateExample example = new BsBankActivityRosterRateExample(); |
||||||
|
example.createCriteria().andBankActivityIdEqualTo(activityId).andMerIdEqualTo(merId); |
||||||
|
example.setOrderByClause("create_time desc"); |
||||||
|
return bsBankActivityRosterRateMapper.selectByExample(example); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BsBankActivityRosterRate getRosterRateById(Long id) { |
||||||
|
return bsBankActivityRosterRateMapper.selectByPrimaryKey(id); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,155 @@ |
|||||||
|
package com.hfkj.service.impl; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.channel.saas.SaasActivityService; |
||||||
|
import com.hfkj.common.exception.ErrorCode; |
||||||
|
import com.hfkj.common.exception.ErrorHelp; |
||||||
|
import com.hfkj.common.exception.SysCode; |
||||||
|
import com.hfkj.dao.BsBankActivityRosterMapper; |
||||||
|
import com.hfkj.entity.*; |
||||||
|
import com.hfkj.service.BsBankActivityRosterRateService; |
||||||
|
import com.hfkj.service.BsBankActivityRosterService; |
||||||
|
import com.hfkj.service.BsBankActivityService; |
||||||
|
import com.hfkj.service.BsMerPlatformNoService; |
||||||
|
import com.hfkj.sysenum.PlatformTypeEnum; |
||||||
|
import org.apache.commons.collections4.ListUtils; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Propagation; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: BsBankActivityRosterServiceImpl |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2023/5/18 |
||||||
|
**/ |
||||||
|
@Service("bankActivityRosterService") |
||||||
|
public class BsBankActivityRosterServiceImpl implements BsBankActivityRosterService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsBankActivityRosterMapper bsBankActivityRosterMapper; |
||||||
|
@Resource |
||||||
|
private BsBankActivityService bankActivityService; |
||||||
|
@Resource |
||||||
|
private BsBankActivityRosterRateService bankActivityRosterRateService; |
||||||
|
@Resource |
||||||
|
private BsMerPlatformNoService merPlatformNoService; |
||||||
|
@Resource |
||||||
|
private SaasActivityService saasActivityService; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void editData(BsBankActivityRoster bankActivityRoster) { |
||||||
|
if (bankActivityRoster.getId() == null) { |
||||||
|
bankActivityRoster.setUpdateTime(new Date()); |
||||||
|
bankActivityRoster.setCreateTime(new Date()); |
||||||
|
bsBankActivityRosterMapper.insert(bankActivityRoster); |
||||||
|
} else { |
||||||
|
bankActivityRoster.setUpdateTime(new Date()); |
||||||
|
bsBankActivityRosterMapper.updateByPrimaryKey(bankActivityRoster); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
||||||
|
public void enrollActivity(Long bankActivityId, Long merId) throws Exception { |
||||||
|
// 查询报名
|
||||||
|
BsBankActivityRoster roster = getActivityRoster(bankActivityId, merId); |
||||||
|
if (roster != null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请勿重复报名"); |
||||||
|
} |
||||||
|
// 查询活动
|
||||||
|
BsBankActivity activity = bankActivityService.getBankActivityById(bankActivityId); |
||||||
|
if (activity == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的活动"); |
||||||
|
} |
||||||
|
// 查询平台
|
||||||
|
BsMerPlatformNo merPlatform = merPlatformNoService.getPlatformNo(merId, PlatformTypeEnum.type1); |
||||||
|
if (merPlatform == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); |
||||||
|
} |
||||||
|
// 渠道报名
|
||||||
|
saasActivityService.customerRegisterActivity(activity.getActivityNo().toString(), null, Arrays.asList(merPlatform.getCupNo())); |
||||||
|
|
||||||
|
BsBankActivityRoster bankActivityRoster = new BsBankActivityRoster(); |
||||||
|
bankActivityRoster.setBankActivityId(bankActivityId); |
||||||
|
bankActivityRoster.setMerId(merId); |
||||||
|
bankActivityRoster.setPlatformNo(merPlatform.getPlatformNo()); |
||||||
|
bankActivityRoster.setCupNo(merPlatform.getCupNo()); |
||||||
|
bankActivityRoster.setStatus(1); |
||||||
|
editData(bankActivityRoster); |
||||||
|
|
||||||
|
// 查询渠道费率
|
||||||
|
JSONArray rates = saasActivityService.queryCustomerRates(activity.getActivityNo().toString(), merPlatform.getPlatformNo()); |
||||||
|
for (Object obj : rates) { |
||||||
|
JSONObject rate = (JSONObject) obj; |
||||||
|
BsBankActivityRosterRate rosterRate = new BsBankActivityRosterRate(); |
||||||
|
rosterRate.setBankActivityId(bankActivityId); |
||||||
|
rosterRate.setBankActivityRosterId(bankActivityRoster.getId()); |
||||||
|
rosterRate.setMerId(bankActivityRoster.getMerId()); |
||||||
|
rosterRate.setPlatformNo(bankActivityRoster.getPlatformNo()); |
||||||
|
rosterRate.setCupNo(bankActivityRoster.getCupNo()); |
||||||
|
rosterRate.setWelfareRatesId(rate.getLong("welfareRatesId")); |
||||||
|
rosterRate.setStartTime(rate.getDate("start")); |
||||||
|
rosterRate.setEndTime(rate.getDate("end")); |
||||||
|
rosterRate.setRates(rate.getString("rates")); |
||||||
|
rosterRate.setStatus(2); |
||||||
|
bankActivityRosterRateService.editData(rosterRate); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
||||||
|
public void configRosterRate(Long bankActivityId, Long merId, List<BsBankActivityRosterRate> bankActivityRosterRateList) throws Exception { |
||||||
|
BsBankActivity activity = bankActivityService.getBankActivityById(bankActivityId); |
||||||
|
if (activity == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||||
|
} |
||||||
|
BsMerPlatformNo platformNo = merPlatformNoService.getPlatformNo(merId, PlatformTypeEnum.type1); |
||||||
|
if (platformNo == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||||
|
} |
||||||
|
for (BsBankActivityRosterRate rosterRate : bankActivityRosterRateList) { |
||||||
|
BsBankActivityRosterRate rate = bankActivityRosterRateService.getRosterRateById(rosterRate.getId()); |
||||||
|
if (rate == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||||
|
} |
||||||
|
rate.setPreferentialRates(rosterRate.getPreferentialRates()); |
||||||
|
rate.setStatus(1); |
||||||
|
bankActivityRosterRateService.editData(rate); |
||||||
|
} |
||||||
|
|
||||||
|
Map<String, Object> rate; |
||||||
|
List<Map<String,Object>> rates = new ArrayList<>(); |
||||||
|
for (BsBankActivityRosterRate obj : bankActivityRosterRateList) { |
||||||
|
rate = new HashMap<>(); |
||||||
|
rate.put("welfareRatesId", obj.getWelfareRatesId()); |
||||||
|
rate.put("discountedRates", obj.getPreferentialRates()); |
||||||
|
rates.add(rate); |
||||||
|
} |
||||||
|
|
||||||
|
saasActivityService.customerRatesUpdate(activity.getActivityNo().toString(), platformNo.getCupNo(), rates); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<BsBankActivityRoster> getActivityRosterList(Map<String, Object> param) { |
||||||
|
BsBankActivityRosterExample example = new BsBankActivityRosterExample(); |
||||||
|
example.createCriteria(); |
||||||
|
return bsBankActivityRosterMapper.selectByExample(example); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BsBankActivityRoster getActivityRoster(Long bankActivityId, Long merId) { |
||||||
|
BsBankActivityRosterExample example = new BsBankActivityRosterExample(); |
||||||
|
example.createCriteria().andBankActivityIdEqualTo(bankActivityId).andMerIdEqualTo(merId); |
||||||
|
List<BsBankActivityRoster> list = bsBankActivityRosterMapper.selectByExample(example); |
||||||
|
if (list.size() > 0) { |
||||||
|
BsBankActivityRoster roster = list.get(0); |
||||||
|
roster.setBankActivityRosterRateList(bankActivityRosterRateService.getListByRosterId(roster.getId())); |
||||||
|
return roster; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue