add file
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.AppMenu;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* app页面菜单 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-09-27
|
||||
*/
|
||||
public interface AppMenuService extends IService<AppMenu> {
|
||||
|
||||
List<Map<String, Object>> getHomeMenu(HttpServletRequest request);
|
||||
|
||||
List<Map<String, Object>> getSpreadPageMenu(HttpServletRequest request);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.BankCard;
|
||||
import cn.pluss.platform.mapper.BankCardMapper;
|
||||
import cn.pluss.platform.vo.BankCardRecordVO;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 银行卡信息 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-10-16
|
||||
*/
|
||||
public interface BankCardService extends IService<BankCard> {
|
||||
|
||||
/**
|
||||
* 获取商户的结算银行卡信息
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 商户结算银行卡信息
|
||||
*/
|
||||
List<Map<String, Object>> getAccBankCardList(String userId);
|
||||
|
||||
/**
|
||||
* 保存实名银行卡信息
|
||||
* @param entity 银行卡信息
|
||||
* @return
|
||||
*/
|
||||
boolean saveCertBankCard(BankCard entity);
|
||||
|
||||
/**
|
||||
* 保存结算银行卡信息
|
||||
* @param entity 银行卡信息
|
||||
* @return
|
||||
*/
|
||||
boolean saveAccountBankCard(BankCard entity);
|
||||
/**
|
||||
* 校验银行卡信息是否合法
|
||||
*
|
||||
* @param bankCard 银行卡信息
|
||||
*/
|
||||
void checkBankInfo(BankCard bankCard);
|
||||
|
||||
/**
|
||||
* 获取未关联结算信息的对私结算银行卡信息
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 银行卡信息
|
||||
*/
|
||||
default BankCard getUnusedBankCard(String userId) {
|
||||
return ((BankCardMapper) getBaseMapper()).getUnusedBankCard(userId);
|
||||
}
|
||||
|
||||
Page<BankCardRecordVO> pageBankCardRecord(Page<BankCardRecordVO> page, Long userId);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.CallbackData;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 表原始数据记录,用于不明确的回调数据的统计 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-09-10
|
||||
*/
|
||||
public interface CallbackDataService extends IService<CallbackData> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.api.PageInfo;
|
||||
import cn.pluss.platform.entity.DeviceGoods;
|
||||
import cn.pluss.platform.mapper.DeviceGoodsMapper;
|
||||
import cn.pluss.platform.vo.DeviceGoodsVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备商品展示表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-11-11
|
||||
*/
|
||||
public interface DeviceGoodsService extends IService<DeviceGoods> {
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* 使用范围:app设备商城
|
||||
* @param pageNum
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
PageInfo<DeviceGoodsVO> goodList(Integer pageNum, Integer size, DeviceGoods condition);
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* 使用范围:app设备商城
|
||||
* @param pageNum
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
PageInfo<DeviceGoodsVO> goodListSimple(Integer pageNum, Integer size, DeviceGoods condition);
|
||||
|
||||
/**
|
||||
* 根据sn码获取对应商品信息
|
||||
* @param snNo sn码
|
||||
* @return
|
||||
*/
|
||||
default DeviceGoods getBySn(String snNo) {
|
||||
return ((DeviceGoodsMapper) getBaseMapper()).selectBySn(snNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code 查询商品信息
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
default DeviceGoods getByCode(String code){
|
||||
return ((DeviceGoodsMapper) getBaseMapper()).getByCode(code);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.IdCardCache;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author DJH
|
||||
*/
|
||||
public interface IdCardCacheService extends IService<IdCardCache> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.IdCard;
|
||||
import cn.pluss.platform.mapper.IdCardMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 身份证信息表, 图片信息在tb_pluss_merchant_image表中 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-10-16
|
||||
*/
|
||||
public interface IdCardService extends IService<IdCard> {
|
||||
|
||||
default int getAgentCount(String certNo, String userId) {
|
||||
return ((IdCardMapper) getBaseMapper()).selectAgentCount(certNo, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实名的身份证信息
|
||||
* @param userId 用户id
|
||||
* @return 身份证信息
|
||||
*/
|
||||
IdCard getCertIdCard(Object userId);
|
||||
|
||||
/**
|
||||
* 获取进件法人的身份证信息
|
||||
* @param userId 用户id
|
||||
* @return 身份证信息
|
||||
*/
|
||||
IdCard getLegalIdCard(String userId);
|
||||
|
||||
/**
|
||||
* 保存法人身份证信息
|
||||
* @param entity 身份证信息
|
||||
*/
|
||||
boolean apiSaveLegalIdCard(IdCard entity);
|
||||
|
||||
/**
|
||||
* 保存实名身份证信息
|
||||
* @param entity 身份证信息
|
||||
* @return
|
||||
*/
|
||||
boolean apiSaveCertIdCard(IdCard entity);
|
||||
|
||||
/**
|
||||
* 获取结算人身份证信息
|
||||
* @param userId
|
||||
* @param merchantType 商户类型
|
||||
* @return
|
||||
*/
|
||||
IdCard getReckonerIdCard(String userId, String merchantType);
|
||||
|
||||
/**
|
||||
* 法人信息为空的时候,将实名身份信息作为法人身份信息存储
|
||||
* 法人身份部位空时,则检验身份与实名身份是否是同一身份,若不匹配,则将实名身份作为法人身份替换保存
|
||||
* @param userId 用户id
|
||||
* @return 保存的法人身份信息
|
||||
*/
|
||||
IdCard createLegalIdCard(String userId);
|
||||
|
||||
/**
|
||||
* 获取结算人信息
|
||||
* @param userId 用户id
|
||||
* @return 结算身份证
|
||||
*/
|
||||
default IdCard getBalanceIdCard(String userId) {
|
||||
IdCard idCard = new IdCard();
|
||||
idCard.setUserType(IdCard.TYPE_ACCOUNT);
|
||||
idCard.setUserId(userId);
|
||||
|
||||
return getOne(new QueryWrapper<>(idCard).last("limit 1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取结算身份证
|
||||
* @return
|
||||
*/
|
||||
default List<IdCard> getAccountIdCard(String userId) {
|
||||
return ((IdCardMapper) getBaseMapper()).getAccountIdCard(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取结算身份证
|
||||
* @return
|
||||
*/
|
||||
default IdCard getAccountIdCard(String userId, String channelType) {
|
||||
return ((IdCardMapper) getBaseMapper()).getAccountIdCard(userId, channelType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未关联结算信息的对私结算身份证信息
|
||||
* @param userId 用户id
|
||||
* @return 身份证信息
|
||||
*/
|
||||
default IdCard getUnusedIdCard(String userId) {
|
||||
return ((IdCardMapper) getBaseMapper()).getUnusedIdCard(userId);
|
||||
}
|
||||
|
||||
IdCard apiGetFaceCertInfo();
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.MerchantAuditRecord;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.MerchantAuditRecordMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-11-27
|
||||
*/
|
||||
public interface MerchantAuditRecordService extends IService<MerchantAuditRecord> {
|
||||
|
||||
/**
|
||||
* 最大进件失败次数限制
|
||||
*/
|
||||
int MAX_FAIL_COUNT = 3;
|
||||
|
||||
/**
|
||||
* 获取商户进件失败次数
|
||||
* @param userId 用户id
|
||||
* @return 进件失败次数
|
||||
*/
|
||||
Integer getFailCountByUserId(String userId);
|
||||
/**
|
||||
* 获取商户进件失败次数
|
||||
* @param merchantCode 商户code
|
||||
* @return 进件失败次数
|
||||
*/
|
||||
default Integer getFailCount(String merchantCode) {
|
||||
MerchantAuditRecordMapper mapper = (MerchantAuditRecordMapper) getBaseMapper();
|
||||
MerchantAuditRecord merchantAuditRecord = new MerchantAuditRecord();
|
||||
merchantAuditRecord.setMerchantCode(merchantCode);
|
||||
|
||||
QueryWrapper<MerchantAuditRecord> queryWrapper = new QueryWrapper<>(merchantAuditRecord);
|
||||
queryWrapper.in("status", "5", "2");
|
||||
|
||||
return mapper.selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户进件失败次数校验
|
||||
* @param merchantCode
|
||||
* @param msg
|
||||
*/
|
||||
default void checkFailCount(String merchantCode, String msg) {
|
||||
Integer failCount = getFailCount(merchantCode);
|
||||
MsgException.check(failCount >= MAX_FAIL_COUNT, msg);
|
||||
}
|
||||
|
||||
default MerchantAuditRecord getLastRecord(String merchantCode) {
|
||||
QueryWrapper<MerchantAuditRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("merchantCode", merchantCode);
|
||||
queryWrapper.orderByDesc("createTime");
|
||||
queryWrapper.last("limit 1");
|
||||
|
||||
return getBaseMapper().selectOne(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.MerchantRateRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 费率修改记录表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-09-02
|
||||
*/
|
||||
public interface MerchantRateRecordService extends IService<MerchantRateRecord> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.PushAll;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 发送推送的服务类
|
||||
* @author DJH
|
||||
*/
|
||||
public interface PushService extends IService<PushAll> {
|
||||
|
||||
/**
|
||||
* 下单
|
||||
*/
|
||||
String MAKE_ORDER = "1";
|
||||
|
||||
/**
|
||||
* 催单
|
||||
*/
|
||||
String URGE_ORDER = "2";
|
||||
|
||||
/**
|
||||
* 请求服务
|
||||
*/
|
||||
String REQUEST_SERVICE = "3";
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
String REFUND_ORDER = "4";
|
||||
|
||||
/**
|
||||
* 推送数据给商户app上
|
||||
* @param userId
|
||||
* @param type
|
||||
*/
|
||||
void pushMsg(String userId, String type);
|
||||
|
||||
/**
|
||||
* 根据店铺的id发送推送或通知
|
||||
* @param storeId store表的id
|
||||
* @param type 通知或推送类别
|
||||
*/
|
||||
void pushMsg(Integer storeId, String type);
|
||||
|
||||
/**
|
||||
* 发送广播推送
|
||||
* @param title 标题
|
||||
* @param msg 内容
|
||||
*/
|
||||
void pushAll(String title, String msg);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.SubMerchantApplyOrder;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 子渠道工单信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-08-31
|
||||
*/
|
||||
public interface SubMerchantApplyOrderService extends IService<SubMerchantApplyOrder> {
|
||||
|
||||
List<SubMerchantApplyOrder> listNoCertData();
|
||||
|
||||
Page<Map<String, Object>> pageMoreDetail(Page<Map<String, Object>> page, Map<String, String> condition);
|
||||
|
||||
/**
|
||||
* 获取商户微信认证信息
|
||||
* @param userApp 商户信息
|
||||
* @return 微信认证结果信息
|
||||
*/
|
||||
SubMerchantApplyOrder apiGetWxAuditInfo(UserApp userApp);
|
||||
|
||||
/**
|
||||
* 商户认证信息标识为完成
|
||||
* @param userApp 商户信息
|
||||
*/
|
||||
void complete(UserApp userApp);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.pluss.platform;
|
||||
|
||||
import cn.pluss.platform.entity.SxfMccInfo;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-09-22
|
||||
*
|
||||
* 常规mcc使用请看
|
||||
* {@link cn.pluss.platform.entity.MccInfoSort}
|
||||
* {@link cn.pluss.platform.mcc.MccInfoSortService}
|
||||
*/
|
||||
public interface SxfMccInfoService extends IService<SxfMccInfo> {
|
||||
|
||||
Page<SxfMccInfo> pageData(Page<SxfMccInfo> page, String keyWord);
|
||||
|
||||
/**
|
||||
* mcc表信息转换为树形
|
||||
* @return 树形mcc信息
|
||||
*/
|
||||
JSONArray treeData();
|
||||
|
||||
SxfMccInfo getByMccCode(String mccCode);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.pluss.platform.activityActivate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.pluss.platform.entity.ActivityActivate;
|
||||
import cn.pluss.platform.mapper.ActivityActivateMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface ActivityActivateService extends IService<ActivityActivate> {
|
||||
|
||||
default ActivityActivate queryActivityActivate(ActivityActivate activityActivate) {
|
||||
return ((ActivityActivateMapper) getBaseMapper()).queryActivityActivate(activityActivate);
|
||||
}
|
||||
|
||||
default List<ActivityActivate> queryActivityActivateList(ActivityActivate activityActivate) {
|
||||
return ((ActivityActivateMapper) getBaseMapper()).queryActivityActivateList(activityActivate);
|
||||
}
|
||||
|
||||
default void saveActivityActivate(ActivityActivate activityActivate) {
|
||||
getBaseMapper().insert(activityActivate);
|
||||
}
|
||||
|
||||
default void updateActivityActivate(ActivityActivate activityActivate) {
|
||||
getBaseMapper().updateById(activityActivate);
|
||||
}
|
||||
|
||||
default void deleteActivityActivate(ActivityActivate activityActivate) {
|
||||
getBaseMapper().deleteById(activityActivate.getId());
|
||||
}
|
||||
|
||||
default List<ActivityActivate> queryActivityActivatePage(Map<String, Object> map) {
|
||||
return ((ActivityActivateMapper) getBaseMapper()).queryActivityActivatePage(map);
|
||||
}
|
||||
|
||||
default List<ActivityActivate> queryNoActivityActivatePage(Map<String, Object> map) {
|
||||
return ((ActivityActivateMapper) getBaseMapper()).queryNoActivityActivatePage(map);
|
||||
}
|
||||
|
||||
default Integer queryActivityActivatePageCount(Map<String, Object> map) {
|
||||
return ((ActivityActivateMapper) getBaseMapper()).queryActivityActivatePageCount(map);
|
||||
}
|
||||
|
||||
default Integer queryNoActivityActivatePageCount(Map<String, Object> map) {
|
||||
return ((ActivityActivateMapper) getBaseMapper()).queryNoActivityActivatePageCount(map);
|
||||
}
|
||||
|
||||
default List<Map<String, Object>> getNewestActivityJoin(String storeId) {
|
||||
return ((ActivityActivateMapper) getBaseMapper()).getNewestActivityJoin(storeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过type删除活动
|
||||
*
|
||||
* @param activityActivate
|
||||
*/
|
||||
void delActByType(ActivityActivate activityActivate);
|
||||
|
||||
void delByUserId(Integer userId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.pluss.platform.activityActivate.impl;
|
||||
|
||||
import cn.pluss.platform.activityActivate.ActivityActivateService;
|
||||
import cn.pluss.platform.activityConsumReturn.ActivityConsumReturnService;
|
||||
import cn.pluss.platform.activityRecharge.ActivityRechargeService;
|
||||
import cn.pluss.platform.entity.ActivityActivate;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.ActivityActivateMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author DJH
|
||||
*/
|
||||
@Service("activityActivateService")
|
||||
public class ActivityActivateServiceImpl extends ServiceImpl<ActivityActivateMapper, ActivityActivate> implements ActivityActivateService {
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private ActivityRechargeService activityRechargeService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private ActivityConsumReturnService activityConsumReturnService;
|
||||
|
||||
@Override
|
||||
public void delActByType(ActivityActivate activityActivate) {
|
||||
switch (activityActivate.getType()) {
|
||||
case "0":
|
||||
activityRechargeService.delByUserId(activityActivate.getUserId());
|
||||
break;
|
||||
case "1":
|
||||
activityConsumReturnService.delByUserId(activityActivate.getUserId());
|
||||
break;
|
||||
case "2":
|
||||
delByUserId(activityActivate.getUserId());
|
||||
break;
|
||||
default:
|
||||
throw new MsgException("未知的活动类型");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delByUserId(Integer userId) {
|
||||
if (userId == null) {
|
||||
throw new MsgException("缺少用户id");
|
||||
}
|
||||
|
||||
ActivityActivate entity = new ActivityActivate();
|
||||
entity.setUserId(userId);
|
||||
|
||||
baseMapper.delete(new QueryWrapper<>(entity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.pluss.platform.activityConsumReturn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.pluss.platform.entity.ActivityConsumReturn;
|
||||
import cn.pluss.platform.entity.MerchantMenberComsume;
|
||||
import cn.pluss.platform.mapper.ActivityConsumReturnMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface ActivityConsumReturnService extends IService<ActivityConsumReturn> {
|
||||
|
||||
ActivityConsumReturn queryActivityConsumReturn(ActivityConsumReturn activityConsumReturn);
|
||||
|
||||
List<ActivityConsumReturn> queryActivityConsumReturnList(ActivityConsumReturn activityConsumReturn);
|
||||
|
||||
void saveActivityConsumReturn(ActivityConsumReturn activityConsumReturn);
|
||||
|
||||
void updateActivityConsumReturn(ActivityConsumReturn activityConsumReturn);
|
||||
|
||||
void deleteActivityConsumReturn(ActivityConsumReturn activityConsumReturn);
|
||||
|
||||
List<ActivityConsumReturn> queryActivityConsumReturnPage(Map map);
|
||||
|
||||
List<ActivityConsumReturn> queryActivityNoConsumReturnPage(Map map);
|
||||
|
||||
Integer queryActivityConsumReturnPageCount(Map map);
|
||||
|
||||
Integer queryActivityNoConsumReturnPageCount(Map map);
|
||||
|
||||
void saveActivityConsumReturnBatch(List<ActivityConsumReturn> activityConsumReturnList);
|
||||
|
||||
/**
|
||||
* 获取消费返现参数
|
||||
*/
|
||||
MerchantMenberComsume getActivityReturnParams(String merchantCode, String storeId, Double consumeAmt);
|
||||
|
||||
/**
|
||||
* 根据用户id删除所有“充值返”活动
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void delByUserId(Integer userId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
package cn.pluss.platform.activityConsumReturn.impl;
|
||||
|
||||
import cn.pluss.platform.activityConsumReturn.ActivityConsumReturnService;
|
||||
import cn.pluss.platform.entity.ActivityConsumReturn;
|
||||
import cn.pluss.platform.entity.MerchantMenberComsume;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.ActivityConsumReturnMapper;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service("activityConsumReturnService")
|
||||
public class ActivityConsumReturnServiceImpl extends ServiceImpl<ActivityConsumReturnMapper, ActivityConsumReturn> implements ActivityConsumReturnService {
|
||||
|
||||
@Override
|
||||
public ActivityConsumReturn queryActivityConsumReturn(ActivityConsumReturn activityConsumReturn) {
|
||||
return baseMapper.queryActivityConsumReturn(activityConsumReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityConsumReturn> queryActivityConsumReturnList(ActivityConsumReturn activityConsumReturn) {
|
||||
return baseMapper.queryActivityConsumReturnList(activityConsumReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveActivityConsumReturn(ActivityConsumReturn activityConsumReturn) {
|
||||
activityConsumReturn.setStoreName(activityConsumReturn.getMerchantName());
|
||||
baseMapper.saveActivityConsumReturn(activityConsumReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActivityConsumReturn(ActivityConsumReturn activityConsumReturn) {
|
||||
baseMapper.updateActivityConsumReturn(activityConsumReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteActivityConsumReturn(ActivityConsumReturn activityConsumReturn) {
|
||||
baseMapper.deleteActivityConsumReturn(activityConsumReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityConsumReturn> queryActivityConsumReturnPage(Map map) {
|
||||
return baseMapper.queryActivityConsumReturnPage(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityConsumReturn> queryActivityNoConsumReturnPage(Map map) {
|
||||
return baseMapper.queryActivityNoConsumReturnPage(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryActivityNoConsumReturnPageCount(Map map) {
|
||||
return baseMapper.queryActivityNoConsumReturnPageCount(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryActivityConsumReturnPageCount(Map map) {
|
||||
return baseMapper.queryActivityConsumReturnPageCount(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveActivityConsumReturnBatch(List<ActivityConsumReturn> activityConsumReturnList) {
|
||||
baseMapper.saveActivityConsumReturnBatch(activityConsumReturnList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充值金额对应的活动返现金额
|
||||
*
|
||||
* @param merchantCode
|
||||
* @param storeId
|
||||
* @param consumeAmt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public MerchantMenberComsume getActivityReturnParams(String merchantCode, String storeId, Double consumeAmt) {
|
||||
/*
|
||||
* 查询所有消费返活动,选择其中最大的反额为消费返的金额
|
||||
*/
|
||||
ActivityConsumReturn activityConsumReturn = new ActivityConsumReturn();
|
||||
activityConsumReturn.setMerchantCode(merchantCode);
|
||||
activityConsumReturn.setStoreId(storeId);
|
||||
List<ActivityConsumReturn> queryActivityConsumReturnList = baseMapper.queryActivityConsumReturnList(activityConsumReturn);
|
||||
Double consumeFee = StringUtil.bigDecimal(consumeAmt);// 消费金额
|
||||
Double returnMoney = 0d;
|
||||
MerchantMenberComsume merchantMenberComsume = new MerchantMenberComsume();
|
||||
merchantMenberComsume.setReturnMoney(returnMoney);
|
||||
merchantMenberComsume.setGiveMoney(0d);
|
||||
if (queryActivityConsumReturnList != null && queryActivityConsumReturnList.size() > 0) {
|
||||
queryActivityConsumReturnList = comsumeMoneyByDesc(queryActivityConsumReturnList);
|
||||
for (ActivityConsumReturn a : queryActivityConsumReturnList) {
|
||||
if (1 == a.getTimeType()) {
|
||||
if (a.getStartDt() == null || a.getEndDt() == null) {
|
||||
continue;
|
||||
}
|
||||
boolean bol = isBoolean(a.getStartDt(), a.getEndDt());
|
||||
if (!bol) {
|
||||
// 删除过期的消费返活动
|
||||
baseMapper.deleteActivityConsumReturn(a);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (null != a.getComsumeMoney()) {
|
||||
//分等级返现
|
||||
if (a.getType() == 0) {
|
||||
if (consumeFee >= StringUtil.bigDecimal(a.getComsumeMoney())) {
|
||||
merchantMenberComsume.setGiveMoney(StringUtil.bigDecimal(a.getReturnMoney()));// 返现金额
|
||||
merchantMenberComsume.setReturnMoney(a.getReturnMoney());
|
||||
break;
|
||||
}
|
||||
} else if (a.getType() == 1) {
|
||||
if (consumeFee >= StringUtil.bigDecimal(a.getComsumeMoney())) {
|
||||
Double d = a.getReturnMoney();
|
||||
Double countD = consumeFee / a.getComsumeMoney();
|
||||
Integer count = countD.intValue();
|
||||
Double returnAmt = d * count;
|
||||
merchantMenberComsume.setGiveMoney(StringUtil.bigDecimal(returnAmt));// 返现金额
|
||||
returnMoney = StringUtil.bigDecimal(returnAmt);
|
||||
merchantMenberComsume.setReturnMoney(returnMoney);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a.getType() == 2) {
|
||||
Double percentRate = a.getPercent() / 100;
|
||||
Double d = consumeFee * percentRate;
|
||||
Double returnAmt = StringUtil.bigDecimal(d);
|
||||
merchantMenberComsume.setGiveMoney(returnAmt);
|
||||
merchantMenberComsume.setReturnMoney(returnAmt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return merchantMenberComsume;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delByUserId(Integer userId) {
|
||||
if (userId == null) {
|
||||
throw new MsgException("缺少用户id");
|
||||
}
|
||||
|
||||
ActivityConsumReturn entity = new ActivityConsumReturn();
|
||||
entity.setUserId(userId);
|
||||
|
||||
baseMapper.delete(new QueryWrapper<>(entity));
|
||||
}
|
||||
|
||||
|
||||
public List<ActivityConsumReturn> comsumeMoneyByDesc(List<ActivityConsumReturn> list) {
|
||||
Collections.sort(list, (o1, o2) -> {
|
||||
int desc = (int) (Optional.ofNullable(o2.getComsumeMoney()).orElse(0d) - Optional.ofNullable(o1.getComsumeMoney()).orElse(0d));
|
||||
return desc;
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* isBoolean:(当前时间大于活动开始时间,并且当前时间小于活动结束时间). <br/>
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @author Administrator
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
public boolean isBoolean(Date startTime, Date endTime) {
|
||||
boolean flag = false;
|
||||
long current = System.currentTimeMillis();
|
||||
boolean start = current >= startTime.getTime();
|
||||
boolean end = current <= endTime.getTime();
|
||||
if (start && end) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.pluss.platform.activityEnroll;
|
||||
|
||||
import cn.pluss.platform.entity.ActivityEnroll;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商户活动报名记录表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-11-02
|
||||
*/
|
||||
public interface ActivityEnrollService extends IService<ActivityEnroll> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.pluss.platform.activityEnroll.impl;
|
||||
|
||||
import cn.pluss.platform.activityEnroll.ActivityEnrollService;
|
||||
import cn.pluss.platform.entity.ActivityEnroll;
|
||||
import cn.pluss.platform.mapper.ActivityEnrollMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商户活动报名记录表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-11-02
|
||||
*/
|
||||
@Service
|
||||
public class ActivityEnrollServiceImpl extends ServiceImpl<ActivityEnrollMapper, ActivityEnroll> implements ActivityEnrollService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.pluss.platform.activityRecharge;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import cn.pluss.platform.entity.ActivityRecharge;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author DJH
|
||||
*/
|
||||
public interface ActivityRechargeService extends IService<ActivityRecharge> {
|
||||
|
||||
ActivityRecharge queryActivityRecharge(ActivityRecharge activityRecharge);
|
||||
|
||||
List<ActivityRecharge> queryActivityRechargeList(ActivityRecharge activityRecharge);
|
||||
|
||||
void saveActivityRecharge(ActivityRecharge activityRecharge);
|
||||
|
||||
void updateActivityRecharge(ActivityRecharge activityRecharge);
|
||||
|
||||
void deleteActivityRecharge(ActivityRecharge activityRecharge);
|
||||
|
||||
/**
|
||||
* 一次删除所有的充值活动
|
||||
* @param userId
|
||||
*/
|
||||
void delByUserId(Integer userId);
|
||||
|
||||
List<ActivityRecharge> queryActivityRechargePage(Map<String, Object> map);
|
||||
|
||||
List<ActivityRecharge> queryActivityNoRechargePage(Map<String, Object> map);
|
||||
|
||||
Integer queryActivityRechargePageCount(Map<String, Object> map);
|
||||
|
||||
Integer queryActivityNoRechargePageCount(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 获取充值赠送金额
|
||||
* @param merchantCode
|
||||
* @param storeId
|
||||
* @param rechargeMoney
|
||||
* @return
|
||||
*/
|
||||
double getRechargeReturnAmt(String merchantCode, String storeId, double rechargeMoney);
|
||||
|
||||
/**
|
||||
* 查询进行中的活动
|
||||
* @param activityRecharge
|
||||
* @return
|
||||
*/
|
||||
List<ActivityRecharge> queryUsableActivityRechageList(ActivityRecharge activityRecharge);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
package cn.pluss.platform.activityRecharge.impl;
|
||||
|
||||
import cn.pluss.platform.activityRecharge.ActivityRechargeService;
|
||||
import cn.pluss.platform.entity.ActivityRecharge;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.ActivityRechargeMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("activityRechargeService")
|
||||
public class ActivityRechargeServiceImpl extends ServiceImpl<ActivityRechargeMapper, ActivityRecharge> implements ActivityRechargeService {
|
||||
|
||||
@Override
|
||||
public ActivityRecharge queryActivityRecharge(ActivityRecharge activityRecharge) {
|
||||
return baseMapper.selectOne(new QueryWrapper<>(activityRecharge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityRecharge> queryActivityRechargeList(ActivityRecharge activityRecharge) {
|
||||
return baseMapper.queryActivityRechargeList(activityRecharge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveActivityRecharge(ActivityRecharge activityRecharge) {
|
||||
baseMapper.insert(activityRecharge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActivityRecharge(ActivityRecharge activityRecharge) {
|
||||
baseMapper.updateById(activityRecharge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteActivityRecharge(ActivityRecharge activityRecharge) {
|
||||
baseMapper.deleteById(activityRecharge.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delByUserId(Integer userId) {
|
||||
if (userId == null) {
|
||||
throw new MsgException("缺少用户id");
|
||||
}
|
||||
|
||||
ActivityRecharge entity = new ActivityRecharge();
|
||||
entity.setUserId(userId);
|
||||
|
||||
baseMapper.delete(new QueryWrapper<>(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityRecharge> queryActivityRechargePage(Map<String, Object> map) {
|
||||
return baseMapper.queryActivityRechargePage(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityRecharge> queryActivityNoRechargePage(Map<String, Object> map) {
|
||||
return baseMapper.queryActivityNoRechargePage(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryActivityRechargePageCount(Map<String, Object> map) {
|
||||
return baseMapper.queryActivityRechargePageCount(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryActivityNoRechargePageCount(Map<String, Object> map) {
|
||||
return baseMapper.queryActivityNoRechargePageCount(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRechargeReturnAmt(String merchantCode, String storeId, double rechargeMoney) {
|
||||
ActivityRecharge activityRecharge = new ActivityRecharge();
|
||||
activityRecharge.setMerchantCode(merchantCode);
|
||||
activityRecharge.setStoreId(storeId);
|
||||
double giveMoney = 0.0d;
|
||||
List<ActivityRecharge> queryActivityRechargeList = queryActivityRechargeList(activityRecharge);
|
||||
if (queryActivityRechargeList != null && queryActivityRechargeList.size() > 0) {
|
||||
queryActivityRechargeList = rechargeMoneyDesc(queryActivityRechargeList);
|
||||
for (ActivityRecharge a : queryActivityRechargeList) {
|
||||
if (1 == a.getTimeType()) {
|
||||
if (a.getStartDt() == null || a.getEndDt() == null) {
|
||||
continue;
|
||||
}
|
||||
boolean bol = isBoolean(a.getStartDt(), a.getEndDt());
|
||||
if (!bol) {
|
||||
deleteActivityRecharge(a);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (null != a.getRechargeMoney()) {
|
||||
if (BigDecimal.valueOf(rechargeMoney).compareTo(BigDecimal.valueOf(a.getRechargeMoney())) > -1) {
|
||||
// 返现金额
|
||||
giveMoney = a.getGiveMoney() == null ? 0d : a.getGiveMoney();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return giveMoney;
|
||||
}
|
||||
|
||||
/**
|
||||
* rechargeMoneyDesc:(充值金额从大到小). <br/>
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*
|
||||
* @author Administrator
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
public List<ActivityRecharge> rechargeMoneyDesc(List<ActivityRecharge> list) {
|
||||
list.sort((o1, o2) -> (int) (o2.getRechargeMoney() - o1.getRechargeMoney()));
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* isBoolean:(当前时间大于活动开始时间,并且当前时间小于活动结束时间). <br/>
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @author Administrator
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
public boolean isBoolean(Date startTime, Date endTime) {
|
||||
boolean flag = false;
|
||||
long current = System.currentTimeMillis();
|
||||
boolean start = current >= startTime.getTime();
|
||||
boolean end = current <= endTime.getTime();
|
||||
if (start && end) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询进行中的活动
|
||||
* @param activityRecharge
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ActivityRecharge> queryUsableActivityRechageList(ActivityRecharge activityRecharge) {
|
||||
return baseMapper.queryUsableActivityRechageList(activityRecharge);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.pluss.platform.activityRecommend;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import cn.pluss.platform.entity.ActivityRecommend;
|
||||
|
||||
public interface ActivityRecommendService {
|
||||
|
||||
public ActivityRecommend queryActivityRecommend(ActivityRecommend activityRecommend);
|
||||
|
||||
public List<ActivityRecommend> queryActivityRecommendList(ActivityRecommend activityRecommend);
|
||||
|
||||
public void saveActivityRecommend(ActivityRecommend activityRecommend);
|
||||
|
||||
public void updateActivityRecommend(ActivityRecommend activityRecommend);
|
||||
|
||||
public void deleteActivityRecommend(ActivityRecommend activityRecommend);
|
||||
|
||||
public List<ActivityRecommend> queryActivityRecommendPage(Map map);
|
||||
|
||||
public Integer queryActivityRecommendPageCount(Map map);
|
||||
|
||||
public void saveActivityRecommendBatch(List<ActivityRecommend> activityRecommendList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.pluss.platform.activityRecommend.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import cn.pluss.platform.activityRecommend.ActivityRecommendService;
|
||||
import cn.pluss.platform.entity.ActivityRecommend;
|
||||
import cn.pluss.platform.mapper.ActivityRecommendMapper;
|
||||
@Service("activityRecommendService")
|
||||
public class ActivityRecommendServiceImpl implements ActivityRecommendService{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger( ActivityRecommendServiceImpl.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private ActivityRecommendMapper activityRecommendMapper;
|
||||
|
||||
@Override
|
||||
public ActivityRecommend queryActivityRecommend(ActivityRecommend activityRecommend){
|
||||
return activityRecommendMapper.queryActivityRecommend(activityRecommend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityRecommend> queryActivityRecommendList(ActivityRecommend activityRecommend){
|
||||
return activityRecommendMapper.queryActivityRecommendList(activityRecommend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveActivityRecommend(ActivityRecommend activityRecommend) {
|
||||
activityRecommendMapper.saveActivityRecommend(activityRecommend);
|
||||
}
|
||||
@Override
|
||||
public void updateActivityRecommend(ActivityRecommend activityRecommend){
|
||||
activityRecommendMapper.updateActivityRecommend(activityRecommend);
|
||||
}
|
||||
@Override
|
||||
public void deleteActivityRecommend(ActivityRecommend activityRecommend){
|
||||
activityRecommendMapper.deleteActivityRecommend(activityRecommend);
|
||||
}
|
||||
@Override
|
||||
public List<ActivityRecommend> queryActivityRecommendPage(Map map){
|
||||
return activityRecommendMapper.queryActivityRecommendPage(map);
|
||||
}
|
||||
@Override
|
||||
public Integer queryActivityRecommendPageCount(Map map){
|
||||
return activityRecommendMapper.queryActivityRecommendPageCount(map);
|
||||
}
|
||||
@Override
|
||||
public void saveActivityRecommendBatch(List<ActivityRecommend> activityRecommendList) {
|
||||
activityRecommendMapper.saveActivityRecommendBatch(activityRecommendList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.pluss.platform.agent;
|
||||
|
||||
import cn.pluss.platform.entity.MerchantRateNew;
|
||||
import cn.pluss.platform.vo.AgentInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* 超级代理商相关处理逻辑
|
||||
* @author DJH
|
||||
*/
|
||||
public interface AgentService {
|
||||
|
||||
/**
|
||||
* 开通或修改下级代理商
|
||||
* @param agentInfo 代理商信息
|
||||
*/
|
||||
void save(AgentInfo agentInfo);
|
||||
|
||||
/**
|
||||
* 获取下级代理商,分页数据
|
||||
* @param page 分页参数
|
||||
* @param agentInfo 查询参数
|
||||
* @param orderItem 排序参数
|
||||
* @return 分页数据
|
||||
*/
|
||||
Page<AgentInfo> page(Page<AgentInfo> page, AgentInfo agentInfo, OrderItem orderItem);
|
||||
|
||||
/**
|
||||
* 获取设置下级代理商的最低费率
|
||||
* @return 最低费率
|
||||
*/
|
||||
Integer getMinSettingRate();
|
||||
|
||||
/**
|
||||
* 获取设置下级商户的最低费率
|
||||
* @return
|
||||
*/
|
||||
MerchantRateNew getMinSettingRateNew();
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package cn.pluss.platform.agent.impl;
|
||||
|
||||
import cn.pluss.platform.agent.AgentService;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.AgentMapper;
|
||||
import cn.pluss.platform.mapper.MerchantRateMapper;
|
||||
import cn.pluss.platform.user.UserLevelService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.userInfo.UserInfoService;
|
||||
import cn.pluss.platform.util.MD5Util;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import cn.pluss.platform.vo.AgentInfo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author DJH
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AgentServiceImpl implements AgentService {
|
||||
|
||||
private static final String NOT_ALL_NUM = "^[0-9]*$";
|
||||
|
||||
/**
|
||||
* \u3000是全角空格
|
||||
*/
|
||||
private static final String NO_SPECIAL_CHAR = "[ \u3000`~!@#$%^&*()+=|{}':;,\\[\\].<>/?!¥…()—【】‘;:”“’。,、?]";
|
||||
|
||||
private final Pattern compile = Pattern.compile(NOT_ALL_NUM);
|
||||
|
||||
private final Pattern compile2 = Pattern.compile(NO_SPECIAL_CHAR);
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private AgentMapper agentMapper;
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private UserAppService userAppService;
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private UserInfoService userInfoService;
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private MerchantRateMapper rateMapper;
|
||||
|
||||
@Autowired
|
||||
private UserLevelService ulService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(AgentInfo agentInfo) {
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
if (!userApp.getUserId().equals(agentInfo.getParentId())) {
|
||||
throw new MsgException("拒绝访问");
|
||||
}
|
||||
|
||||
Matcher matcher = compile.matcher(agentInfo.getLoginName());
|
||||
if (matcher.matches()) {
|
||||
throw new MsgException("账号不能使用纯数字");
|
||||
}
|
||||
|
||||
Matcher matcher2 = compile2.matcher(agentInfo.getLoginName());
|
||||
if (matcher2.find()) {
|
||||
throw new MsgException("账号不能使用包含特殊符号");
|
||||
}
|
||||
|
||||
MsgException.throwException("代理账户和普通账户即将合并,暂无法开通代理商,请使用推广海报拓展团队");
|
||||
|
||||
saveAgentInfo(agentInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<AgentInfo> page(Page<AgentInfo> page, AgentInfo agentInfo, OrderItem orderItem) {
|
||||
if (agentInfo.getParentId() == null) {
|
||||
throw new MsgException("缺少parentId");
|
||||
}
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
if (!userApp.getUserId().equals(agentInfo.getParentId())) {
|
||||
throw new MsgException("拒绝访问");
|
||||
}
|
||||
|
||||
page.getOrders().clear();
|
||||
if (orderItem != null && StringUtils.isNotBlank(orderItem.getColumn())) {
|
||||
page.addOrder(orderItem);
|
||||
}
|
||||
|
||||
if (page.getOrders().isEmpty()) {
|
||||
page.addOrder(OrderItem.desc("createTime"));
|
||||
}
|
||||
|
||||
return agentMapper.selectPage(page, agentInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMinSettingRate() {
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
|
||||
// if (!"agent".equals(userApp.getUserType())) {
|
||||
// throw new MsgException("拒绝访问");
|
||||
// }
|
||||
|
||||
MerchantRate userRate = new MerchantRate().setUserId(userApp.getUserId() + "");
|
||||
userRate = rateMapper.selectOne(new QueryWrapper<>(userRate));
|
||||
|
||||
int min = 0;
|
||||
// 非固定费率的服务商,下级服务商费率必须大于25
|
||||
if (!"1".equals(userApp.getIsFixedRate())) {
|
||||
min = 25;
|
||||
}
|
||||
|
||||
return Math.max(userRate.getCurrentRate(), min);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MerchantRateNew getMinSettingRateNew() {
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
|
||||
UserLevel entity = ulService.getLevelInfoByRoleLevel(userApp.getRoleCode(), userApp.getLevelCode());
|
||||
|
||||
MerchantRateNew rateNew = new MerchantRateNew();
|
||||
rateNew.setWxRate(entity.getRate().intValue() + 1);
|
||||
rateNew.setAliRate(entity.getRate().intValue() + 1);
|
||||
rateNew.setBankRate(entity.getRate().intValue() + 1);
|
||||
rateNew.setBankRateLarge(entity.getRate().intValue() + 1);
|
||||
|
||||
MerchantRateNew.setRateValue(rateNew);
|
||||
|
||||
return rateNew;
|
||||
}
|
||||
|
||||
private void saveAgentInfo(AgentInfo agentInfo) {
|
||||
AgentInfo exist = new AgentInfo().setLoginName(agentInfo.getLoginName());
|
||||
exist = agentMapper.selectOne(exist);
|
||||
MsgException.check(exist != null, "该账号已存在");
|
||||
|
||||
exist = new AgentInfo().setPhone(agentInfo.getPhone());
|
||||
exist = agentMapper.selectOne(exist);
|
||||
MsgException.check(exist != null, "该手机号已存在关联代理商");
|
||||
|
||||
Date date = new Date();
|
||||
UserInfo userInfo = new UserInfo()
|
||||
.setPassword(MD5Util.MD5Encode(agentInfo.getPassword(), "UTF-8"))
|
||||
.setLoginName(agentInfo.getLoginName())
|
||||
.setPhone(agentInfo.getPhone())
|
||||
.setUpdateTime(date)
|
||||
.setCreateTime(date);
|
||||
userInfoService.saveUserInfo(userInfo);
|
||||
MsgException.check(userInfo.getId() == null, "插入数据失败");
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
if (!(userApp.getStatus() == 3) || !(userApp.getBankStatus() == 3)) {
|
||||
throw new MsgException("当前服务商账号暂未实名,无法添加下级代理");
|
||||
}
|
||||
|
||||
MerchantRate userRate = new MerchantRate().setUserId(userApp.getUserId() + "");
|
||||
userRate = rateMapper.selectOne(new QueryWrapper<>(userRate));
|
||||
|
||||
log.info("自身费率: {}", userRate.getRate());
|
||||
log.info("设置下级费率: {}", agentInfo.getRate().intValue());
|
||||
|
||||
// 非固定费率的服务商,下级服务商费率必须大于25
|
||||
if (!"1".equals(userApp.getIsFixedRate()) && agentInfo.getRate().intValue() <= MerchantRate.MAX_RATE) {
|
||||
throw new MsgException("下级代理商费率必须大于" + MerchantRate.MAX_RATE);
|
||||
}
|
||||
|
||||
if (userRate.getRate() >= agentInfo.getRate().intValue()) {
|
||||
throw new MsgException("下级代理商费率必须大于自身费率");
|
||||
}
|
||||
|
||||
agentInfo.setUserId(userInfo.getId());
|
||||
|
||||
String pIdArr = userApp.getUserId() + "";
|
||||
if (StringUtils.isNotBlank(userApp.getPIdArr())) {
|
||||
pIdArr += "," + userApp.getPIdArr();
|
||||
}
|
||||
|
||||
UserApp subUserApp = new UserApp();
|
||||
subUserApp.setUserType("agent")
|
||||
.setUserId(userInfo.getId())
|
||||
.setLoginName(agentInfo.getPhone())
|
||||
.setInviteNum(getRandomNum())
|
||||
.setParentId(userApp.getUserId())
|
||||
.setLevel(3)
|
||||
// 默认身份认证状态
|
||||
.setStatus(0)
|
||||
.setIsFixedRate("1")
|
||||
.setCreateDt(date)
|
||||
.setPIdArr(pIdArr);
|
||||
|
||||
UserApp.setSort(userApp, subUserApp);
|
||||
UserApp.setRoleInfo(userApp, subUserApp,null);
|
||||
|
||||
userAppService.save(subUserApp);
|
||||
|
||||
MerchantRate merchantRate = new MerchantRate()
|
||||
.setUserId(userInfo.getId() + "")
|
||||
.setRate(agentInfo.getRate().intValue())
|
||||
.setPreviousRate(agentInfo.getRate().intValue())
|
||||
.setUpdateTime(new Date());
|
||||
rateMapper.insert(merchantRate);
|
||||
}
|
||||
|
||||
private String getRandomNum() {
|
||||
String inviteNum;
|
||||
UserApp condition = new UserApp();
|
||||
|
||||
do {
|
||||
inviteNum = StringUtil.genRandomNum(5);
|
||||
condition.setInviteNum(inviteNum);
|
||||
UserApp userApp = userAppService.queryUserApp(condition);
|
||||
if (userApp == null) {
|
||||
return inviteNum;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.pluss.platform.agentInfo;
|
||||
|
||||
import cn.pluss.platform.dto.UserInfoDTO;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.vo.AgentInfo;
|
||||
import cn.pluss.platform.vo.AgentStaffVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 代理商相关查询接口
|
||||
*/
|
||||
public interface AgentInfoService {
|
||||
|
||||
Page<AgentInfo> pageData(Page<AgentInfo> page, AgentInfo agentInfo);
|
||||
|
||||
Page<AgentInfo> pagePermissionData(Page<AgentInfo> page, AgentInfo agentInfo);
|
||||
|
||||
Page<AgentInfo> pageSubData(Page<AgentInfo> page, AgentInfo agentInfo);
|
||||
|
||||
AgentInfo getOne(AgentInfo agentInfo);
|
||||
|
||||
void saveOrUpdate(AgentInfo agentInfo);
|
||||
|
||||
void delete(AgentInfo agentInfo);
|
||||
|
||||
/**
|
||||
* 业务员列表分页查询
|
||||
*/
|
||||
Page<AgentStaffVO> staffPage(Page<AgentStaffVO> page, AgentStaffVO agentStaffVO, OrderItem orderItem);
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package cn.pluss.platform.agentInfo.impl;
|
||||
|
||||
import cn.pluss.platform.MerchantRateRecordService;
|
||||
import cn.pluss.platform.agentInfo.AgentInfoService;
|
||||
import cn.pluss.platform.cash.CashService;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.AgentInfoMapper;
|
||||
import cn.pluss.platform.mapper.MerchantRateMapper;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.userInfo.UserInfoService;
|
||||
import cn.pluss.platform.util.MD5Util;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import cn.pluss.platform.vo.AgentInfo;
|
||||
import cn.pluss.platform.vo.AgentStaffVO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author SSS
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AgentInfoServiceImpl implements AgentInfoService {
|
||||
|
||||
@Autowired
|
||||
private UserAppService userAppService;
|
||||
@Resource
|
||||
private AgentInfoMapper agentInfoMapper;
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
@Autowired
|
||||
private MerchantRateMapper merchantRateMapper;
|
||||
@Autowired
|
||||
private CashService cashService;
|
||||
@Autowired
|
||||
private MerchantRateRecordService merchantRateRecordService;
|
||||
|
||||
@Override
|
||||
public Page<AgentInfo> pageData(Page<AgentInfo> page, AgentInfo agentInfo) {
|
||||
page.addOrder(OrderItem.desc("ui.createTime"));
|
||||
JSONObject pageData = (JSONObject) JSON.toJSON(page);
|
||||
List<List<?>> queryData = agentInfoMapper.selectPage(agentInfo, pageData);
|
||||
List<AgentInfo> records = (List<AgentInfo>) queryData.get(0);
|
||||
page.setRecords(records);
|
||||
long total = ((Long) queryData.get(1).get(0));
|
||||
page.setTotal(total);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<AgentInfo> pagePermissionData(Page<AgentInfo> page, AgentInfo agentInfo) {
|
||||
page.addOrder(OrderItem.desc("ui.createTime"));
|
||||
JSONObject pageData = (JSONObject) JSON.toJSON(page);
|
||||
List<List<?>> queryData = agentInfoMapper.selectPermissionPage(agentInfo, pageData);
|
||||
List<AgentInfo> records = (List<AgentInfo>) queryData.get(0);
|
||||
page.setRecords(records);
|
||||
long total = ((Long) queryData.get(1).get(0));
|
||||
page.setTotal(total);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<AgentInfo> pageSubData(Page<AgentInfo> page, AgentInfo agentInfo) {
|
||||
page.addOrder(OrderItem.desc("ui.createTime"));
|
||||
JSONObject pageData = (JSONObject) JSON.toJSON(page);
|
||||
List<List<?>> queryData = agentInfoMapper.selectSubAgentPage(agentInfo, pageData);
|
||||
List<AgentInfo> records = (List<AgentInfo>) queryData.get(0);
|
||||
page.setRecords(records);
|
||||
long total = ((Long) queryData.get(1).get(0));
|
||||
page.setTotal(total);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgentInfo getOne(AgentInfo agentInfo) {
|
||||
return agentInfoMapper.selectOne(agentInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveOrUpdate(AgentInfo agentInfo) {
|
||||
if (StringUtils.isEmpty(agentInfo.getLoginName())) {
|
||||
throw new MsgException("请输入登录账号");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(agentInfo.getPhone())) {
|
||||
throw new MsgException("请输入关联手机号");
|
||||
}
|
||||
|
||||
if (agentInfo.getUserId() == null) {
|
||||
saveAgentInfo(agentInfo);
|
||||
} else {
|
||||
updateAgentInfo(agentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void delete(AgentInfo agentInfo) {
|
||||
userInfoService.removeById(agentInfo.getUserId());
|
||||
QueryWrapper<UserApp> queryWrapperUserApp = new QueryWrapper<UserApp>().eq("userId", agentInfo.getUserId());
|
||||
userAppService.remove(queryWrapperUserApp);
|
||||
QueryWrapper<MerchantRate> queryWrapperMerchantRate = new QueryWrapper<MerchantRate>().eq("userId", agentInfo.getUserId());
|
||||
merchantRateMapper.delete(queryWrapperMerchantRate);
|
||||
Cash cash = new Cash();
|
||||
cash.setUserId(agentInfo.getUserId());
|
||||
cashService.deleteUserIdCash(cash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<AgentStaffVO> staffPage(Page<AgentStaffVO> page, AgentStaffVO agentStaffVO, OrderItem orderItem) {
|
||||
page.getOrders().clear();
|
||||
page.addOrder(orderItem);
|
||||
page = agentInfoMapper.selectStaffPage(page, agentStaffVO);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询出相关信息并更新
|
||||
*
|
||||
* @param agentInfo 超级代理商信息
|
||||
*/
|
||||
private void updateAgentInfo(AgentInfo agentInfo) {
|
||||
UserInfo userInfo = userInfoService.getById(agentInfo.getUserId());
|
||||
userInfo.setUpdateTime(new Date());
|
||||
userInfo.setLoginName(agentInfo.getLoginName());
|
||||
userInfo.setPhone(agentInfo.getPhone());
|
||||
|
||||
QueryWrapper<UserApp> queryWrapperUserApp = new QueryWrapper<UserApp>()
|
||||
.eq("userId", agentInfo.getUserId());
|
||||
UserApp userApp = userAppService.getOne(queryWrapperUserApp);
|
||||
userApp.setLevel(3)
|
||||
.setIsFixedRate(agentInfo.getIsFixedRate())
|
||||
.setLoginName(agentInfo.getLoginName());
|
||||
|
||||
userInfoService.updateUserInfo(userInfo);
|
||||
userAppService.updateById(userApp);
|
||||
|
||||
// Cash cash = new Cash();
|
||||
// cash.setUserId(agentInfo.getUserId());
|
||||
// cash.setUpdateDt(new Date());
|
||||
// cash.setUserName(agentInfo.getUserName());
|
||||
// cash.setCashAmt(agentInfo.getCashAmt());
|
||||
// cashService.updateUserIdCash(cash);
|
||||
|
||||
MerchantRate merchantRate = new MerchantRate().setUserId(agentInfo.getUserId() + "");
|
||||
merchantRate = merchantRateMapper.selectOne(new QueryWrapper<>(merchantRate));
|
||||
// 补充数据
|
||||
if (merchantRate == null) {
|
||||
merchantRate = new MerchantRate()
|
||||
.setUserId(userInfo.getId() + "")
|
||||
.setRate(agentInfo.getRate().intValue())
|
||||
.setPreviousRate(agentInfo.getRate().intValue())
|
||||
.setUpdateTime(new Date());
|
||||
merchantRateMapper.insert(merchantRate);
|
||||
} else {
|
||||
merchantRate.setRate(agentInfo.getRate().intValue()).setUpdateTime(new Date()).setPreviousRate(agentInfo.getRate().intValue());
|
||||
merchantRateMapper.updateById(merchantRate);
|
||||
// 保存修改费率记录
|
||||
MerchantRateRecord merchantRateRecord = new MerchantRateRecord();
|
||||
merchantRateRecord.setCreateTime(new Date());
|
||||
merchantRateRecord.setRate(merchantRate.getRate());
|
||||
merchantRateRecord.setUserId(merchantRate.getUserId());
|
||||
merchantRateRecordService.save(merchantRateRecord);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void saveAgentInfo(AgentInfo agentInfo) {
|
||||
Date date = new Date();
|
||||
UserInfo userInfo = new UserInfo()
|
||||
.setPassword(MD5Util.MD5Encode("123456", "UTF-8"))
|
||||
.setLoginName(agentInfo.getLoginName()).setPhone(agentInfo.getPhone())
|
||||
.setUpdateTime(date)
|
||||
.setCreateTime(date);
|
||||
|
||||
AgentInfo exist = new AgentInfo().setLoginName(agentInfo.getLoginName());
|
||||
exist = agentInfoMapper.selectOne(exist);
|
||||
if (exist != null) {
|
||||
throw new MsgException("该账号已存在");
|
||||
}
|
||||
|
||||
exist = new AgentInfo().setPhone(agentInfo.getPhone());
|
||||
exist = agentInfoMapper.selectOne(exist);
|
||||
if (exist != null) {
|
||||
throw new MsgException("该手机号已存在关联代理商");
|
||||
}
|
||||
|
||||
userInfoService.saveUserInfo(userInfo);
|
||||
|
||||
if (userInfo.getId() == null) {
|
||||
throw new MsgException("插入数据失败!");
|
||||
}
|
||||
|
||||
agentInfo.setUserId(userInfo.getId());
|
||||
|
||||
UserApp userApp = new UserApp();
|
||||
userApp.setUserType("agent")
|
||||
.setUserId(userInfo.getId())
|
||||
.setLoginName(agentInfo.getPhone())
|
||||
.setInviteNum(getRandomNum())
|
||||
.setLevel(3)
|
||||
.setSort(1)
|
||||
.setIsFixedRate(agentInfo.getIsFixedRate())
|
||||
// 默认身份认证状态
|
||||
.setStatus(0)
|
||||
.setCreateDt(date);
|
||||
userAppService.save(userApp);
|
||||
|
||||
if (agentInfo.getCashAmt() != null && !Objects.equals(agentInfo.getCashAmt(), BigDecimal.ZERO)) {
|
||||
Cash cash = new Cash();
|
||||
cash.setUserId(userInfo.getId());
|
||||
cash.setCreateDt(new Date());
|
||||
cash.setUpdateDt(new Date());
|
||||
cash.setUserName(agentInfo.getUserName());
|
||||
cash.setCashAmt(agentInfo.getCashAmt());
|
||||
cashService.save(cash);
|
||||
}
|
||||
|
||||
MerchantRate merchantRate = new MerchantRate()
|
||||
.setUserId(userInfo.getId() + "")
|
||||
.setRate(agentInfo.getRate().intValue())
|
||||
.setPreviousRate(agentInfo.getRate().intValue())
|
||||
.setUpdateTime(new Date());
|
||||
merchantRateMapper.insert(merchantRate);
|
||||
}
|
||||
|
||||
private String getRandomNum() {
|
||||
String inviteNum;
|
||||
UserApp condition = new UserApp();
|
||||
|
||||
do {
|
||||
inviteNum = StringUtil.genRandomNum(5);
|
||||
condition.setInviteNum(inviteNum);
|
||||
UserApp userApp = userAppService.queryUserApp(condition);
|
||||
if (userApp == null) {
|
||||
return inviteNum;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.pluss.platform.agreement;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import cn.pluss.platform.entity.Agreement;
|
||||
|
||||
public interface AgreementService {
|
||||
|
||||
public Agreement queryAgreement(Agreement agreement);
|
||||
|
||||
public List<Agreement> queryAgreementList(Agreement agreement);
|
||||
|
||||
public void saveAgreement(Agreement agreement);
|
||||
|
||||
public void updateAgreement(Agreement agreement);
|
||||
|
||||
public void deleteAgreement(Agreement agreement);
|
||||
|
||||
public List<Agreement> queryAgreementPage(Map map);
|
||||
|
||||
public Integer queryAgreementPageCount(Map map);
|
||||
|
||||
public void saveAgreementBatch(List<Agreement> agreementList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.pluss.platform.agreement.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.pluss.platform.entity.Agreement;
|
||||
import cn.pluss.platform.agreement.AgreementService;
|
||||
import cn.pluss.platform.mapper.AgreementMapper;
|
||||
|
||||
@Transactional
|
||||
@Service("agreementService")
|
||||
public class AgreementServiceImpl implements AgreementService{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger( AgreementServiceImpl.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private AgreementMapper agreementMapper;
|
||||
|
||||
@Override
|
||||
public Agreement queryAgreement(Agreement agreement){
|
||||
return agreementMapper.queryAgreement(agreement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Agreement> queryAgreementList(Agreement agreement){
|
||||
return agreementMapper.queryAgreementList(agreement);
|
||||
}
|
||||
@Override
|
||||
public void saveAgreement(Agreement agreement){
|
||||
agreementMapper.saveAgreement(agreement);
|
||||
}
|
||||
@Override
|
||||
public void updateAgreement(Agreement agreement){
|
||||
agreementMapper.updateAgreement(agreement);
|
||||
}
|
||||
@Override
|
||||
public void deleteAgreement(Agreement agreement){
|
||||
agreementMapper.deleteAgreement(agreement);
|
||||
}
|
||||
@Override
|
||||
public List<Agreement> queryAgreementPage(Map map){
|
||||
return agreementMapper.queryAgreementPage(map);
|
||||
}
|
||||
@Override
|
||||
public Integer queryAgreementPageCount(Map map){
|
||||
return agreementMapper.queryAgreementPageCount(map);
|
||||
}
|
||||
@Override
|
||||
public void saveAgreementBatch(List<Agreement> agreementList) {
|
||||
agreementMapper.saveAgreementBatch(agreementList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.pluss.platform.ali;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 阿里原生支付的一些回调逻辑
|
||||
* @author DJH
|
||||
*/
|
||||
public interface AliPayNotifyService {
|
||||
|
||||
/**
|
||||
* 通用回调处理方法
|
||||
* @param param 回调参数
|
||||
*/
|
||||
void commonPayNotify(Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 设备购买回调处理方法
|
||||
* @param param 回调参数
|
||||
*/
|
||||
void devicePayNotify(Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 推广升级回调处理方法
|
||||
* @param param 回调参数
|
||||
*/
|
||||
void spreadUpgradePayNotify(Map<String, Object> param);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package cn.pluss.platform.ali;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import cn.pluss.platform.entity.MercOrderDetail;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
|
||||
import cn.pluss.platform.api.Result;
|
||||
import cn.pluss.platform.dto.BatchInfoDTO;
|
||||
import cn.pluss.platform.entity.DeviceMerchantBuy;
|
||||
import cn.pluss.platform.dto.DeviceMerchantBuyDTO;
|
||||
import cn.pluss.platform.entity.MerchantBaseInfo;
|
||||
|
||||
/**
|
||||
* @author yuchen
|
||||
*
|
||||
* @Description
|
||||
* 支付宝进件service
|
||||
*/
|
||||
public interface AliService {
|
||||
|
||||
/**
|
||||
*
|
||||
* getBatchNo:(开启事务). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param dto
|
||||
* @return
|
||||
* @throws AlipayApiException
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
Result<String> getBatchNo(MerchantBaseInfo merchantBaseInfo);
|
||||
|
||||
/**
|
||||
*
|
||||
* facetofaceSign:(是否当面付产品提交信息成功). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param dto
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
Boolean facetofaceSign(BatchInfoDTO dto);
|
||||
|
||||
/**
|
||||
*
|
||||
* agentConfirm:(提交事务). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param batchNo
|
||||
* @return
|
||||
* @throws AlipayApiException
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
Boolean agentConfirm(String batchNo);
|
||||
|
||||
/**
|
||||
*
|
||||
* AppPayParam:(app支付统一下单). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
Result<Map<String, Object>> appPayParam(Map<String, String> map, DeviceMerchantBuyDTO deviceMerchantBuyDTO);
|
||||
|
||||
/**
|
||||
*
|
||||
* AppPayParam:(app支付统一下单). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
Result<Map<String, Object>> appPayParamV2(Map<String, String> map, DeviceMerchantBuyDTO deviceMerchantBuyDTO);
|
||||
|
||||
/**
|
||||
* app统一支付下单,非商城
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> appPayParam(Map<String, String> map);
|
||||
|
||||
/**
|
||||
*
|
||||
* AppRefund:(app支付退款). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param deviceMerchantBuy
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
Result<Map<String, Object>> appRefund(DeviceMerchantBuy deviceMerchantBuy);
|
||||
|
||||
/**
|
||||
* 退款V2
|
||||
* @param orderDetail
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> refundV2(MercOrderDetail orderDetail);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.pluss.platform.ali;
|
||||
|
||||
public interface AlipayService {
|
||||
|
||||
void remit(String account, String realName, String money);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.pluss.platform.ali.device;
|
||||
|
||||
import cn.pluss.platform.alidevice.AliScanCodeDevicePayEntity;
|
||||
import cn.pluss.platform.alidevice.AliScanCodeDeviceStatus;
|
||||
import cn.pluss.platform.alidevice.RespDeviceEntity;
|
||||
import cn.pluss.platform.api.Result;
|
||||
|
||||
/**
|
||||
* 阿里云设备接口服务类
|
||||
* @author: Administrator
|
||||
* @DATE: 2021/12/22 11:31
|
||||
*/
|
||||
public interface AliDeviceService {
|
||||
|
||||
/**
|
||||
* 获取设备状态V1
|
||||
* @date: 2021/12/22 11:43
|
||||
* @return cn.pluss.platform.api.Result<java.lang.Object>
|
||||
*/
|
||||
RespDeviceEntity getDeviceStatusV1(String deivceNo);
|
||||
|
||||
/**
|
||||
* 获取设备状态V2
|
||||
* @date: 2021/12/22 11:44
|
||||
* @param deivceNo:
|
||||
* @return cn.pluss.platform.api.Result<java.lang.Object>
|
||||
*/
|
||||
RespDeviceEntity getDeviceStatusV2(String deivceNo);
|
||||
|
||||
/**
|
||||
* 绑定设备
|
||||
* @date: 2021/12/22 14:06
|
||||
* @param deivceNo:厂商设备号
|
||||
* @param userId :用户ID
|
||||
* @return
|
||||
*/
|
||||
Result<Object> bindDevice(String deivceNo, String userId);
|
||||
|
||||
/**
|
||||
* 设备支付
|
||||
* @date: 2021/12/22 14:42
|
||||
* @param entity:
|
||||
* @param payCode:
|
||||
* @return RespDeviceEntity
|
||||
*/
|
||||
RespDeviceEntity orderPay(AliScanCodeDevicePayEntity entity, String payCode);
|
||||
|
||||
/**
|
||||
* 订单查询
|
||||
* @date: 2021/12/22 18:35
|
||||
* @param orderNumber:
|
||||
* @return RespDeviceEntity
|
||||
*/
|
||||
RespDeviceEntity orderQuery(String orderNumber);
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package cn.pluss.platform.ali.device.impl;
|
||||
|
||||
import cn.pluss.platform.ali.device.AliDeviceService;
|
||||
import cn.pluss.platform.alidevice.AliScanCodeDevicePayEntity;
|
||||
import cn.pluss.platform.alidevice.AliScanCodeDevicePayEnum;
|
||||
import cn.pluss.platform.alidevice.AliScanCodeDeviceStatus;
|
||||
import cn.pluss.platform.alidevice.RespDeviceEntity;
|
||||
import cn.pluss.platform.api.Result;
|
||||
import cn.pluss.platform.api.ResultCode;
|
||||
import cn.pluss.platform.api.ResultGenerator;
|
||||
import cn.pluss.platform.deviceStock.DeviceStockService;
|
||||
import cn.pluss.platform.dto.MerChantOrderDTO;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mercOrderToken.MercOrderTokenService;
|
||||
import cn.pluss.platform.merchant.MerchantBaseInfoService;
|
||||
import cn.pluss.platform.merchantChannelStatus.MerchantChannelStatusService;
|
||||
import cn.pluss.platform.merchantOrder.MerchantOrderService;
|
||||
import cn.pluss.platform.pay.PayService;
|
||||
import cn.pluss.platform.ryx.pay.RyxPayService;
|
||||
import cn.pluss.platform.sxf.pay.SxfPayService;
|
||||
import cn.pluss.platform.util.ParametersUtil;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*阿里云扫码王服务实现类
|
||||
*@author: bzg
|
||||
*@time: 2021/12/22 11:34
|
||||
*/
|
||||
@Service("aliScanCodeDeviceService")
|
||||
@Slf4j
|
||||
public class AliScanCodeDeviceServiceImpl implements AliDeviceService {
|
||||
|
||||
@Resource
|
||||
private DeviceStockService deviceStockService;
|
||||
@Resource
|
||||
private MerchantBaseInfoService baseInfoService;
|
||||
@Resource
|
||||
private MerchantOrderService merchantOrderService;
|
||||
@Resource
|
||||
private MercOrderTokenService mercOrderTokenService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired, @Qualifier("ysPayOldService")})
|
||||
private PayService ysPayOldService;
|
||||
|
||||
@Resource
|
||||
private RyxPayService ryxPayService;
|
||||
|
||||
@Resource
|
||||
private SxfPayService sxfPayService;
|
||||
|
||||
@Resource
|
||||
private MerchantChannelStatusService channelService;
|
||||
|
||||
@Override
|
||||
public RespDeviceEntity getDeviceStatusV1(String deviceNo) {
|
||||
if(StringUtil.isEmpty(deviceNo)){
|
||||
return RespDeviceEntity.fail("无效的设备号!");
|
||||
}
|
||||
DeviceStock deviceStock = deviceStockService.getDevicebyNo(deviceNo);
|
||||
return AliScanCodeDeviceStatus.getAliDeviceStatusV1(deviceStock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RespDeviceEntity getDeviceStatusV2(String deviceNo) {
|
||||
if(StringUtil.isEmpty(deviceNo)){
|
||||
return RespDeviceEntity.fail("无效的设备号!");
|
||||
}
|
||||
DeviceStock deviceStock = deviceStockService.getDevicebyNo(deviceNo);
|
||||
return AliScanCodeDeviceStatus.getAliDeviceStatusV2(deviceStock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Object> bindDevice(String deivceNo, String userId) {
|
||||
DeviceStock deviceStock = deviceStockService.getDevicebyNo(deivceNo);
|
||||
MsgException.checkNull(deviceStock,"无效的设备号");
|
||||
MsgException.check("3".equals(deviceStock.getStatus()),"当前设备已被其他商户绑定");
|
||||
MerchantBaseInfo baseInfo = baseInfoService.getMerchantBaseInfoByUserId(userId);
|
||||
MsgException.checkNull(baseInfo,"无效用户");
|
||||
deviceStock.setActMercId(baseInfo.getId().toString());
|
||||
deviceStock.setActMercName(baseInfo.getAlias());
|
||||
deviceStockService.updateById(deviceStock);
|
||||
return ResultGenerator.genSuccessResult("绑定成功",null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RespDeviceEntity orderPay(AliScanCodeDevicePayEntity entity, String payCode) {
|
||||
log.info("【阿里云扫码王】主扫请求参数:{}", JSON.toJSONString(entity));
|
||||
if(StringUtil.isEmpty(entity.getCode()) && StringUtil.isEmpty(entity.getSn())){
|
||||
return RespDeviceEntity.fail("缺失设备SN号");
|
||||
}
|
||||
String deviceNo = StringUtil.isEmpty(entity.getCode()) ? entity.getSn() : entity.getCode();
|
||||
entity.setCode(deviceNo);
|
||||
entity.setSn(deviceNo);
|
||||
if(StringUtil.isEmpty(entity.getFee())){
|
||||
return RespDeviceEntity.fail("缺少支付金额");
|
||||
}
|
||||
if (!StringUtil.isNumber(entity.getFee().toString())) {
|
||||
return RespDeviceEntity.fail("金额格式不正确,保留两位小数,单位(元)!");
|
||||
}
|
||||
RespDeviceEntity rde = this.getDeviceStatusV2(entity.getCode());
|
||||
if(rde.getCode() != 0 || rde.getData() == null){
|
||||
return rde;
|
||||
}
|
||||
AliScanCodeDeviceStatus deviceStatus = (AliScanCodeDeviceStatus)rde.getData();
|
||||
if(StringUtil.isEmpty(deviceStatus.getMercId())){
|
||||
return RespDeviceEntity.fail("该设备还未激活,请激活后再使用");
|
||||
}
|
||||
MerchantBaseInfo baseInfo = baseInfoService.getById(deviceStatus.getMercId());
|
||||
if(baseInfo == null){
|
||||
return RespDeviceEntity.fail("商户异常,暂时无法交易!");
|
||||
}
|
||||
try {
|
||||
if(AliScanCodeDevicePayEnum.BARCODE.getCode().equals(payCode)){
|
||||
if(StringUtil.isEmpty(entity.getAuth())){
|
||||
return RespDeviceEntity.fail("未获取到付款码信息");
|
||||
}
|
||||
MerChantOrderDTO dto = new MerChantOrderDTO();
|
||||
dto.setType("0");
|
||||
dto.setMerchantCode(baseInfo.getMerchantCode());
|
||||
dto.setMerchantName(baseInfo.getAlias());
|
||||
dto.setConsumeFee(entity.getFee());
|
||||
dto.setAuthCode(entity.getAuth());
|
||||
dto.setMerchantBaseInfo(baseInfo);
|
||||
dto.setDeviceNo(entity.getCode());
|
||||
dto.setRemark(entity.getRemark());
|
||||
try {
|
||||
Result<Object> mapResult = merchantOrderService.toActivePay(dto);
|
||||
Object data = mapResult.getData();
|
||||
if (ResultCode.TRANSUNKNOW.code() == mapResult.getCode()) {
|
||||
return RespDeviceEntity.await(mapResult.getMessage(),((Map)data).get("orderNumber"));
|
||||
}else if (ResultCode.SUCCESS.code() == mapResult.getCode()) {
|
||||
return RespDeviceEntity.success(mapResult.getMessage(),((Map)data).get("orderNumber"));
|
||||
}else{
|
||||
return RespDeviceEntity.fail(mapResult.getMessage());
|
||||
}
|
||||
}catch (Exception e){
|
||||
return RespDeviceEntity.fail(e.getMessage());
|
||||
}
|
||||
}else if(AliScanCodeDevicePayEnum.QRCODE.getCode().equals(payCode)){
|
||||
String orderNumber = "AS_"+StringUtil.getBillno();
|
||||
MercOrderToken token = new MercOrderToken(baseInfo,entity.getFee(),entity.getCode(),orderNumber);
|
||||
mercOrderTokenService.save(token);
|
||||
String payUrl = ParametersUtil.domain + "/wap/merchant/scanPayAuth?tk="+token.getToken();
|
||||
Map<String, Object> result = new HashMap<>(2);
|
||||
result.put("trace",orderNumber);
|
||||
result.put("qr_code",payUrl);
|
||||
return RespDeviceEntity.success("获取成功",result);
|
||||
}else{
|
||||
return RespDeviceEntity.fail("未知操作");
|
||||
}
|
||||
}catch (MsgException e){
|
||||
e.printStackTrace();
|
||||
return RespDeviceEntity.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RespDeviceEntity orderQuery(String orderNumber) {
|
||||
if(StringUtil.isEmpty(orderNumber)){
|
||||
return RespDeviceEntity.fail("缺少订单号");
|
||||
}
|
||||
QueryWrapper<MerchantOrder> queryWrapper = new QueryWrapper<MerchantOrder>().eq("orderNumber",orderNumber);
|
||||
MerchantOrder order = merchantOrderService.getOne(queryWrapper);
|
||||
if(order == null){
|
||||
return RespDeviceEntity.await("等待支付中...",orderNumber);
|
||||
}
|
||||
Map<String,Object> result = new HashMap<>(2);
|
||||
if("1".equals(order.getStatus())){
|
||||
result.put("amount",order.getConsumeFee().toString());
|
||||
return RespDeviceEntity.success("支付成功",result);
|
||||
}else if("5".equals(order.getStatus()) || "7".equals(order.getStatus())){
|
||||
try {
|
||||
Integer chnnelId = "2".equals(order.getAisleSwitch()) ? 1 : Integer.valueOf(order.getAisleSwitch());
|
||||
MerchantChannelStatus channel = channelService.getByMerchantCode(order.getMerchantCode(), chnnelId);
|
||||
JSONObject res = null;
|
||||
switch (channel.getChannel()){
|
||||
case 1:
|
||||
res = sxfPayService.tradeQuery(order,channel.getMerchantId());
|
||||
break;
|
||||
case 3:
|
||||
res = ryxPayService.tradeQuery(order,channel.getMerchantId());
|
||||
break;
|
||||
case 4:
|
||||
res = ysPayOldService.tradeQuery(order,channel.getMerchantId());
|
||||
break;
|
||||
}
|
||||
if(res != null){
|
||||
String payStatus = res.getString("payStatus");
|
||||
if("0".equals(payStatus)){
|
||||
return RespDeviceEntity.fail("支付失败",order.getOrderNumber());
|
||||
}
|
||||
}
|
||||
return RespDeviceEntity.await("支付状态未知",order.getOrderNumber());
|
||||
}catch (Exception e){
|
||||
return RespDeviceEntity.await("支付状态未知",order.getOrderNumber());
|
||||
}
|
||||
}else{
|
||||
return RespDeviceEntity.fail("支付失败",order.getOrderNumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
package cn.pluss.platform.ali.impl;
|
||||
|
||||
import cn.pluss.platform.ali.AliPayNotifyService;
|
||||
import cn.pluss.platform.device.MercOrderNewService;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.merchantIncome.MerchantIncomeService;
|
||||
import cn.pluss.platform.merchantOrder.MerchantOrderService;
|
||||
import cn.pluss.platform.merchantProfit.MerchantProfitService;
|
||||
import cn.pluss.platform.notice.NoticeService;
|
||||
import cn.pluss.platform.pay.PayCallbackService;
|
||||
import cn.pluss.platform.pay.impl.BaseCallbackService;
|
||||
import cn.pluss.platform.systemConfig.SystemConfigService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.userInfo.UserInfoService;
|
||||
import cn.pluss.platform.util.DateUtils;
|
||||
import cn.pluss.platform.user.impl.GeneralPushUtil;
|
||||
import cn.pluss.platform.util.ParametersUtil;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author DJH
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AliPayNotifyServiceImpl extends BaseCallbackService implements AliPayNotifyService, PayCallbackService {
|
||||
|
||||
@Autowired
|
||||
private GeneralPushUtil generalPushUtil;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private MerchantOrderService merchantOrderService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private MerchantIncomeService merchantIncomeService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private UserAppService userAppService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private MerchantProfitService merchantProfitService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private NoticeService noticeService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private MercOrderNewService mercOrderNewService;
|
||||
|
||||
@Override
|
||||
public void commonPayNotify(Map<String, Object> param) {
|
||||
// 商家订单号
|
||||
String orderNumber = (String) param.get("out_trade_no");
|
||||
|
||||
if (orderNumber != null && orderNumber.startsWith(MerchantOrder.UPGRADE_ORDER_PREFIX)) {
|
||||
spreadUpgradePayNotify(param);
|
||||
return;
|
||||
}
|
||||
|
||||
devicePayNotify(param);
|
||||
}
|
||||
|
||||
private void checkSign(Map<String, String> params) throws AlipayApiException {
|
||||
boolean signVerified = AlipaySignature.rsaCheckV1(params, ParametersUtil.ZY_PUB, "UTF-8", "RSA2");
|
||||
if (!signVerified) {
|
||||
throw new MsgException("支付宝回调验签失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void devicePayNotify(Map<String, Object> param) {
|
||||
String tradeNumber = (String) param.get("trade_no");
|
||||
// 商家订单号
|
||||
String orderNumber = (String) param.get("out_trade_no");
|
||||
// 交易付款时间
|
||||
String consumeTime = (String) param.get("gmt_payment");
|
||||
Date transDt = DateUtils.parse(consumeTime, "yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
devicePaySuccessNotify(orderNumber, tradeNumber, tradeNumber, transDt, param);
|
||||
mercOrderNewService.devicePaySuccessNotifyV2(orderNumber, tradeNumber,tradeNumber, transDt, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spreadUpgradePayNotify(Map<String, Object> param) {
|
||||
String orderNumber = (String) param.get("out_trade_no");// 微信交易流水号
|
||||
String tradeNo = (String) param.get("trade_no");
|
||||
|
||||
String consumeTime = (String) param.get("gmt_payment");
|
||||
Date transDt = DateUtils.parse(consumeTime, "yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
upgradeSuccessNotify(orderNumber, tradeNo, tradeNo, transDt, param);
|
||||
|
||||
// 计算分润 profitAmt
|
||||
try {
|
||||
merchantIncome(param);
|
||||
}catch (Exception e){
|
||||
log.error("升级回调更新分润异常,订单号:{},异常信息:{}",param.get("out_trade_no"),e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 更新订单信息
|
||||
updateOrderStatus(param);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新订单信息和状态
|
||||
*
|
||||
* @param param 订单回调信息
|
||||
*/
|
||||
private void updateOrderStatus(Map<String, Object> param) {
|
||||
// 商户订单号
|
||||
String orderNumber = (String) param.get("out_trade_no");
|
||||
// 支付宝交易号
|
||||
String tradeNo = (String) param.get("trade_no");
|
||||
MerchantOrder mOrder = new MerchantOrder().setOrderNumber(orderNumber);
|
||||
mOrder = merchantOrderService.getOne(new QueryWrapper<>(mOrder));
|
||||
|
||||
mOrder.setThirdTransNo(tradeNo);
|
||||
// 交易付款时间
|
||||
String consumeTime = (String) param.get("gmt_payment");
|
||||
mOrder.setStatus("1");
|
||||
mOrder.setTransDt(DateUtils.parse(consumeTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
mOrder.setTransNo(tradeNo);
|
||||
String profitAmt = (String) param.get("profitAmt");
|
||||
if(StringUtil.isNotEmpty(profitAmt)){
|
||||
mOrder.setProfitShareMoney(Double.valueOf(profitAmt));
|
||||
}
|
||||
merchantOrderService.updateById(mOrder);
|
||||
}
|
||||
|
||||
private void merchantIncome(Map<String, Object> param) {
|
||||
String ordersSn = (String) param.get("out_trade_no");
|
||||
MerchantIncome merchantIncome = new MerchantIncome();
|
||||
merchantIncome.setDealCode(ordersSn);
|
||||
merchantIncome = merchantIncomeService.queryMerchantIncome(merchantIncome);
|
||||
merchantIncome.setDealStatus(1);
|
||||
merchantIncomeService.updateMerchantIncome(merchantIncome);
|
||||
|
||||
UserApp userApp = new UserApp();
|
||||
userApp.setUserId(merchantIncome.getUserId().longValue());
|
||||
userApp = userAppService.queryUserApp(userApp);
|
||||
|
||||
String content = "";
|
||||
|
||||
if (userApp == null || userApp.getParentId() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
UserApp userApp2 = new UserApp();
|
||||
userApp2.setUserId(userApp.getParentId());
|
||||
userApp2 = userAppService.queryUserApp(userApp2);
|
||||
|
||||
String userName = "";
|
||||
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(userApp.getUserId());
|
||||
userInfo = userInfoService.queryUserInfo(userInfo);
|
||||
String twoConfigValue = systemConfigService.querySystemConfigValue("twoUpVipAmount");
|
||||
String threeConfigValue = systemConfigService.querySystemConfigValue("threeUpVipAmount");
|
||||
userName = userInfo.getLoginName().substring(0, 11);
|
||||
|
||||
userName = StringUtil.isHideMobile(userName);
|
||||
|
||||
MerchantProfit profit = new MerchantProfit();
|
||||
profit.setUserId(userApp.getParentId());
|
||||
profit.setMerchantCode("M800202008254990744");
|
||||
profit.setMerchantName("安象科技公司");
|
||||
profit.setConsumeFee(merchantIncome.getDealFee());
|
||||
Double twoVipAmountD = 999.00;
|
||||
Double twoVipShapeAmtD = 500.00;
|
||||
Double threeVipAmountD = 9999.00;
|
||||
Double threeVipShapeAmtD = 5000.00;
|
||||
if (StringUtil.isNotEmpty(twoConfigValue)) {
|
||||
String twoVipAmount = twoConfigValue.split("-")[0];
|
||||
String twoVipShapeAmount = twoConfigValue.split("-")[1];
|
||||
twoVipAmountD = Double.valueOf(twoVipAmount);
|
||||
twoVipShapeAmtD = Double.valueOf(twoVipShapeAmount);
|
||||
}
|
||||
if (StringUtil.isNotEmpty(threeConfigValue)) {
|
||||
String threeVipAmount = threeConfigValue.split("-")[0];
|
||||
String threeVipShapeAmount = threeConfigValue.split("-")[1];
|
||||
threeVipAmountD = Double.valueOf(threeVipAmount);
|
||||
threeVipShapeAmtD = Double.valueOf(threeVipShapeAmount);
|
||||
}
|
||||
if (twoVipAmountD.equals(merchantIncome.getDealFee())) {
|
||||
profit.setPrice(twoVipShapeAmtD);
|
||||
userApp.setLevel(2);
|
||||
content = "您的直接推荐 " + userName + "付费升级v2,收益" + twoVipShapeAmtD + "元";
|
||||
}
|
||||
if (threeVipAmountD.equals(merchantIncome.getDealFee())) {
|
||||
profit.setPrice(threeVipShapeAmtD);
|
||||
userApp.setLevel(3);
|
||||
content = "您的直接推荐 " + userName + "付费升级v3,收益" + threeVipShapeAmtD + "元";
|
||||
}
|
||||
|
||||
profit.setType("4");
|
||||
profit.setCreateDt(new Date());
|
||||
profit.setOrderDt(merchantIncome.getCreateTime());
|
||||
profit.setStatus("1");
|
||||
profit.setOrderNumber(ordersSn);
|
||||
merchantProfitService.saveMerchantProfit(profit);
|
||||
userAppService.updateById(userApp);
|
||||
param.put("profitAmt",profit.getPrice().toString());
|
||||
|
||||
List<String> alias = new ArrayList<>();
|
||||
log.info("=========推送人userId======" + profit.getUserId() + "=========金额=======" + profit.getPrice());
|
||||
alias.add(profit.getUserId() + "");
|
||||
|
||||
if (userApp2 != null) {
|
||||
Notice notice = new Notice(0, 7, userApp2);
|
||||
notice.setConrtent(content);
|
||||
|
||||
noticeService.saveNotice(notice);
|
||||
generalPushUtil.sendAllPlatByAlias(alias, "升级分润通知", content, "0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void orderCallback(Map<String, Object> callbackData) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
package cn.pluss.platform.ali.impl;
|
||||
|
||||
import cn.pluss.platform.ali.AliService;
|
||||
import cn.pluss.platform.api.Result;
|
||||
import cn.pluss.platform.api.ResultCode;
|
||||
import cn.pluss.platform.api.ResultGenerator;
|
||||
import cn.pluss.platform.device.DeviceOrderInfoService;
|
||||
import cn.pluss.platform.deviceMerchantBuy.DeviceMerchantBuyService;
|
||||
import cn.pluss.platform.deviceMerchantBuyDetail.DeviceMerchantBuyDetailService;
|
||||
import cn.pluss.platform.dto.BatchInfoDTO;
|
||||
import cn.pluss.platform.dto.DeviceMerchantBuyDTO;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.MerchantBaseInfoMapper;
|
||||
import cn.pluss.platform.mapper.SystemConfigMapper;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.util.AliPayParam;
|
||||
import cn.pluss.platform.util.ParametersUtil;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.FileItem;
|
||||
import com.alipay.api.domain.AlipayTradeAppPayModel;
|
||||
import com.alipay.api.request.*;
|
||||
import com.alipay.api.response.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuchen
|
||||
*
|
||||
* @Description
|
||||
*/
|
||||
@Transactional
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service("aliService")
|
||||
public class AliServiceImpl implements AliService {
|
||||
|
||||
public static AlipayClient alipayClients = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
|
||||
AliPayParam.getAppId(), AliPayParam.getPri(), "json", "GBK", AliPayParam.getPub(), "RSA2");
|
||||
|
||||
private final SystemConfigMapper systemConfigMapper;
|
||||
|
||||
private final UserAppService userAppService;
|
||||
|
||||
private final MerchantBaseInfoMapper merchantBaseInfoMapper;
|
||||
|
||||
private final DeviceMerchantBuyService deviceMerchantBuyService;
|
||||
|
||||
private final DeviceMerchantBuyDetailService deviceMerchantBuyDetailService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private DeviceOrderInfoService deviceOrderInfoService;
|
||||
|
||||
@Setter
|
||||
@Lazy
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public Result<String> getBatchNo(MerchantBaseInfo merchantBaseInfo) {
|
||||
AlipayClient alipayClient = alipayClients;
|
||||
AlipayOpenAgentCreateRequest request = new AlipayOpenAgentCreateRequest();
|
||||
request.setBizContent("{" + "\"account\":\"" + merchantBaseInfo.getAliAccount() + "\"," + "\"contact_info\":{"
|
||||
+ "\"contact_name\":\"" + merchantBaseInfo.getContactName() + "\"," + "\"contact_mobile\":\""
|
||||
+ merchantBaseInfo.getContactMobile() + "\"," + "\"contact_email\":\"" + merchantBaseInfo.getEmail() + "\"" + "}," + "}");
|
||||
try {
|
||||
AlipayOpenAgentCreateResponse response = alipayClient.execute(request);
|
||||
if (response.isSuccess()) {
|
||||
if ("10000".equals(response.getCode())) {
|
||||
return ResultGenerator.genSuccessResult(response.getBatchNo());
|
||||
} else {
|
||||
return ResultGenerator.genFailResult(response.getSubMsg());
|
||||
}
|
||||
} else {
|
||||
return ResultGenerator.genFailResult(response.getSubMsg());
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return ResultGenerator.genFailResult("系统繁忙,请稍后再试");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean facetofaceSign(BatchInfoDTO dto) {
|
||||
log.info("=========BatchInfoDTO=======" + JSONObject.toJSONString(dto));
|
||||
AlipayClient alipayClient = alipayClients;
|
||||
String businessLicensePic = dto.getBusinessLicensePic();
|
||||
try {
|
||||
SystemConfig systemConfig = new SystemConfig();
|
||||
systemConfig.setPropertyKey("REPLACE");
|
||||
SystemConfig querySystemConfig = systemConfigMapper.querySystemConfig(systemConfig);
|
||||
businessLicensePic = businessLicensePic.replace("https://www.shouyinbei.net",
|
||||
querySystemConfig.getPropertyValue());
|
||||
log.info(businessLicensePic);
|
||||
FileItem BusinessLicensePic = new FileItem(businessLicensePic);
|
||||
String shopSignBoardPic = dto.getShopSignBoardPic();
|
||||
shopSignBoardPic = shopSignBoardPic.replace("https://www.shouyinbei.net",
|
||||
querySystemConfig.getPropertyValue());
|
||||
log.info(shopSignBoardPic);
|
||||
FileItem ShopSignBoardPic = new FileItem(shopSignBoardPic);
|
||||
AlipayOpenAgentFacetofaceSignRequest request = new AlipayOpenAgentFacetofaceSignRequest();
|
||||
request.setBatchNo(dto.getBatchNo());
|
||||
request.setMccCode(dto.getMccCode());
|
||||
request.setBusinessLicenseNo(dto.getBusinessLicenseNo());
|
||||
request.setBusinessLicensePic(BusinessLicensePic);
|
||||
request.setShopSignBoardPic(ShopSignBoardPic);
|
||||
AlipayOpenAgentFacetofaceSignResponse response = alipayClient.execute(request);
|
||||
log.info("=====代签约当面付=====" + response);
|
||||
if (response.isSuccess()) {
|
||||
if ("10000".equals(response.getCode())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean agentConfirm(String batchNo) {
|
||||
log.info("=agentConfirm提交事务=" + batchNo);
|
||||
AlipayClient alipayClient = alipayClients;
|
||||
AlipayOpenAgentConfirmRequest request = new AlipayOpenAgentConfirmRequest();
|
||||
request.setBizContent("{" + "\"batch_no\":\"" + batchNo + "\"" + " }");
|
||||
|
||||
try {
|
||||
AlipayOpenAgentConfirmResponse response = alipayClient.execute(request);
|
||||
log.info("=agentConfirm提交事务=" + response);
|
||||
if (response.isSuccess()) {
|
||||
if ("10000".equals(response.getCode())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Map<String, Object>> appPayParam(Map<String, String> map, DeviceMerchantBuyDTO deviceMerchantBuyDTO) {
|
||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", ParametersUtil.ZY_ALI_APP_ID, ParametersUtil.ZY_PRI, "json", "UTF-8", ParametersUtil.ZY_PUB, "RSA2");
|
||||
AlipayTradeAppPayRequest appPayRequest = getPayRequest(map);
|
||||
appPayRequest.setNotifyUrl(ParametersUtil.domain + "/wap/aliPay/aliCallBack");
|
||||
try {
|
||||
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(appPayRequest);//这里和普通的接口调用不同,使用的是sdkExecute
|
||||
// System.out.println(response.getBody());//就是orderString 可以直接给客户端请求,无需再做处理。
|
||||
boolean createOrder = createOrder(map.get("outTradeNo") + "", deviceMerchantBuyDTO, request);
|
||||
if (createOrder) {
|
||||
Map<String, Object> resultMap = new HashMap<>(16);
|
||||
resultMap.put("aliCode", response.getBody());
|
||||
return ResultGenerator.genSuccessResult(resultMap);
|
||||
} else {
|
||||
return ResultGenerator.genFailResult("系统繁忙,请稍后再试");
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
return ResultGenerator.genFailResult("请求失败,请稍后再试");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Map<String, Object>> appPayParamV2(Map<String, String> map, DeviceMerchantBuyDTO deviceMerchantBuyDTO) {
|
||||
Map<String, Object> result = appPayParam(map);
|
||||
boolean createOrder = createOrder(map.get("outTradeNo") + "", deviceMerchantBuyDTO, request);
|
||||
if (createOrder) {
|
||||
deviceOrderInfoService.createOrder(map.get("outTradeNo") + "", deviceMerchantBuyDTO);
|
||||
return ResultGenerator.genSuccessResult(result);
|
||||
} else {
|
||||
return ResultGenerator.genFailResult("系统繁忙,请稍后再试");
|
||||
}
|
||||
}
|
||||
|
||||
private AlipayTradeAppPayRequest getPayRequest(Map<String, String> map) {
|
||||
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
|
||||
AlipayTradeAppPayRequest appPayRequest = new AlipayTradeAppPayRequest();
|
||||
//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
|
||||
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
|
||||
model.setBody(map.get("body"));
|
||||
model.setSubject(map.get("subject"));
|
||||
model.setOutTradeNo(map.get("outTradeNo"));
|
||||
model.setTotalAmount(map.get("totalAmount"));
|
||||
appPayRequest.setBizModel(model);
|
||||
appPayRequest.setNotifyUrl(ParametersUtil.domain + "/wap/aliPay/aliCallBackV2");
|
||||
|
||||
return appPayRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> appPayParam(Map<String, String> map) {
|
||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", ParametersUtil.ZY_ALI_APP_ID, ParametersUtil.ZY_PRI, "json", "UTF-8", ParametersUtil.ZY_PUB, "RSA2");
|
||||
AlipayTradeAppPayRequest appPayRequest = getPayRequest(map);
|
||||
try {
|
||||
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(appPayRequest);
|
||||
Map<String, Object> resultMap = new HashMap<>(16);
|
||||
resultMap.put("aliCode", response.getBody());
|
||||
return resultMap;
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new MsgException("请求失败,请稍后再试");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* createOrder:(创建订单). <br/>
|
||||
*
|
||||
* @param deviceMerchantBuyDTO
|
||||
* @return
|
||||
*
|
||||
* @author Administrator
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
public boolean createOrder(String orderNo, DeviceMerchantBuyDTO deviceMerchantBuyDTO, HttpServletRequest request) {
|
||||
DeviceMerchantBuy deviceMerchantBuy = deviceMerchantBuyDTO.convertDeviceMerchantBuy();
|
||||
try {
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
Long userId = userApp.getUserId();
|
||||
MerchantBaseInfo merchantBaseInfo;
|
||||
List<MerchantBaseInfo> queryMerchantBaseInfoList = merchantBaseInfoMapper.selectListByUserId(userId);
|
||||
if (queryMerchantBaseInfoList != null && queryMerchantBaseInfoList.size() > 0) {
|
||||
merchantBaseInfo = queryMerchantBaseInfoList.get(0);
|
||||
deviceMerchantBuy.setMerchantCode(merchantBaseInfo.getMerchantCode());
|
||||
deviceMerchantBuy.setMerchantName(merchantBaseInfo.getMerchantName());
|
||||
}
|
||||
deviceMerchantBuy.setOrderNo(orderNo);
|
||||
deviceMerchantBuyService.saveDeviceMerchantBuy(deviceMerchantBuy);
|
||||
for (int i = 0; i < deviceMerchantBuyDTO.getQuantity(); i++) {
|
||||
DeviceMerchantBuyDetail deviceMerchantBuyDetail = new DeviceMerchantBuyDetail();
|
||||
deviceMerchantBuyDetail.setOrderNo(orderNo);
|
||||
deviceMerchantBuyDetail.setSoleCode(StringUtil.genRandomNum(3) + StringUtil.getBillno());
|
||||
deviceMerchantBuyDetailService.saveDeviceMerchantBuyDetail(deviceMerchantBuyDetail);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Map<String, Object>> appRefund(DeviceMerchantBuy deviceMerchantBuy) {
|
||||
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
|
||||
request.setBizContent("{" + "\"out_trade_no\":\"" + deviceMerchantBuy.getOrderNo() + "\"," + "\"refund_amount\":" + deviceMerchantBuy.getOrderAmount() + "" + "}");
|
||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", AliPayParam.getAppId(), AliPayParam.getPri(), "json", "UTF-8", AliPayParam.getPub(), "RSA2");
|
||||
try {
|
||||
AlipayTradeRefundResponse response = alipayClient.execute(request);
|
||||
if (response.isSuccess()) {
|
||||
deviceMerchantBuy.setStatus("2");
|
||||
deviceMerchantBuyService.updateDeviceMerchantBuy(deviceMerchantBuy);
|
||||
Map<String, Object> result = new HashMap<String, Object>(16);
|
||||
result.put("aliCode", "退款成功");
|
||||
return ResultGenerator.genSuccessResult(result);
|
||||
} else {
|
||||
return ResultGenerator.genFailResult("退款失败");
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
return ResultGenerator.genFailResult("退款失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款V2
|
||||
* @param orderDetail
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> refundV2(MercOrderDetail orderDetail) {
|
||||
Map<String, Object> result = new HashMap<>(4);
|
||||
result.put("code", ResultCode.SUCCESS.code());
|
||||
result.put("msg","退款成功!");
|
||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", ParametersUtil.ZY_ALI_APP_ID, ParametersUtil.ZY_PRI, "json", "UTF-8", ParametersUtil.ZY_PUB, "RSA2");
|
||||
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
|
||||
String refundNo = "ALIR" + StringUtil.getBillno();
|
||||
result.put("refundNo",refundNo);
|
||||
JSONObject bizContent = new JSONObject();
|
||||
bizContent.put("out_trade_no", orderDetail.getOrderNo());
|
||||
bizContent.put("refund_amount", orderDetail.getRefundAmt());
|
||||
bizContent.put("out_request_no", refundNo);
|
||||
bizContent.put("refund_reason",orderDetail.getRefundReason());
|
||||
request.setBizContent(bizContent.toString());
|
||||
try {
|
||||
AlipayTradeRefundResponse response = alipayClient.execute(request);
|
||||
if(!response.isSuccess()){
|
||||
result.put("code",ResultCode.FAIL.code());
|
||||
result.put("msg",response.getSubMsg());
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
result.put("code",ResultCode.FAIL.code());
|
||||
result.put("msg","退款失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package cn.pluss.platform.ali.impl;
|
||||
|
||||
import cn.pluss.platform.ali.AlipayService;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.CertAlipayRequest;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipayFundTransUniTransferRequest;
|
||||
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AlipayServiceImpl implements AlipayService {
|
||||
@Override
|
||||
public void remit(String account, String realName, String money) {
|
||||
try {
|
||||
CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
|
||||
certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do");
|
||||
// certAlipayRequest.setAppId("2021001189650608");
|
||||
// certAlipayRequest.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDWIvHm57tQURFF+UKIxNnnZcxnBPZ5oXwQlJjmUzv3qInD/I9TBBBvlRsY1ugRioH7KGwpUI0vjBuSzZYKx8ckktAIb03j75nSHOFD0Mn23y73bjVznj2NVLeVvDKPP8vfFO+7VYM2vBNHrXlvBSjfb/0gP0wZa1H2uqwKVdRHnTJgllzINKcO8ttosRqUZlj8oysCbV8BXDQ5B8QPKsvbtbva9v8giwp3Utk490Ufqh/cX0IL28PMBBp0SL7ptrbN9mT7FA02+T9Me1BevXBHBsqykgZfbuptEIg/tn93lBCM4cP70nXMz4hTYSPHp9f1QZjsdMxtOEhiWNoJeO6jAgMBAAECggEAaTr3AW/zfv63rFlXtvp10t8V2bJ4pUEURNmhYd6ZY5UxTly42iTvJsZxcH17wdL9GT2+GXd6Sllh23yoNVgDpxd2oA6CinbecoC6uqbJ+UWoQPOp1M14lhGBvlWjyv2g5FnXjYnyV12JY/n96O7yLQtNqyEv9nXk64jErreLAD17u8mQKDWx0E3s6j3JewCS/gpCoiPVGr4Aoh5pZQqZPvdirFtnLhPbphQAe/xRxMXn3SCTh/I+ggAlPf4pi20nYSJH/yV3RnPMg5GmwQm8Yr46ducbUyeQWjN2Gktaixz3ZGKX9RDabahHU5S4/RiCVF0/Mt6qun3j+AXC/NfkMQKBgQDqOPhRC1mzZE86KlfWpIW48hvjEY3UQW89OGpLfsGrh5JU4xhI+7ahFQZ212xIH3Ee4lqzLcfQIGZUZOAytQtSVOQ54FvQQYO1DlAr8RdFoNQAua9Z08If9LGNg7+b+dWDcnfAf07oV+zqBMy3+3+oQAupv/0v2C4szNxqQOBl7wKBgQDqC+GsyGXt0PRhWXr8jN3LoKv/z1+GLrk5EnW7DW4NYdI3OshY4F284QV57PFvS93HKh7hHinGlSniwR39yCmU6SsF+NSERsBQnm1y6Nof7i2Ywoz3yYKBzcplwlwN/3D7hH/SjlxKFAf0REcXIMSv/rmN8VQ6BfzIJ1ln9QXWjQKBgQDbRPQqou6Zw3lsIYHT3neVeYpj2+Yj5BIohOz1ujfCxgtWzrbIdGU3jcBcdzXWmyDCYfO5NE2P6RUDQuCkd9qee/ygtgod/4c2c6zYRj6cH4D5INwowtZEJkYmDkXN1mhtQzcajdQoLVAMkOu5/Yc30qVYh/SV2tL3e92I1y18HwKBgCzj3oMfZL16aIULfpVWB2x5AsRr5+x6pbgWnFImP0d9za4eLjMtxYzmtAAwvBYWvRDoOUgAWw7lqUT+uVvlumP/XOsmUMyWLWjJGkEB/GRHcKNuHU+hbNCswfdGkhV1Oxxiy4l9GKJ0uRnWxrPe6xq+hqR89ySx5UwWkAVqb5Y5AoGAPEc//P14ppYSx/G3f2rFML/G2pc6OgSABtbbKSgziX11AbVEzaqmmQI39TMkaLSdBAzqzmaLg3ZYnHsvBLg1il/7xE/d7nYlkaCwbEC+M1MzPGzXODt+5jusUVzO4Uk4bX9asBQJsWVhC851eoi/G4o7VZ4tal2fz17pyiuZq40=");
|
||||
// certAlipayRequest.setFormat("json");
|
||||
// certAlipayRequest.setCharset("UTF-8");
|
||||
// certAlipayRequest.setSignType("RSA2");
|
||||
// certAlipayRequest.setCertPath ( "/home/syb/cert/appCertPublicKey_2021001189650608.crt" );
|
||||
// certAlipayRequest.setAlipayPublicCertPath ( "/home/syb/cert/alipayCertPublicKey_RSA2 (2).crt" );
|
||||
// certAlipayRequest.setRootCertPath ( "/home/syb/cert/alipayRootCert (2).crt" );
|
||||
|
||||
certAlipayRequest.setAppId("2021003133649094");
|
||||
String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDP0ky+6wTP7mTiyuA3rfUXW9kibwU3q4V8R/zWE5zGOIaMv/bQ3La/0WWUGHd9K/bsgQ6GLBE+i74QU/3RzfdrbTvrL6GrLupMxxgdiikmvkhPRwkWVPghjNmbJhG6+gva1K8BfE0QtbP3oghnBc78TSyp02aoKFIjo98+21fXUQZs8yagoZBojoQ8zcSr09TsCB4BCm+nSEhD7yEa7HyPcX+FkMtRFXt0XsxnBwV/9T95vaBNGKQoNdvY5evIVRnSInc4E4k8MU3sm+YxrPHWMKWZJn2SP/1kPXIGc/IZkf6AZGeZXMNL36kz8k6Z/1f/TsOKioHX5J498ueuc1HvAgMBAAECggEARDtKoUAuQ0qE6wUq2n0NxA6O2sRSlTWGTQihlXO4/EegvWNlWKuugInybM4fpQQjPQEeUKT1QHDHBTteUVzrR+UEUDJCRR7RJEYVv9UVr7e3q/epnyBkmzdQVqUIGzhvXfiIQNebwcm2fa5ATfrVO3bnHBbhVIJwfW0XJd8EFxfWonUDjtPfk8wTEjmNqz6vXhpk3ncV7MMY07ehbYaMA4NbbysABKRP0S9515JUX0NkBtxnhVm2ojcoc1Wjy3//TN8RXpC17E1Tyd/9pQIxmosLjS1gcX1WzphMZU0Y/74yHiE0WQCKP3J6PkdBTQDIqubyRdErJ9TYSe9+u3OZyQKBgQDrtap3LItv8IjH6O5Lg4xMU9r9dFW8QVc3dD1yn+wWq5x54mnUo5d6cTa7HqZ9SgS7gxWQZG/km9R2cJLQsATlQjdHyEoNKtqdgl3vB8MGK+Lwh6vNhE2z2svRJqQpzZfs1dKwI74mASDzwu/HjdkOFO2BVzjG3IPmrDRmN+7w8wKBgQDhthAKdbkhb7vjlgckGqDyy28QVb1YfZ4YzwW5aZiAhBmQhfZZEB5/KAYKRkToFg6Nqz6cBHwb1rH1YtOua8Dgr5XsqPQz9+MCCrUKxVt/1ziWhkpaNxEobT7QYtJiaGvuLxGP7uqpJGDpePCLHQTxmocsj8UgEE49HDj4qlO6FQKBgFGip5mC2gA5BIaITA/nTa4Z1Ny3cAI1dymDnsyWSsRHR3iHTDQTPKFxmI0SPoNiIWV4Lv3Fa2N3/QvQTWjtraRhXJgF7G/HCdRHlJT20TrP9FduBbi2O9swyip0AaNgy1+BZukOWAr9lRYXy8gHfsd7xA5p0QY+1YgM2FEWyjC1AoGBAKaSAsKFYGuRltp9BKYbVL35bexjKgodIkhyt2m+yQHG+0rR4hyWLbtvYQ3CD+YrKPBZ+SmQkbrFta0/ErL86Gmoiv8NLLMRdCE0n6jkPwNYZHWJg2OSkgIApUOKOnLPVx9+8voCuoC6zR5f1z0C3Hwkqy8ypqpj/ilRI6Y3pPSFAoGAaxBlqCUBFEhs/FnYf9neoPzx9WYDmJY7PgNgZ/s0H9vaGqyWPLWyF95/dTZ5yrBsABQyuIfDa2/m8y1YJaIJ/qU29FDq/GMv6IX4zDgm2iaWNZFnMoW7qSEkpVISSLoVxat4D556YI6FrQeoUAS+L1iEFgS33ln1tTyqb7mSe00=";
|
||||
certAlipayRequest.setPrivateKey(privateKey);
|
||||
certAlipayRequest.setFormat("json");
|
||||
certAlipayRequest.setCharset("UTF-8");
|
||||
certAlipayRequest.setSignType("RSA2");
|
||||
certAlipayRequest.setCertPath ( "/home/syb/cert/20220622/appCertPublicKey_2021003133649094.crt" );
|
||||
certAlipayRequest.setAlipayPublicCertPath ( "/home/syb/cert/20220622/alipayCertPublicKey_RSA2.crt" );
|
||||
certAlipayRequest.setRootCertPath ( "/home/syb/cert/20220622/alipayRootCert.crt" );
|
||||
|
||||
// certAlipayRequest.setAppId("2021003133649094");
|
||||
// String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDP0ky+6wTP7mTiyuA3rfUXW9kibwU3q4V8R/zWE5zGOIaMv/bQ3La/0WWUGHd9K/bsgQ6GLBE+i74QU/3RzfdrbTvrL6GrLupMxxgdiikmvkhPRwkWVPghjNmbJhG6+gva1K8BfE0QtbP3oghnBc78TSyp02aoKFIjo98+21fXUQZs8yagoZBojoQ8zcSr09TsCB4BCm+nSEhD7yEa7HyPcX+FkMtRFXt0XsxnBwV/9T95vaBNGKQoNdvY5evIVRnSInc4E4k8MU3sm+YxrPHWMKWZJn2SP/1kPXIGc/IZkf6AZGeZXMNL36kz8k6Z/1f/TsOKioHX5J498ueuc1HvAgMBAAECggEARDtKoUAuQ0qE6wUq2n0NxA6O2sRSlTWGTQihlXO4/EegvWNlWKuugInybM4fpQQjPQEeUKT1QHDHBTteUVzrR+UEUDJCRR7RJEYVv9UVr7e3q/epnyBkmzdQVqUIGzhvXfiIQNebwcm2fa5ATfrVO3bnHBbhVIJwfW0XJd8EFxfWonUDjtPfk8wTEjmNqz6vXhpk3ncV7MMY07ehbYaMA4NbbysABKRP0S9515JUX0NkBtxnhVm2ojcoc1Wjy3//TN8RXpC17E1Tyd/9pQIxmosLjS1gcX1WzphMZU0Y/74yHiE0WQCKP3J6PkdBTQDIqubyRdErJ9TYSe9+u3OZyQKBgQDrtap3LItv8IjH6O5Lg4xMU9r9dFW8QVc3dD1yn+wWq5x54mnUo5d6cTa7HqZ9SgS7gxWQZG/km9R2cJLQsATlQjdHyEoNKtqdgl3vB8MGK+Lwh6vNhE2z2svRJqQpzZfs1dKwI74mASDzwu/HjdkOFO2BVzjG3IPmrDRmN+7w8wKBgQDhthAKdbkhb7vjlgckGqDyy28QVb1YfZ4YzwW5aZiAhBmQhfZZEB5/KAYKRkToFg6Nqz6cBHwb1rH1YtOua8Dgr5XsqPQz9+MCCrUKxVt/1ziWhkpaNxEobT7QYtJiaGvuLxGP7uqpJGDpePCLHQTxmocsj8UgEE49HDj4qlO6FQKBgFGip5mC2gA5BIaITA/nTa4Z1Ny3cAI1dymDnsyWSsRHR3iHTDQTPKFxmI0SPoNiIWV4Lv3Fa2N3/QvQTWjtraRhXJgF7G/HCdRHlJT20TrP9FduBbi2O9swyip0AaNgy1+BZukOWAr9lRYXy8gHfsd7xA5p0QY+1YgM2FEWyjC1AoGBAKaSAsKFYGuRltp9BKYbVL35bexjKgodIkhyt2m+yQHG+0rR4hyWLbtvYQ3CD+YrKPBZ+SmQkbrFta0/ErL86Gmoiv8NLLMRdCE0n6jkPwNYZHWJg2OSkgIApUOKOnLPVx9+8voCuoC6zR5f1z0C3Hwkqy8ypqpj/ilRI6Y3pPSFAoGAaxBlqCUBFEhs/FnYf9neoPzx9WYDmJY7PgNgZ/s0H9vaGqyWPLWyF95/dTZ5yrBsABQyuIfDa2/m8y1YJaIJ/qU29FDq/GMv6IX4zDgm2iaWNZFnMoW7qSEkpVISSLoVxat4D556YI6FrQeoUAS+L1iEFgS33ln1tTyqb7mSe00=";
|
||||
// certAlipayRequest.setPrivateKey(privateKey);
|
||||
// certAlipayRequest.setFormat("json");
|
||||
// certAlipayRequest.setCharset("UTF-8");
|
||||
// certAlipayRequest.setSignType("RSA2");
|
||||
// certAlipayRequest.setCertPath ( "C:\\Users\\DJH\\Downloads\\appCertPublicKey_2021003133649094.crt" );
|
||||
// certAlipayRequest.setAlipayPublicCertPath ( "C:\\Users\\DJH\\Downloads\\alipayCertPublicKey_RSA2.crt" );
|
||||
// certAlipayRequest.setRootCertPath ( "C:\\Users\\DJH\\Downloads\\alipayRootCert.crt" );
|
||||
DefaultAlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest);
|
||||
// 构建request内容
|
||||
AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
|
||||
JSONObject bizJson = new JSONObject();
|
||||
JSONObject payeeInfo = new JSONObject();
|
||||
// 身份信息设置为帐号
|
||||
payeeInfo.put("identity_type", "ALIPAY_LOGON_ID");
|
||||
payeeInfo.put("identity", account);
|
||||
payeeInfo.put("name", realName);
|
||||
|
||||
bizJson.put("out_biz_no", UUID.randomUUID().toString().replace("-", ""));
|
||||
bizJson.put("trans_amount", money);
|
||||
bizJson.put("product_code", "TRANS_ACCOUNT_NO_PWD");
|
||||
bizJson.put("biz_scene", "DIRECT_TRANSFER");
|
||||
bizJson.put("payee_info", payeeInfo);
|
||||
bizJson.put("order_title", "收银呗分润");
|
||||
bizJson.put("remark", "收银呗分润");
|
||||
|
||||
JSONObject bizParam = new JSONObject();
|
||||
bizParam.put("payer_show_name", "收银呗");
|
||||
|
||||
bizJson.put("business_params", bizParam);
|
||||
|
||||
request.setBizContent(bizJson.toString());
|
||||
|
||||
AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request);
|
||||
if (response.isSuccess()) {
|
||||
log.info("调用成功");
|
||||
} else {
|
||||
log.error(response.getSubMsg());
|
||||
throw new MsgException(response.getSubMsg());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new MsgException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.pluss.platform.aliMcc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import cn.pluss.platform.entity.AliMcc;
|
||||
|
||||
public interface AliMccService {
|
||||
|
||||
public AliMcc queryAliMcc(AliMcc aliMcc);
|
||||
|
||||
public List<AliMcc> queryAliMccList(AliMcc aliMcc);
|
||||
|
||||
public void saveAliMcc(AliMcc aliMcc);
|
||||
|
||||
public void updateAliMcc(AliMcc aliMcc);
|
||||
|
||||
public void deleteAliMcc(AliMcc aliMcc);
|
||||
|
||||
public List<AliMcc> queryAliMccPage(Map map);
|
||||
|
||||
public Integer queryAliMccPageCount(Map map);
|
||||
|
||||
public void saveAliMccBatch(List<AliMcc> aliMccList);
|
||||
|
||||
/**
|
||||
*
|
||||
* queryMcc:(查询支付宝mccCode). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param mccCode
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
public String queryMccCode(String mccCode);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.pluss.platform.aliMcc.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import cn.pluss.platform.aliMcc.AliMccService;
|
||||
import cn.pluss.platform.entity.AliMcc;
|
||||
import cn.pluss.platform.mapper.AliMccMapper;
|
||||
|
||||
@Transactional
|
||||
@Service("aliMccService")
|
||||
public class AliMccServiceImpl implements AliMccService{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger( AliMccServiceImpl.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private AliMccMapper aliMccMapper;
|
||||
|
||||
@Override
|
||||
public AliMcc queryAliMcc(AliMcc aliMcc){
|
||||
return aliMccMapper.queryAliMcc(aliMcc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AliMcc> queryAliMccList(AliMcc aliMcc){
|
||||
return aliMccMapper.queryAliMccList(aliMcc);
|
||||
}
|
||||
@Override
|
||||
public void saveAliMcc(AliMcc aliMcc){
|
||||
aliMccMapper.saveAliMcc(aliMcc);
|
||||
}
|
||||
@Override
|
||||
public void updateAliMcc(AliMcc aliMcc){
|
||||
aliMccMapper.updateAliMcc(aliMcc);
|
||||
}
|
||||
@Override
|
||||
public void deleteAliMcc(AliMcc aliMcc){
|
||||
aliMccMapper.deleteAliMcc(aliMcc);
|
||||
}
|
||||
@Override
|
||||
public List<AliMcc> queryAliMccPage(Map map){
|
||||
return aliMccMapper.queryAliMccPage(map);
|
||||
}
|
||||
@Override
|
||||
public Integer queryAliMccPageCount(Map map){
|
||||
return aliMccMapper.queryAliMccPageCount(map);
|
||||
}
|
||||
@Override
|
||||
public void saveAliMccBatch(List<AliMcc> aliMccList) {
|
||||
aliMccMapper.saveAliMccBatch(aliMccList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryMccCode(String mccCode) {
|
||||
return aliMccMapper.queryMccCode(mccCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.pluss.platform.api;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author crystal
|
||||
* @date 2022/6/29 16:13
|
||||
*/
|
||||
public interface ApiMercSplitService {
|
||||
|
||||
/**
|
||||
* 商户分账配置操作
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
Result<Object> splitOperat(SplitReq req);
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package cn.pluss.platform.api.impl;
|
||||
|
||||
import cn.pluss.platform.api.*;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.MerchantOrderMapper;
|
||||
import cn.pluss.platform.mercSplitSetting.MerchantSplitSettingService;
|
||||
import cn.pluss.platform.merchant.MerchantBaseInfoService;
|
||||
import cn.pluss.platform.merchantChannelStatus.MerchantChannelStatusService;
|
||||
import cn.pluss.platform.merchantOrder.BaseMercSplitService;
|
||||
import cn.pluss.platform.merchantOrderSplit.MerchantOrderSplitDetailService;
|
||||
import cn.pluss.platform.merchantOrderSplit.MerchantOrderSplitRefundService;
|
||||
import cn.pluss.platform.merchantOrderSplit.MerchantOrderSplitService;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import cn.pluss.platform.vo.SplitOrderVo;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* 分账业务处理Service实现类
|
||||
* @author crystal
|
||||
* @date 2022/6/29 16:14
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ApiMercSplitServiceImpl implements ApiMercSplitService {
|
||||
|
||||
@Resource
|
||||
private MerchantChannelStatusService channelStatusService;
|
||||
|
||||
@Resource
|
||||
private MerchantBaseInfoService merchantBaseInfoService;
|
||||
|
||||
@Resource
|
||||
private MerchantSplitSettingService merchantSplitSettingService;
|
||||
|
||||
@Resource
|
||||
private MerchantOrderSplitService merchantOrderSplitService;
|
||||
|
||||
@Resource
|
||||
private MerchantOrderSplitDetailService merchantOrderSplitDetailService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired, @Qualifier("ysMercSplitService")})
|
||||
private BaseMercSplitService ysMercSplitService;
|
||||
|
||||
@Resource
|
||||
private MerchantOrderSplitRefundService merchantOrderSplitRefundService;
|
||||
|
||||
@Resource
|
||||
private MerchantOrderMapper merchantOrderMapper;
|
||||
|
||||
@Override
|
||||
public Result<Object> splitOperat(SplitReq req) {
|
||||
log.info("【订单分账接口】请求参数:{}", JSON.toJSONString(req));
|
||||
SplitReq.Method method = req.checkParams();
|
||||
Object obj = split(req,method);
|
||||
return ResultGenerator.genSuccessResult("操作成功",obj);
|
||||
}
|
||||
/**
|
||||
* 分账
|
||||
* @param req
|
||||
*/
|
||||
private Object split(SplitReq req,SplitReq.Method method) {
|
||||
int size = req.getDivList() == null ? 16 : req.getDivList().size();
|
||||
MerchantBaseInfo merchant = merchantBaseInfoService.getMerchantBaseInfoByMerchantCode(req.getMerchantCode());
|
||||
MsgException.checkNull(merchant,"收款方商户号有误!");
|
||||
merchant.chekSign(req);
|
||||
MerchantChannelStatus channel = channelStatusService.getByMerchantCode(req.getMerchantCode(), 4);
|
||||
MsgException.checkNull(channel,"商户入网数据异常!");
|
||||
MsgException.check(!channel.isPayment(),"商户状态不可用!");
|
||||
List<MercSubSplitAccount> divList = req.getDivList();
|
||||
switch (method){
|
||||
case ORDER_ACCEPT:
|
||||
MerchantOrder mOrder = merchantOrderMapper.getByMercOrderNo(req.getMercOrderNo());
|
||||
MsgException.checkNull(mOrder,"原商户订单号有误!");
|
||||
MsgException.check(!"1".equals(mOrder.getStatus()),"当前订单状态不支持!");
|
||||
MerchantOrderSplit byMercOrderNo = merchantOrderSplitService.getByMercOrderNo(req.getMercOrderNo());
|
||||
if(byMercOrderNo != null && byMercOrderNo.getDivStatus() != -1){
|
||||
MsgException.throwException("原订单已登记过分账,请勿重复发起分账");
|
||||
}
|
||||
MerchantOrderSplit sOrder = new MerchantOrderSplit(mOrder,channel,req.getDivisionMode(),req.getNotifyUrl());
|
||||
ArrayList<MerchantOrderSplitDetail> details = new ArrayList<>(16);
|
||||
checkDivListParams(req,divList,channel,merchant,sOrder.getOrderAmt(),null,details,sOrder);
|
||||
Boolean resFlag = ysMercSplitService.split(sOrder, details,channel);
|
||||
MsgException.check(!resFlag,sOrder.getRemark());
|
||||
merchantOrderSplitService.save(sOrder);
|
||||
merchantOrderSplitDetailService.saveBatch(details);
|
||||
SplitOrderVo result = merchantOrderSplitService.resultChannelParam(sOrder,details);
|
||||
return result;
|
||||
case MERC_ACCEPT:
|
||||
List<MerchantSplitSetting> list = new ArrayList<>(size);
|
||||
checkDivListParams(req,divList,channel,merchant,BigDecimal.ZERO,list,null,null);
|
||||
List<MerchantSplitSetting> oldList = merchantSplitSettingService.listChieMerchantCode(req.getMerchantCode());
|
||||
if(!oldList.isEmpty()){
|
||||
merchantSplitSettingService.removeList(oldList);
|
||||
}
|
||||
merchantSplitSettingService.saveBatch(list);
|
||||
MerchantBaseInfo update = new MerchantBaseInfo();
|
||||
update.setId(merchant.getId());
|
||||
update.setSplitFlag(MerchantBaseInfo.SPLIT_FLAG_YES);
|
||||
merchantBaseInfoService.updateById(update);
|
||||
break;
|
||||
case MERC_REFUND:
|
||||
MerchantOrderSplit orderSplit = merchantOrderSplitService.getByMercOrderNo(req.getMercOrderNo());
|
||||
MsgException.checkNull(orderSplit,"原商户订单号有误!");
|
||||
MsgException.check(orderSplit.getStatus() == 0,"原订单未支付,无法发起退款");
|
||||
BigDecimal orderAmt = orderSplit.getOrderAmt();
|
||||
boolean flag = orderAmt.compareTo(orderSplit.getRefundAmt().add(new BigDecimal(req.getRefundAmt()))) < 0;
|
||||
MsgException.check(flag,"超出可退款的最大金额");
|
||||
List<MerchantOrderSplitDetail> detailList = merchantOrderSplitDetailService.listByOrderNumber(orderSplit.getOrderNumber());
|
||||
MsgException.check(detailList.isEmpty(),"分账详情异常,发起退款失败");
|
||||
orderSplit.setDetailList(detailList);
|
||||
List<SplitRefund> refundList = req.getRefundList();
|
||||
BigDecimal countRefundAmt = BigDecimal.ZERO;
|
||||
for (SplitRefund refund:refundList) {
|
||||
MsgException.checkBlank(refund.getMerchantCode(),"退款信息商户号不能为空");
|
||||
MerchantChannelStatus divChannel = channelStatusService.getByMerchantCode(refund.getMerchantCode(), 4);
|
||||
MsgException.checkNull(divChannel,"退款商户信息商户号有误");
|
||||
MsgException.checkNull(refund.getRefundAmt(),"退款明细中的退款金额不能为空");
|
||||
MerchantOrderSplitDetail detail = merchantOrderSplitDetailService.getByOrderNumberAndMerchantCode(orderSplit.getOrderNumber(),refund.getMerchantCode());
|
||||
MsgException.check(new BigDecimal(refund.getRefundAmt()).compareTo(detail.getFinalAmt()) > 0,"退款明细的退款超出分账商户的实际分账金额");
|
||||
refund.setMerchantId(divChannel.getMerchantId());
|
||||
countRefundAmt = countRefundAmt.add(new BigDecimal(refund.getRefundAmt()));
|
||||
}
|
||||
BigDecimal tRefundAmt = new BigDecimal(req.getRefundAmt());
|
||||
if(tRefundAmt.compareTo(countRefundAmt) != 0){
|
||||
MsgException.throwException("退款明细中的退款总额必须等于退款金额");
|
||||
}
|
||||
MerchantOrderSplitRefund refund = new MerchantOrderSplitRefund(orderSplit,req);
|
||||
// ysMercSplitService.withdraw(orderSplit,channel);
|
||||
|
||||
boolean resp = ysMercSplitService.generalRefund(refund);
|
||||
MsgException.check(!resp,refund.getRemark());
|
||||
merchantOrderSplitRefundService.save(refund);
|
||||
return refund;
|
||||
case SPLIT_QUERY:
|
||||
MerchantOrderSplit order = merchantOrderSplitService.getByMercOrderNo(req.getMercOrderNo());
|
||||
MsgException.checkNull(order,"原商户订单号有误!");
|
||||
List<MerchantOrderSplitDetail> splitDetailList = merchantOrderSplitDetailService.listByOrderNumber(order.getOrderNumber());
|
||||
List<MerchantOrderSplitDetail> dList = ysMercSplitService.splitQuery(order, splitDetailList);
|
||||
if(dList != null){
|
||||
merchantOrderSplitDetailService.updateBatchById(splitDetailList);
|
||||
merchantOrderSplitService.updateById(order);
|
||||
}
|
||||
return merchantOrderSplitService.resultChannelParam(order,splitDetailList);
|
||||
case REFUND_QUERY:
|
||||
MerchantOrderSplit qOrder = merchantOrderSplitService.getByMercOrderNo(req.getMercOrderNo());
|
||||
MsgException.checkNull(qOrder,"原商户订单号有误!");
|
||||
MerchantOrderSplitRefund qRefund = merchantOrderSplitRefundService.getByMercRefunNo(req.getMercRefundNo());
|
||||
MsgException.checkNull(qRefund,"原商户退款单号有误!");
|
||||
List<MerchantOrderSplitDetail> srList = merchantOrderSplitDetailService.listByOrderNumber(req.getMercOrderNo());
|
||||
MsgException.check(srList.isEmpty(),"订单分账详情数据异常!");
|
||||
List<MerchantOrderSplitDetail> rList = ysMercSplitService.refundQuery(qRefund,srList);
|
||||
merchantOrderSplitRefundService.updateById(qRefund);
|
||||
merchantOrderSplitDetailService.updateBatchById(rList);
|
||||
return rList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void checkDivListParams(SplitReq req,List<MercSubSplitAccount> divList,MerchantChannelStatus channel,
|
||||
MerchantBaseInfo merchant,
|
||||
BigDecimal orderAmt,
|
||||
List<MerchantSplitSetting> settingList,
|
||||
List<MerchantOrderSplitDetail> detailList,
|
||||
MerchantOrderSplit orderSplit) {
|
||||
BigDecimal ratioCount = BigDecimal.ZERO;
|
||||
BigDecimal amtCount = BigDecimal.ZERO;
|
||||
for (MercSubSplitAccount account:divList) {
|
||||
MerchantBaseInfo subMerchant = merchantBaseInfoService.getMerchantBaseInfoByMerchantCode(account.getMerchantCode());
|
||||
MsgException.checkNull(subMerchant,"分账方商户编号"+account.getMerchantCode()+"有误!");
|
||||
MerchantChannelStatus subChannel = channelStatusService.getByMerchantCode(subMerchant.getMerchantCode(), 4);
|
||||
if(!channel.getSrcMerchantNo().equals(subChannel.getSrcMerchantNo())){
|
||||
MsgException.throwException("商户进件主体不一致!");
|
||||
}
|
||||
MsgException.checkNull(subChannel,"分账商户入网数据异常!");
|
||||
MsgException.check(!subChannel.isPayment(),"分账方商户状态不可用!");
|
||||
if(SplitReq.DivisionMode.SCALE.getValue().equals(req.getDivisionMode())){
|
||||
if(account.getDivRatio() == null){
|
||||
MsgException.throwException("当分账类型为比例时,分账divRatio参数不能为空!");
|
||||
}
|
||||
boolean divRatioFlag = new BigDecimal(account.getDivRatio()).compareTo(BigDecimal.ZERO) <= 0 || new BigDecimal(account.getDivRatio()).compareTo(BigDecimal.ONE) >= 0;
|
||||
MsgException.check(divRatioFlag,"分账比例应该介于0-1之间");
|
||||
ratioCount = ratioCount.add(new BigDecimal(account.getDivRatio()));
|
||||
}
|
||||
if(SplitReq.DivisionMode.AMT.getValue().equals(req.getDivisionMode())){
|
||||
if(account.getDivAmount() == null){
|
||||
MsgException.throwException("当分账类型为金额时,分账divAmount参数不能为空!");
|
||||
}
|
||||
MsgException.check(!StringUtil.isNumber(account.getDivAmount()),"分账金额数据格式不正确。单位元");
|
||||
amtCount = amtCount.add(new BigDecimal(account.getDivAmount()));
|
||||
}
|
||||
if(settingList != null){
|
||||
MerchantSplitSetting setting = new MerchantSplitSetting();
|
||||
setting.setChieMerchantCode(merchant.getMerchantCode());
|
||||
setting.setChieMerchantId(channel.getMerchantId());
|
||||
setting.setIsDivistion(MerchantSplitSetting.DEFAULT_IS_DIVISTION);
|
||||
setting.setDivisionMode(req.getDivisionMode());
|
||||
setting.setDiviMerchantCode(subMerchant.getMerchantCode());
|
||||
setting.setDiviMerchantId(subChannel.getMerchantId());
|
||||
if(StringUtil.isNotEmpty(account.getDivRatio())){
|
||||
setting.setDivRatio(new BigDecimal(account.getDivRatio()));
|
||||
}
|
||||
if(StringUtil.isNotEmpty(account.getDivAmount())){
|
||||
setting.setDivAmt(new BigDecimal(account.getDivAmount()));
|
||||
}
|
||||
if(StringUtil.isNotEmpty(account.getIsChargeFee())){
|
||||
setting.setIsChargeFee(account.getIsChargeFee());
|
||||
}else{
|
||||
setting.setIsChargeFee(MerchantSplitSetting.DEFAULT_IS_CHARGEFEE);
|
||||
}
|
||||
setting.setNotifyUrl(req.getNotifyUrl());
|
||||
settingList.add(setting);
|
||||
}
|
||||
if(detailList != null){
|
||||
MerchantOrderSplitDetail detail = new MerchantOrderSplitDetail(account,subMerchant,subChannel,orderSplit);
|
||||
detailList.add(detail);
|
||||
}
|
||||
}
|
||||
if(SplitReq.DivisionMode.SCALE.getValue().equals(req.getDivisionMode())){
|
||||
MsgException.check(ratioCount.compareTo(BigDecimal.ONE) != 0,"所有分账比例之和必须为1");
|
||||
}
|
||||
if(SplitReq.DivisionMode.AMT.getValue().equals(req.getDivisionMode())){
|
||||
MsgException.check(amtCount.compareTo(orderAmt) != 0,"所有分账金额之后应该和订单金额一致");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.pluss.platform.app;
|
||||
|
||||
import cn.pluss.platform.api.PageInfo;
|
||||
import cn.pluss.platform.entity.MakeMoney;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* app余额界面
|
||||
* @author Djh
|
||||
*/
|
||||
public interface AccountBalanceService {
|
||||
|
||||
PageInfo<MakeMoney> queryBills(Page<MakeMoney> pageInfo);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package cn.pluss.platform.app;
|
||||
|
||||
public interface HomePageService {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.pluss.platform.app;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* app主页面接口服务实现类
|
||||
* @author Djh
|
||||
*/
|
||||
public interface MainPageService {
|
||||
|
||||
/**
|
||||
* app主页
|
||||
* @param userId 用户id
|
||||
* @return 数据
|
||||
*/
|
||||
Map<String, Object> getHomeData(String userId);
|
||||
|
||||
/**
|
||||
* 推广数据, 包含今日收款笔数,新增商户数(当日), 推广总收益(推广者/超级服务商), 本月交易额(超级服务商下的业务员)
|
||||
* @param userId 用户id
|
||||
* @return 推广数据
|
||||
*/
|
||||
Map<String, Object> getSpreadData(String userId);
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package cn.pluss.platform.app.impl;
|
||||
|
||||
import cn.pluss.platform.api.PageInfo;
|
||||
import cn.pluss.platform.app.AccountBalanceService;
|
||||
import cn.pluss.platform.channel.MakeMoneyService;
|
||||
import cn.pluss.platform.entity.MakeMoney;
|
||||
import cn.pluss.platform.entity.MerchantChannelStatus;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.MerchantOrderMapper;
|
||||
import cn.pluss.platform.merchantChannelStatus.MerchantChannelStatusService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.util.PageUtils;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.apache.commons.lang3.time.FastDateFormat;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AccountBalanceServiceImpl implements AccountBalanceService {
|
||||
|
||||
private final MerchantOrderMapper merchantOrderMapper;
|
||||
private final MakeMoneyService sxfMakeMoneyService;
|
||||
|
||||
private final UserAppService userAppService;
|
||||
private final MerchantChannelStatusService merchantChannelStatusService;
|
||||
|
||||
@Override
|
||||
public PageInfo<MakeMoney> queryBills(Page<MakeMoney> pageInfo) {
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
if (StringUtils.isEmpty(userApp.getMerchantCode())) {
|
||||
throw new MsgException("请先进行商户认证");
|
||||
}
|
||||
|
||||
QueryWrapper<MerchantChannelStatus> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("userId", userApp.getMerchantCode());
|
||||
MerchantChannelStatus merchantChannelStatus = merchantChannelStatusService.getOne(queryWrapper);
|
||||
if (!(merchantChannelStatus.getStatus().equals("3") || merchantChannelStatus.getStatus().equals("4"))) {
|
||||
throw new MsgException("请先进行商户认证");
|
||||
}
|
||||
|
||||
QueryWrapper<MakeMoney> qw2 = new QueryWrapper<>();
|
||||
qw2.eq("merchantId", merchantChannelStatus.getMerchantId());
|
||||
qw2.orderByDesc("createTime");
|
||||
Page<MakeMoney> page = sxfMakeMoneyService.page(pageInfo, qw2);
|
||||
for (MakeMoney l : page.getRecords()) {
|
||||
l.setRealAmount(StringUtil.bigDecimal(l.getRealAmount() * 0.01));
|
||||
l.setSuspendAmount(StringUtil.bigDecimal(l.getSuspendAmount() * 0.01));
|
||||
l.setPlanAmount(StringUtil.bigDecimal(l.getPlanAmount() * 0.01));
|
||||
}
|
||||
|
||||
if (page.getRecords().size() == 0) {
|
||||
return PageUtils.page(page);
|
||||
}
|
||||
String start = page.getRecords().get(page.getRecords().size() - 1).getCreateTime();
|
||||
String end = page.getRecords().get(0).getCreateTime();
|
||||
|
||||
try {
|
||||
FastDateFormat dateFormat = FastDateFormat.getInstance("yyyy-MM-dd", Locale.CHINA);
|
||||
Date startTime = dateFormat.parse(start);
|
||||
startTime = DateUtils.addDays(startTime, -1);
|
||||
Date endTime = dateFormat.parse(end);
|
||||
setDailyCount(startTime, endTime, userApp.getMerchantCode(), page.getRecords());
|
||||
} catch (Exception e) {
|
||||
return PageUtils.page(page);
|
||||
}
|
||||
return PageUtils.page(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询每日的总流水,并放入结果集中
|
||||
*
|
||||
* @param start 开始时间
|
||||
* @param end 截止时间
|
||||
* @param merchantCode 店铺code
|
||||
* @param targetList 结算信息
|
||||
*/
|
||||
private void setDailyCount(Date start, Date end, String merchantCode, List<MakeMoney> targetList) {
|
||||
List<Map<String, Object>> dailyCountList = merchantOrderMapper.queryDailyCount(merchantCode, start, end);
|
||||
|
||||
for (MakeMoney makeMoney : targetList) {
|
||||
for (Map<String, Object> dailyCount : dailyCountList) {
|
||||
java.lang.String billDate = makeMoney.getCreateTime().substring(0, 10);
|
||||
String dailyDate;
|
||||
if (dailyCount.get("date") instanceof byte[]) {
|
||||
dailyDate = new String((byte[]) dailyCount.get("date"));
|
||||
} else {
|
||||
dailyDate = dailyCount.get("date").toString();
|
||||
}
|
||||
|
||||
if (billDate.equals(dailyDate)) {
|
||||
makeMoney.setConsumeFeeSum(BigDecimal.valueOf((double) dailyCount.get("consumeFeeSum")));
|
||||
dailyCountList.remove(dailyCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package cn.pluss.platform.app.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.jiguang.common.utils.StringUtils;
|
||||
import cn.pluss.platform.app.MainPageService;
|
||||
import cn.pluss.platform.entity.MerchantOrderStatistics;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.merchantOrder.MerchantOrderService;
|
||||
import cn.pluss.platform.merchantOrder.MerchantOrderStatisticsService;
|
||||
import cn.pluss.platform.merchantProfit.MerchantProfitService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.util.DateUtils;
|
||||
import cn.pluss.platform.vo.MerchantOrderStatisticsVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 业务员主页数据查询实现类
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service("agentStaffMainPageService")
|
||||
public class AgentStaffMainPageServiceImpl implements MainPageService {
|
||||
|
||||
private final UserAppService userAppService;
|
||||
|
||||
private final MerchantProfitService merchantProfitService;
|
||||
|
||||
@Autowired @Lazy
|
||||
private MerchantOrderService moService;
|
||||
|
||||
@Autowired @Lazy
|
||||
private UserAppService uaService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSpreadData(String userId) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
throw new MsgException("无用户Id!");
|
||||
}
|
||||
|
||||
// 获取当前的用户信息
|
||||
UserApp queryUserApp = new UserApp();
|
||||
queryUserApp.setUserId(Long.parseLong(userId));
|
||||
List<UserApp> queryUserAppList2 = userAppService.queryUserAppList(queryUserApp);
|
||||
if (queryUserAppList2 == null || queryUserAppList2.size() == 0) {
|
||||
throw new MsgException("无用户信息!");
|
||||
} else {
|
||||
queryUserApp = queryUserAppList2.get(0);
|
||||
}
|
||||
|
||||
Double promoteConsumeFee;
|
||||
Integer totalOrderCount;
|
||||
|
||||
//分润
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
queryMap.put("userId", queryUserApp.getParentId());
|
||||
queryMap.put("agentStaffId", userId);
|
||||
queryMap.put("startTime", DateUtils.getBeginMonth(0));
|
||||
queryMap.put("endTime", DateUtils.getBeginMonth(1));
|
||||
queryMap.put("status", 1);
|
||||
// 本月交易额
|
||||
promoteConsumeFee = merchantProfitService.queryMerchantProfitSumConsumeFee(queryMap);
|
||||
if (promoteConsumeFee == null) {
|
||||
promoteConsumeFee = 0d;
|
||||
}
|
||||
|
||||
//今日收款笔数
|
||||
queryMap.put("recordDate", DateUtils.getDayBegin());
|
||||
queryMap.put("retype", "1");
|
||||
totalOrderCount = merchantProfitService.queryMerchantProfitPageCount(queryMap);
|
||||
|
||||
//今日新增商户数
|
||||
QueryWrapper<UserApp> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("agentStaffId", queryUserApp.getUserId());
|
||||
queryWrapper.eq("parentId", queryUserApp.getParentId());
|
||||
|
||||
queryWrapper.in("merchantAuditStatus", 3, 4);
|
||||
Integer newMerchantCount = userAppService.getUserAppWithChannelStatus(queryWrapper);
|
||||
resultMap.put("promoteFee", promoteConsumeFee + "");
|
||||
resultMap.put("totalOrderCount", totalOrderCount + "");
|
||||
resultMap.put("newMerchantCount", newMerchantCount + "");
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getHomeData(String userId) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.pluss.platform.app.impl;
|
||||
|
||||
import cn.pluss.platform.app.HomePageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class HomePageServiceImpl implements HomePageService {
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package cn.pluss.platform.app.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.pluss.platform.app.MainPageService;
|
||||
import cn.pluss.platform.entity.MerchantOrderStatistics;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.merchantOrder.MerchantOrderStatisticsService;
|
||||
import cn.pluss.platform.merchantProfit.MerchantProfitService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.util.DateUtils;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import cn.pluss.platform.vo.MerchantOrderStatisticsVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 推广者的主页面信息查询实现类
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service("promoterMainPageService")
|
||||
public class PromoterMainPageServiceImpl implements MainPageService {
|
||||
|
||||
private final UserAppService userAppService;
|
||||
|
||||
private final MerchantProfitService merchantProfitService;
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private MerchantOrderStatisticsService mosService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSpreadData(String userId) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
if (StringUtil.isEmpty(userId)) {
|
||||
throw new MsgException("无用户Id!");
|
||||
}
|
||||
|
||||
// 获取当前的用户信息
|
||||
UserApp queryUserApp = new UserApp();
|
||||
queryUserApp.setUserId(Long.parseLong(userId));
|
||||
List<UserApp> queryUserAppList2 = userAppService.queryUserAppList(queryUserApp);
|
||||
if (queryUserAppList2 == null || queryUserAppList2.size() == 0) {
|
||||
throw new MsgException("无用户信息!");
|
||||
} else {
|
||||
queryUserApp = queryUserAppList2.get(0);
|
||||
}
|
||||
|
||||
Double promoteFee;
|
||||
Double todayProfit;
|
||||
Integer totalOrderCount;
|
||||
|
||||
//分润
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
queryMap.put("userId", userId);
|
||||
queryMap.put("status", 1);
|
||||
// 累计总分润
|
||||
promoteFee = merchantProfitService.queryMerchantProfitSumPrice(queryMap);
|
||||
if (promoteFee == null) {
|
||||
promoteFee = 0d;
|
||||
}
|
||||
|
||||
//今日收款笔数
|
||||
queryMap.put("recordDate", DateUtils.getDayBegin());
|
||||
queryMap.put("retype", "1");
|
||||
totalOrderCount = merchantProfitService.queryMerchantProfitPageCount(queryMap);
|
||||
todayProfit = merchantProfitService.queryMerchantProfitSumPrice(queryMap);
|
||||
|
||||
//今日新增商户数
|
||||
QueryWrapper<UserApp> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("parentId", queryUserApp.getUserId());
|
||||
queryWrapper.in("merchantAuditStatus", 3, 4);
|
||||
queryWrapper.between("createDt", DateUtils.getDayBegin(), DateUtils.getDayEnd());
|
||||
Integer newMerchantCount = userAppService.getUserAppWithChannelStatus(queryWrapper);
|
||||
resultMap.put("promoteFee", promoteFee + "");
|
||||
resultMap.put("totalOrderCount", totalOrderCount + "");
|
||||
resultMap.put("newMerchantCount", newMerchantCount + "");
|
||||
resultMap.put("todayProfit", todayProfit == null? "0.00": todayProfit + "");
|
||||
|
||||
String currentMonth = DateUtil.format(new Date(), "yyyy-MM");
|
||||
|
||||
MerchantOrderStatistics directTotalCurrentMonth = mosService.getDirectTotal(queryUserApp.getUserId() + "", currentMonth);
|
||||
MerchantOrderStatistics teamTotalCurrentMonth = mosService.getIndirectTotal(queryUserApp.getUserId() + "", currentMonth);
|
||||
|
||||
MerchantOrderStatisticsVO mosVO = new MerchantOrderStatisticsVO();
|
||||
mosVO.setMonthCount((directTotalCurrentMonth.getCount() + teamTotalCurrentMonth.getCount()) + "");
|
||||
mosVO.setDirectMonthTotalFee(directTotalCurrentMonth.getTotalFee());
|
||||
mosVO.setTeamMonthTotalFee(teamTotalCurrentMonth.getTotalFee());
|
||||
|
||||
MerchantOrderStatistics directTotal = mosService.getDirectTotal(queryUserApp.getUserId() + "", null);
|
||||
MerchantOrderStatistics teamTotal = mosService.getIndirectTotal(queryUserApp.getUserId() + "", null);
|
||||
mosVO.setCount(directTotal.getCount() + teamTotal.getCount());
|
||||
mosVO.setDirectTotalFee(directTotal.getTotalFee());
|
||||
mosVO.setTeamTotalFee(teamTotal.getTotalFee());
|
||||
|
||||
resultMap.put("merchStatistics", mosVO);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getHomeData(String userId) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.pluss.platform.appGuide;
|
||||
|
||||
import cn.pluss.platform.entity.AppGuide;
|
||||
import cn.pluss.platform.mapper.AppGuideMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* app引导页 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-06-03
|
||||
*/
|
||||
public interface AppGuideService extends IService<AppGuide> {
|
||||
|
||||
/**
|
||||
* 根据code获取内容
|
||||
* @param code 页面code
|
||||
* @return 数据
|
||||
*/
|
||||
default AppGuide getByCode(String code) {
|
||||
QueryWrapper<AppGuide> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("code", code);
|
||||
return getBaseMapper().selectOne(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.pluss.platform.appGuide.impl;
|
||||
|
||||
import cn.pluss.platform.appGuide.AppGuideService;
|
||||
import cn.pluss.platform.entity.AppGuide;
|
||||
import cn.pluss.platform.mapper.AppGuideMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* app引导页 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-06-03
|
||||
*/
|
||||
@Service
|
||||
public class AppGuideServiceImpl extends ServiceImpl<AppGuideMapper, AppGuide> implements AppGuideService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.pluss.platform.appMenuUserType;
|
||||
|
||||
import cn.pluss.platform.entity.AppMenuUserType;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface AppMenuUserTypeService extends IService<AppMenuUserType> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.pluss.platform.appMenuUserType.impl;
|
||||
|
||||
import cn.pluss.platform.appMenuUserType.AppMenuUserTypeService;
|
||||
import cn.pluss.platform.entity.AppMenuUserType;
|
||||
import cn.pluss.platform.mapper.AppMenuUserTypeMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AppMenuUserTypeServiceImpl extends ServiceImpl<AppMenuUserTypeMapper, AppMenuUserType> implements AppMenuUserTypeService {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.pluss.platform.appVersionInfo;
|
||||
|
||||
import cn.pluss.platform.entity.AppVersionInfo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface AppVersionInfoService extends IService<AppVersionInfo> {
|
||||
Page<AppVersionInfo> pageData(Page<AppVersionInfo> page, AppVersionInfo appVersionInfo);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.pluss.platform.appVersionInfo.impl;
|
||||
|
||||
import cn.pluss.platform.appVersionInfo.AppVersionInfoService;
|
||||
import cn.pluss.platform.entity.AppVersionInfo;
|
||||
import cn.pluss.platform.mapper.AppVersionInfoMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AppVersionInfoServiceImpl extends ServiceImpl<AppVersionInfoMapper, AppVersionInfo> implements AppVersionInfoService {
|
||||
@Override
|
||||
public Page<AppVersionInfo> pageData(Page<AppVersionInfo> page, AppVersionInfo appVersionInfo) {
|
||||
return baseMapper.pageData(page,appVersionInfo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.pluss.platform.appletInfo;
|
||||
|
||||
import cn.pluss.platform.entity.AppletInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 小程序配置信息 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author crystal
|
||||
* @since 2022-04-20
|
||||
*/
|
||||
public interface AppletInfoService extends IService<AppletInfo> {
|
||||
|
||||
/**
|
||||
* 根据appid 获取小程序配置信息
|
||||
* @param appid
|
||||
* @return
|
||||
*/
|
||||
AppletInfo getAppletInfoByAppId(String appid);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.pluss.platform.appletInfo.impl;
|
||||
|
||||
import cn.pluss.platform.appletInfo.AppletInfoService;
|
||||
import cn.pluss.platform.entity.AppletInfo;
|
||||
import cn.pluss.platform.mapper.AppletInfoMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 小程序配置信息 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author crystal
|
||||
* @since 2022-04-20
|
||||
*/
|
||||
@Service
|
||||
public class AppletInfoServiceImpl extends ServiceImpl<AppletInfoMapper, AppletInfo> implements AppletInfoService {
|
||||
|
||||
/**
|
||||
* 获取小程序配置信息
|
||||
* @param appid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AppletInfo getAppletInfoByAppId(String appid) {
|
||||
return baseMapper.getAppletInfoByAppId(appid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.pluss.platform.area;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.pluss.platform.entity.Area;
|
||||
import cn.pluss.platform.leshua.LeshuaArea;
|
||||
|
||||
public interface AreaService {
|
||||
|
||||
public LeshuaArea queryArea(Area area);
|
||||
|
||||
public List<LeshuaArea> queryAreaList(Area area);
|
||||
|
||||
public void saveArea(Area area);
|
||||
|
||||
public void updateArea(Area area);
|
||||
|
||||
public void deleteArea(Area area);
|
||||
|
||||
public List<LeshuaArea> queryAreaPage(Map map);
|
||||
|
||||
public Integer queryAreaPageCount(Map map);
|
||||
|
||||
public void saveAreaBatch(List<Area> areaList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package cn.pluss.platform.area.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import cn.pluss.platform.entity.Area;
|
||||
import cn.pluss.platform.leshua.LeshuaArea;
|
||||
import cn.pluss.platform.area.AreaService;
|
||||
import cn.pluss.platform.mapper.AreaMapper;
|
||||
|
||||
@Transactional
|
||||
@Service("areaService")
|
||||
public class AreaServiceImpl implements AreaService{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger( AreaServiceImpl.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private AreaMapper areaMapper;
|
||||
|
||||
@Override
|
||||
public LeshuaArea queryArea(Area area){
|
||||
return areaMapper.queryArea(area);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LeshuaArea> queryAreaList(Area area){
|
||||
return areaMapper.queryAreaList(area);
|
||||
}
|
||||
@Override
|
||||
public void saveArea(Area area){
|
||||
areaMapper.saveArea(area);
|
||||
}
|
||||
@Override
|
||||
public void updateArea(Area area){
|
||||
areaMapper.updateArea(area);
|
||||
}
|
||||
@Override
|
||||
public void deleteArea(Area area){
|
||||
areaMapper.deleteArea(area);
|
||||
}
|
||||
@Override
|
||||
public List<LeshuaArea> queryAreaPage(Map map){
|
||||
return areaMapper.queryAreaPage(map);
|
||||
}
|
||||
@Override
|
||||
public Integer queryAreaPageCount(Map map){
|
||||
return areaMapper.queryAreaPageCount(map);
|
||||
}
|
||||
@Override
|
||||
public void saveAreaBatch(List<Area> areaList) {
|
||||
areaMapper.saveAreaBatch(areaList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.pluss.platform.areaCity;
|
||||
|
||||
import cn.pluss.platform.api.Result;
|
||||
import cn.pluss.platform.entity.AreaCity;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: bzg
|
||||
* @time: 2021/7/16 10:59
|
||||
*
|
||||
* @deprecated 请使用 tb_pluss_region_code_ls 表中的数据
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AreaCityService {
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @return cn.pluss.platform.api.Result<org.json.JSONObject>
|
||||
* @date: 2021/7/16 9:57
|
||||
*/
|
||||
Result<JSONObject> getAreaCodeByName(JSONObject params);
|
||||
|
||||
/**
|
||||
* 递归查询所有省市区数据
|
||||
*
|
||||
* @return java.util.List<cn.pluss.platform.entity.AreaCity>
|
||||
* @date: 2022/2/25 10:31
|
||||
*/
|
||||
List<AreaCity> queryProvince();
|
||||
|
||||
/**
|
||||
* 查询所省份
|
||||
*
|
||||
* @date: 2022/2/25 10:32
|
||||
*/
|
||||
List<AreaCity> queryOnlyProvince();
|
||||
|
||||
/**
|
||||
* 查询下级区域信息
|
||||
*
|
||||
* @param areaCode:
|
||||
* @return java.util.List<cn.pluss.platform.entity.AreaCity>
|
||||
* @date: 2022/2/25 11:04
|
||||
*/
|
||||
List<AreaCity> queryParentCode(String areaCode);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package cn.pluss.platform.areaCity.impl;
|
||||
|
||||
import cn.pluss.platform.api.Result;
|
||||
import cn.pluss.platform.api.ResultGenerator;
|
||||
import cn.pluss.platform.areaCity.AreaCityService;
|
||||
import cn.pluss.platform.entity.AreaCity;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.AreaCityMapper;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @description:
|
||||
* @author: Administrator
|
||||
* @DATE: 2021/7/16 11:03
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AreaCityServiceImpl implements AreaCityService {
|
||||
|
||||
@Resource
|
||||
private AreaCityMapper areaCityMapper;
|
||||
|
||||
/**
|
||||
* String provinceName, String cityName, String areaName,String type
|
||||
* @date: 2021/7/23 15:03
|
||||
* @return cn.pluss.platform.api.Result<com.alibaba.fastjson.JSONObject>
|
||||
*/
|
||||
@Override
|
||||
public Result<JSONObject> getAreaCodeByName(JSONObject params) {
|
||||
MsgException.checkBlank(params.getString("provinceName"),"缺失参数provinceName");
|
||||
MsgException.checkBlank(params.getString("cityName"),"缺失参数cityName");
|
||||
String type = StringUtil.isEmpty(params.getString("type")) ? "1" : params.getString("type");
|
||||
Map<String, String> areaCodeMap = areaCityMapper.getAreaCodeByName(params.getString("provinceName"),
|
||||
params.getString("cityName"), params.getString("areaName"),type);
|
||||
if(areaCodeMap != null){
|
||||
JSONObject result = new JSONObject(3);
|
||||
result.putAll(areaCodeMap);
|
||||
return ResultGenerator.genSuccessResult("获取成功",result);
|
||||
}
|
||||
return ResultGenerator.genSuccessResult("获取成功",null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查询所有省市区数据
|
||||
* @date: 2022/2/25 10:33
|
||||
* @return java.util.List<cn.pluss.platform.entity.AreaCity>
|
||||
*/
|
||||
@Override
|
||||
public List<AreaCity> queryProvince() {
|
||||
return areaCityMapper.queryProvince();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所省份
|
||||
* @date: 2022/2/25 10:33
|
||||
* @return java.util.List<cn.pluss.platform.entity.AreaCity>
|
||||
*/
|
||||
@Override
|
||||
public List<AreaCity> queryOnlyProvince() {
|
||||
return areaCityMapper.queryOnlyProvince();
|
||||
}
|
||||
|
||||
/**
|
||||
* queryParentCode
|
||||
* @date: 2022/2/25 11:04
|
||||
* @param areaCode:
|
||||
* @return java.util.List<cn.pluss.platform.entity.AreaCity>
|
||||
*/
|
||||
@Override
|
||||
public List<AreaCity> queryParentCode(String areaCode) {
|
||||
return areaCityMapper.queryParentCode(areaCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.pluss.platform.baidu;
|
||||
|
||||
/**
|
||||
* @author DJH
|
||||
*/
|
||||
public interface BaiduFaceDetectService {
|
||||
|
||||
/**
|
||||
*
|
||||
* 人脸识别获取accessToken
|
||||
*
|
||||
* @author Administrator
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
String getAuth();
|
||||
|
||||
String apiGetAuth();
|
||||
|
||||
/**
|
||||
* 目标图片与源图片做图片对比
|
||||
* @param src 源图片,这里指进件身份证图片,base64
|
||||
* @param dist 目标图片, 这里指待对比的图片,base64
|
||||
*/
|
||||
void checkFaceMatch(String src, String dist);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dist base64图片
|
||||
*/
|
||||
void apiCheckFaceMatch(String dist);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.pluss.platform.baidu;
|
||||
|
||||
/**
|
||||
* @author yuchen
|
||||
*
|
||||
* @Description
|
||||
*/
|
||||
public interface BaiduOCRService {
|
||||
|
||||
/**
|
||||
*
|
||||
* OCR识别获取accessToken
|
||||
*
|
||||
* @author Administrator
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
String getAuth();
|
||||
|
||||
/**
|
||||
*
|
||||
* getInfo:(获取身份证或银行卡信息). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param url
|
||||
* @param accessToken
|
||||
* @param param
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
String getInfo(String url,String accessToken,String param);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
package cn.pluss.platform.baidu.impl;
|
||||
|
||||
import cn.pluss.platform.IdCardService;
|
||||
import cn.pluss.platform.baidu.BaiduFaceDetectService;
|
||||
import cn.pluss.platform.entity.IdCard;
|
||||
import cn.pluss.platform.entity.OperationRecord;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.entity.UserInfo;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.merchant.AccountService;
|
||||
import cn.pluss.platform.operationRecord.OperationRecordService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.userInfo.UserInfoService;
|
||||
import cn.pluss.platform.util.DateUtils;
|
||||
import cn.pluss.platform.util.FileUtil;
|
||||
import cn.pluss.platform.util.HttpUtil;
|
||||
import cn.pluss.platform.util.ParametersUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.java_websocket.util.Base64;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author DJH
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BaiduFaceDetectServiceImpl implements BaiduFaceDetectService {
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
private UserAppService uaService;
|
||||
|
||||
@Autowired
|
||||
private UserInfoService uiService;
|
||||
|
||||
@Autowired
|
||||
private IdCardService idCardService;
|
||||
|
||||
@Autowired
|
||||
private OperationRecordService opService;
|
||||
|
||||
@Override
|
||||
public String getAuth() {
|
||||
String baiduApiKey = ParametersUtil.baiduAK2;
|
||||
String baiduSecretKey = ParametersUtil.baiduSK2;
|
||||
String authHost = "https://aip.baidubce.com/oauth/2.0/token?";
|
||||
String getAccessTokenUrl = authHost + "grant_type=client_credentials" + "&client_id=" + baiduApiKey + "&client_secret=" + baiduSecretKey;
|
||||
return HttpUtil.baiduGET(getAccessTokenUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiGetAuth() {
|
||||
final UserApp tokenUa = uaService.queryUserAppByToken();
|
||||
faceCertCheck(tokenUa);
|
||||
|
||||
return getAuth();
|
||||
}
|
||||
|
||||
/**
|
||||
* 人脸识别请求前的校验
|
||||
* @return
|
||||
*/
|
||||
private void faceCertCheck(UserApp tokenUa) {
|
||||
LambdaQueryWrapper<OperationRecord> qWrapper2 = Wrappers.lambdaQuery();
|
||||
qWrapper2.eq(OperationRecord::getUserId, tokenUa.getUserId());
|
||||
qWrapper2.in(OperationRecord::getDictValue, "APP_FACE_CERT");
|
||||
qWrapper2.between(OperationRecord::getCreateTime, DateUtils.getDayBegin(), DateUtils.getDayEnd());
|
||||
final int faceCertCount = opService.count(qWrapper2);
|
||||
if (faceCertCount >= 3) {
|
||||
throw new MsgException("人脸认证次数超限,请明天再试");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<OperationRecord> qWrapper = Wrappers.lambdaQuery();
|
||||
qWrapper.eq(OperationRecord::getUserId, tokenUa.getUserId());
|
||||
qWrapper.in(OperationRecord::getDictValue, "BAIDU_ACCESS_TOKEN");
|
||||
qWrapper.between(OperationRecord::getCreateTime, DateUtils.getDayBegin(), DateUtils.getDayEnd());
|
||||
final int reqAccessTokenCount = opService.count(qWrapper);
|
||||
if (reqAccessTokenCount >= 10) {
|
||||
throw new MsgException("人脸认证次数超限,请明天再试");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkFaceMatch(String src, String dist) {
|
||||
String url = "https://aip.baidubce.com/rest/2.0/face/v4/mingjing/match";
|
||||
final String accessToken = getAuth();
|
||||
url += "?access_token=" + accessToken;
|
||||
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("image", src);
|
||||
param.put("image_type", "URL");
|
||||
param.put("face_type", "CERT");
|
||||
param.put("register_image", dist);
|
||||
param.put("register_face_type", "LIVE");
|
||||
param.put("register_liveness_control", "NONE");
|
||||
|
||||
|
||||
final JSONObject result = restTemplate.postForObject(url, param, JSONObject.class);
|
||||
if (result == null) {
|
||||
throw new MsgException("人脸对比不通过");
|
||||
}
|
||||
|
||||
log.info("result : " + result);
|
||||
|
||||
final JSONObject result1 = result.getJSONObject("result");
|
||||
if (result1 == null) {
|
||||
throw new MsgException("人脸对比不通过");
|
||||
}
|
||||
|
||||
final BigDecimal score = result1.getBigDecimal("score");
|
||||
|
||||
if (score.compareTo(BigDecimal.valueOf(80L)) <= 0) {
|
||||
throw new MsgException("人脸对比不通过");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apiCheckFaceMatch(String dist) {
|
||||
final UserApp tokenUa = uaService.queryUserAppByToken();
|
||||
faceCertCheck(tokenUa);
|
||||
final IdCard certIdCard = idCardService.getCertIdCard(tokenUa.getUserId());
|
||||
final String imgPositive = certIdCard.getImgPositive();
|
||||
|
||||
byte[] bytes = DatatypeConverter.parseBase64Binary(dist);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
Thumbnails.of(bais).size(1920, 1080).toOutputStream(baos);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
dist = DatatypeConverter.printBase64Binary(baos.toByteArray());
|
||||
|
||||
checkFaceMatch(imgPositive, dist);
|
||||
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(tokenUa.getUserId());
|
||||
userInfo.setFaceCert("1");
|
||||
userInfo.setFaceCompare("1");
|
||||
|
||||
uiService.updateById(userInfo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.pluss.platform.baidu.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import cn.pluss.platform.baidu.BaiduOCRService;
|
||||
import cn.pluss.platform.util.HttpUtil;
|
||||
import cn.pluss.platform.util.ParametersUtil;
|
||||
|
||||
/**
|
||||
* @author yuchen
|
||||
* @Description
|
||||
*/
|
||||
@Transactional
|
||||
@Service("baiduOCRService")
|
||||
public class BaiduOCRServiceImpl implements BaiduOCRService {
|
||||
//https://ai.baidu.com/docs#/OCR-API-Idcard/top 此文档地址
|
||||
|
||||
@Override
|
||||
public String getInfo(String url, String accessToken, String params) {
|
||||
try {
|
||||
String baiduPOST = HttpUtil.baiduPOST(url, accessToken, params);
|
||||
return baiduPOST;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuth() {
|
||||
String baiduApiKey = ParametersUtil.baiduAK;
|
||||
String baiduSecretKey = ParametersUtil.baiduSK;
|
||||
String authHost = "https://aip.baidubce.com/oauth/2.0/token?";
|
||||
//固定值 //2. 官网获取的 API Key // 3. 官网获取的 Secret Key
|
||||
String getAccessTokenUrl = authHost + "grant_type=client_credentials" + "&client_id=" + baiduApiKey + "&client_secret=" + baiduSecretKey;
|
||||
return HttpUtil.baiduGET(getAccessTokenUrl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.pluss.platform.bankUnionpayCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import cn.pluss.platform.leshua.BankNameVO;
|
||||
|
||||
public interface BankUnionpayCodeService {
|
||||
|
||||
/**
|
||||
*
|
||||
* getBranchName:(根据省市 银行名称 查询支行). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param areaCode
|
||||
* @param provinceCode
|
||||
* @param bankName
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
List<BankNameVO> getBranchName(@Param(value = "areaCode") String areaCode, @Param(value = "provinceCode") String provinceCode, @Param(value = "bankName") String bankName, @Param(value = "brankName") String brankName);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.pluss.platform.bankUnionpayCode.impl;
|
||||
|
||||
import cn.pluss.platform.bankUnionpayCode.BankUnionpayCodeService;
|
||||
import cn.pluss.platform.leshua.BankNameVO;
|
||||
import cn.pluss.platform.mapper.BankCodeSxfMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
@Service("bankUnionpayCodeService")
|
||||
public class BankUnionpayCodeServiceImpl implements BankUnionpayCodeService {
|
||||
|
||||
private final BankCodeSxfMapper bankCodeSxfMapper;
|
||||
|
||||
@Override
|
||||
public List<BankNameVO> getBranchName(String areaCode, String provinceCode, String bankName, String branchName) {
|
||||
return bankCodeSxfMapper.getBranchName(areaCode, provinceCode, bankName, branchName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.pluss.platform.banner;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import cn.pluss.platform.entity.Banner;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface BannerService extends IService<Banner> {
|
||||
|
||||
Banner queryBanner(Banner banner);
|
||||
|
||||
List<Banner> queryBannerList(Banner banner);
|
||||
|
||||
void saveBanner(Banner banner);
|
||||
|
||||
void updateBanner(Banner banner);
|
||||
|
||||
void deleteBanner(Banner banner);
|
||||
|
||||
List<Banner> queryBannerPage(Map map);
|
||||
|
||||
Integer queryBannerPageCount(Map map);
|
||||
|
||||
void saveBannerBatch(List<Banner> bannerList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.pluss.platform.banner.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.pluss.platform.entity.Banner;
|
||||
import cn.pluss.platform.banner.BannerService;
|
||||
import cn.pluss.platform.mapper.BannerMapper;
|
||||
|
||||
@Transactional
|
||||
@Service("bannerService")
|
||||
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService {
|
||||
|
||||
@Override
|
||||
public Banner queryBanner(Banner banner){
|
||||
return baseMapper.queryBanner(banner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Banner> queryBannerList(Banner banner){
|
||||
return baseMapper.queryBannerList(banner);
|
||||
}
|
||||
@Override
|
||||
public void saveBanner(Banner banner){
|
||||
baseMapper.saveBanner(banner);
|
||||
}
|
||||
@Override
|
||||
public void updateBanner(Banner banner){
|
||||
baseMapper.updateBanner(banner);
|
||||
}
|
||||
@Override
|
||||
public void deleteBanner(Banner banner){
|
||||
baseMapper.deleteBanner(banner);
|
||||
}
|
||||
@Override
|
||||
public List<Banner> queryBannerPage(Map map){
|
||||
return baseMapper.queryBannerPage(map);
|
||||
}
|
||||
@Override
|
||||
public Integer queryBannerPageCount(Map map){
|
||||
return baseMapper.queryBannerPageCount(map);
|
||||
}
|
||||
@Override
|
||||
public void saveBannerBatch(List<Banner> bannerList) {
|
||||
baseMapper.saveBannerBatch(bannerList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.pluss.platform.bestNewActivity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import cn.pluss.platform.entity.BestNewActivity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface BestNewActivityService extends IService<BestNewActivity> {
|
||||
|
||||
BestNewActivity queryBestNewActivity(BestNewActivity bestNewActivity);
|
||||
|
||||
List<BestNewActivity> queryBestNewActivityList(BestNewActivity bestNewActivity);
|
||||
|
||||
void saveBestNewActivity(BestNewActivity bestNewActivity);
|
||||
|
||||
void updateBestNewActivity(BestNewActivity bestNewActivity);
|
||||
|
||||
void deleteBestNewActivity(BestNewActivity bestNewActivity);
|
||||
|
||||
List<BestNewActivity> queryBestNewActivityPage(Map map);
|
||||
|
||||
Integer queryBestNewActivityPageCount(Map map);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package cn.pluss.platform.bestNewActivity.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.pluss.platform.entity.BestNewActivity;
|
||||
import cn.pluss.platform.bestNewActivity.BestNewActivityService;
|
||||
import cn.pluss.platform.mapper.BestNewActivityMapper;
|
||||
|
||||
@Transactional
|
||||
@Service("bestNewActivityService")
|
||||
public class BestNewActivityServiceImpl extends ServiceImpl<BestNewActivityMapper, BestNewActivity> implements BestNewActivityService {
|
||||
|
||||
@Autowired
|
||||
private UserAppService userAppService;
|
||||
|
||||
@Autowired
|
||||
private BestNewActivityMapper bestNewActivityMapper;
|
||||
|
||||
@Override
|
||||
public BestNewActivity queryBestNewActivity(BestNewActivity bestNewActivity) {
|
||||
return bestNewActivityMapper.queryBestNewActivity(bestNewActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BestNewActivity> queryBestNewActivityList(BestNewActivity bestNewActivity) {
|
||||
return bestNewActivityMapper.queryBestNewActivityList(bestNewActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveBestNewActivity(BestNewActivity bestNewActivity) {
|
||||
bestNewActivityMapper.saveBestNewActivity(bestNewActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBestNewActivity(BestNewActivity bestNewActivity) {
|
||||
bestNewActivityMapper.updateBestNewActivity(bestNewActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBestNewActivity(BestNewActivity bestNewActivity) {
|
||||
bestNewActivityMapper.deleteBestNewActivity(bestNewActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BestNewActivity> queryBestNewActivityPage(Map map) {
|
||||
try {
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
map.put("userId", userApp.getUserId());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return bestNewActivityMapper.queryBestNewActivityPage(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryBestNewActivityPageCount(Map map) {
|
||||
return bestNewActivityMapper.queryBestNewActivityPageCount(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package cn.pluss.platform.bill;
|
||||
|
||||
import cn.pluss.platform.entity.BillSendRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-05-10
|
||||
*/
|
||||
public interface BillSendRecordService extends IService<BillSendRecord> {
|
||||
|
||||
|
||||
/**
|
||||
* 请求生成账单并发送邮件
|
||||
* @param entity
|
||||
*/
|
||||
void reqBill(BillSendRecord entity);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 生成账单excel
|
||||
* @param entity
|
||||
* @return 账单workBook对象
|
||||
*/
|
||||
XSSFWorkbook createBill(BillSendRecord entity);
|
||||
|
||||
/**
|
||||
* 将账单发送到指定邮箱
|
||||
* @param entity
|
||||
* @param workbook
|
||||
*/
|
||||
void sendBill(BillSendRecord entity, XSSFWorkbook workbook);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cn.pluss.platform.bill;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.pluss.platform.entity.MemberTransStatistics;
|
||||
import cn.pluss.platform.mapper.MemberTransStatisticsMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员消费日记录 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-03-17
|
||||
*/
|
||||
public interface MemberTransStatisticsService extends IService<MemberTransStatistics> {
|
||||
|
||||
/**
|
||||
* 保存指定日期的账单总计统计
|
||||
* @param day 日期格式为 yyyy-MM-dd
|
||||
*/
|
||||
default void saveDaysBill(String day) {
|
||||
((MemberTransStatisticsMapper) getBaseMapper()).insertDuringBill(day, day);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当日/当周/当月的账单
|
||||
* @param condition
|
||||
* @return
|
||||
*/
|
||||
default MemberTransStatistics currentDuringBill(MemberTransStatistics condition) {
|
||||
Date currentDate = new Date();
|
||||
Date startDate;
|
||||
Date endDate;
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
switch (condition.getType()) {
|
||||
case 2:
|
||||
// 当周周一
|
||||
startDate = DateUtil.beginOfWeek(currentDate).toJdkDate();
|
||||
endDate = DateUtil.endOfWeek(currentDate);
|
||||
break;
|
||||
case 3:
|
||||
// 当月一号
|
||||
startDate = DateUtil.beginOfMonth(currentDate).toJdkDate();
|
||||
endDate = DateUtil.endOfMonth(currentDate);
|
||||
break;
|
||||
case 4:
|
||||
// 当年一号
|
||||
startDate = DateUtil.beginOfYear(currentDate).toJdkDate();
|
||||
endDate = DateUtil.endOfYear(currentDate);
|
||||
break;
|
||||
default:
|
||||
// 当天开始时间
|
||||
startDate = DateUtil.beginOfDay(currentDate).toJdkDate();
|
||||
endDate = startDate;
|
||||
break;
|
||||
}
|
||||
|
||||
MemberTransStatistics result = ((MemberTransStatisticsMapper) getBaseMapper()).selectOneDuringBill(sdf.format(startDate), sdf.format(endDate), condition.getUserId().toString());
|
||||
|
||||
if (result == null) {
|
||||
result = new MemberTransStatistics();
|
||||
}
|
||||
|
||||
if (result.getConsumeAmount() == null) {
|
||||
result.setConsumeAmount(BigDecimal.ZERO);
|
||||
} else {
|
||||
result.setConsumeAmount(result.getConsumeAmount().setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
if (result.getGiveAmount() == null) {
|
||||
result.setGiveAmount(BigDecimal.ZERO);
|
||||
} else {
|
||||
result.setGiveAmount(result.getGiveAmount().setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
if (result.getRechargeAmount() == null) {
|
||||
result.setRechargeAmount(BigDecimal.ZERO);
|
||||
} else {
|
||||
result.setRechargeAmount(result.getRechargeAmount().setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.pluss.platform.bill;
|
||||
|
||||
import cn.pluss.platform.entity.MerchantBillStatistics;
|
||||
import cn.pluss.platform.mapper.MerchantBillStatisticsMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 按日统计商户的账单 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-03-11
|
||||
*/
|
||||
public interface MerchantBillStatisticsService extends IService<MerchantBillStatistics> {
|
||||
|
||||
/**
|
||||
* 保存指定日期的账单总计统计
|
||||
* @param day 日期格式为 yyyy-MM-dd
|
||||
*/
|
||||
default void saveDaysBill(String day) {
|
||||
((MerchantBillStatisticsMapper) getBaseMapper()).insertDuringBill(day, day);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package cn.pluss.platform.bill.impl;
|
||||
|
||||
import cn.pluss.platform.bill.BillSendRecordService;
|
||||
import cn.pluss.platform.entity.BillSendRecord;
|
||||
import cn.pluss.platform.entity.MerchantBaseInfo;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.export.BillStatisticsService;
|
||||
import cn.pluss.platform.mapper.BillSendRecordMapper;
|
||||
import cn.pluss.platform.merchant.MerchantBaseInfoService;
|
||||
import cn.pluss.platform.service.EmailService;
|
||||
import cn.pluss.platform.task.BillStatisticsHandler;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.Setter;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-05-10
|
||||
*/
|
||||
@Service
|
||||
public class BillSendRecordServiceImpl extends ServiceImpl<BillSendRecordMapper, BillSendRecord> implements BillSendRecordService {
|
||||
|
||||
|
||||
/**
|
||||
* 电子邮箱格式校验正则
|
||||
*/
|
||||
public final static String EMAIL_REG = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
|
||||
|
||||
/**
|
||||
* 最大目标邮箱个数
|
||||
*/
|
||||
public final static int MAX_EMAIL_TARGET = 3;
|
||||
|
||||
/**
|
||||
* 一天最大生成报表次数
|
||||
*/
|
||||
public final static int MAX_EMAIL_DAY_COUNT = 3;
|
||||
|
||||
/**
|
||||
* 报表生成最低间隔时间
|
||||
*/
|
||||
public final static Long MIN_DURING = 60 * 1000L;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private BillStatisticsService billStatisticsService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private EmailService emailService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private UserAppService userAppService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private MerchantBaseInfoService merchantBaseInfoService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired, @Lazy})
|
||||
private BillStatisticsHandler billStatisticsHandler;
|
||||
|
||||
@Override
|
||||
public void reqBill(BillSendRecord entity) {
|
||||
if (entity.getUserId() == null) {
|
||||
throw new MsgException("缺少用户id");
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date currentDate = new Date();
|
||||
String currentDateStr = sdf.format(currentDate);
|
||||
|
||||
if (entity.getStartTime() == null) {
|
||||
throw new MsgException("缺少开始时间");
|
||||
}
|
||||
|
||||
String startDate = sdf.format(entity.getEndTime());
|
||||
|
||||
if (startDate.compareTo(currentDateStr) > 0) {
|
||||
throw new MsgException("非法的开始时间");
|
||||
}
|
||||
|
||||
// 将起始时间设置为一天的开始
|
||||
Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(entity.getStartTime());
|
||||
instance.set(Calendar.HOUR_OF_DAY, 0);
|
||||
instance.set(Calendar.MINUTE, 0);
|
||||
instance.set(Calendar.SECOND, 0);
|
||||
instance.set(Calendar.MILLISECOND, 0);
|
||||
entity.setStartTime(instance.getTime());
|
||||
|
||||
if (entity.getEndTime() == null) {
|
||||
throw new MsgException("缺少截止时间");
|
||||
}
|
||||
|
||||
|
||||
String endDate = sdf.format(entity.getEndTime());
|
||||
|
||||
if (endDate.compareTo(currentDateStr) >= 0) {
|
||||
entity.setEndTime(currentDate);
|
||||
}
|
||||
|
||||
if (entity.getEmail() == null) {
|
||||
throw new MsgException("缺少目标邮箱");
|
||||
}
|
||||
|
||||
Pattern p = Pattern.compile(EMAIL_REG);
|
||||
|
||||
String[] split = entity.getEmail().split(",");
|
||||
if (split.length > MAX_EMAIL_TARGET) {
|
||||
throw new MsgException("最多指定三个邮箱");
|
||||
}
|
||||
|
||||
for (String email: split) {
|
||||
Matcher matcher = p.matcher(email);
|
||||
if (!matcher.matches()) {
|
||||
throw new MsgException("存在不合法邮箱,请检查邮箱格式是否正确");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
if (!entity.getUserId().equals(userApp.getUserId())) {
|
||||
throw new MsgException("拒绝访问");
|
||||
}
|
||||
|
||||
String date = sdf.format(currentDate);
|
||||
|
||||
// 报表次数限制
|
||||
QueryWrapper<BillSendRecord> queryWrapper1 = new QueryWrapper<>();
|
||||
queryWrapper1.eq("userId", entity.getUserId());
|
||||
queryWrapper1.likeRight("createTime", date);
|
||||
Integer todayCount = baseMapper.selectCount(queryWrapper1);
|
||||
if (todayCount >= MAX_EMAIL_DAY_COUNT) {
|
||||
throw new MsgException("账单报表一天只能生成3次");
|
||||
}
|
||||
|
||||
// 报表时间间隔
|
||||
QueryWrapper<BillSendRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("userId", entity.getUserId());
|
||||
queryWrapper.orderByDesc("createTime");
|
||||
queryWrapper.last("limit 1");
|
||||
BillSendRecord one = getOne(queryWrapper);
|
||||
if (one != null) {
|
||||
long during = System.currentTimeMillis() - one.getCreateTime().getTime();
|
||||
if (during < MIN_DURING) {
|
||||
throw new MsgException("操作过于频繁, 请于一分钟后再操作");
|
||||
}
|
||||
}
|
||||
|
||||
entity.setStatus("0");
|
||||
save(entity);
|
||||
|
||||
billStatisticsHandler.execute(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook createBill(BillSendRecord entity) {
|
||||
UserApp userApp = new UserApp();
|
||||
userApp.setUserId(entity.getUserId());
|
||||
userApp = userAppService.queryUserApp(userApp);
|
||||
|
||||
String merchantCode = userApp.getMerchantCode();
|
||||
Date startTime = entity.getStartTime();
|
||||
Date endTime= entity.getEndTime();
|
||||
|
||||
XSSFWorkbook workBook = billStatisticsService.createBillStatisticsSheet(null, merchantCode, startTime, endTime);
|
||||
workBook = billStatisticsService.createBillListSheet(workBook, merchantCode, startTime, endTime);
|
||||
workBook = billStatisticsService.createMemberBillStatisticsSheet(workBook, merchantCode, startTime, endTime);
|
||||
workBook = billStatisticsService.createMemberBillListSheet(workBook, merchantCode, startTime, endTime);
|
||||
workBook = billStatisticsService.createStaffBillStatisticsSheet(workBook, merchantCode, startTime, endTime);
|
||||
|
||||
return workBook;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBill(BillSendRecord entity, XSSFWorkbook workbook) {
|
||||
MerchantBaseInfo merchantBaseInfo = new MerchantBaseInfo();
|
||||
merchantBaseInfo.setUserId(entity.getUserId() + "");
|
||||
merchantBaseInfo = merchantBaseInfoService.queryMerchantBaseInfo(merchantBaseInfo);
|
||||
|
||||
String[] tos = entity.getEmail().split(",");
|
||||
// 抄送邮件设置为自己
|
||||
String[] ccs = new String[]{"caiwu@shouyinbei.com"};
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
String title = merchantBaseInfo.getAlias() + "_" + sdf.format(entity.getStartTime()) + "~" + sdf.format(entity.getEndTime()) + "账单报表";
|
||||
String content = "账单明细,请查看附件";
|
||||
|
||||
emailService.sendEmail(tos, ccs, title, content, workbook, title + ".xlsx");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.pluss.platform.bill.impl;
|
||||
|
||||
import cn.pluss.platform.bill.MemberTransStatisticsService;
|
||||
import cn.pluss.platform.entity.MemberTransStatistics;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.MemberTransStatisticsMapper;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员消费日记录 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-03-17
|
||||
*/
|
||||
@Service
|
||||
public class MemberTransStatisticsServiceImpl extends ServiceImpl<MemberTransStatisticsMapper, MemberTransStatistics> implements MemberTransStatisticsService {
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private UserAppService userAppService;
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public <E extends IPage<MemberTransStatistics>> E page(E page, Wrapper<MemberTransStatistics> queryWrapper) {
|
||||
MemberTransStatistics entity = queryWrapper.getEntity();
|
||||
if (entity.getUserId() == null) {
|
||||
throw new MsgException("缺少userId");
|
||||
}
|
||||
|
||||
UserApp uaBoss = userAppService.getBossUserApp(entity.getUserId(), request.getHeader("merchantCode"));
|
||||
if (uaBoss != null) {
|
||||
entity.setUserId(uaBoss.getUserId().intValue());
|
||||
}
|
||||
|
||||
return super.page(page, queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.pluss.platform.bill.impl;
|
||||
|
||||
import cn.pluss.platform.entity.MerchantBillStatistics;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.MerchantBillStatisticsMapper;
|
||||
import cn.pluss.platform.bill.MerchantBillStatisticsService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 按日统计商户的账单 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-03-11
|
||||
*/
|
||||
@Service
|
||||
public class MerchantBillStatisticsServiceImpl extends ServiceImpl<MerchantBillStatisticsMapper, MerchantBillStatistics> implements MerchantBillStatisticsService {
|
||||
|
||||
@Setter(onMethod_ = {@Autowired,@Lazy})
|
||||
private UserAppService userAppService;
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public <E extends IPage<MerchantBillStatistics>> E page(E page, Wrapper<MerchantBillStatistics> queryWrapper) {
|
||||
MerchantBillStatistics entity = queryWrapper.getEntity();
|
||||
if (entity.getUserId() == null) {
|
||||
throw new MsgException("缺少userId");
|
||||
}
|
||||
|
||||
UserApp uaBoss = userAppService.getBossUserApp(entity.getUserId(), request.getHeader("merchantCode"));
|
||||
if (uaBoss != null) {
|
||||
entity.setUserId(uaBoss.getUserId().intValue());
|
||||
}
|
||||
|
||||
return super.page(page, queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.pluss.platform.business;
|
||||
|
||||
import cn.pluss.platform.vo.BusinessInfoVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* 业务员相关查询接口
|
||||
*/
|
||||
public interface BusinessInfoService {
|
||||
|
||||
Page<BusinessInfoVo> pageData(Page<BusinessInfoVo> page, BusinessInfoVo businessInfoVo);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.pluss.platform.business.impl;
|
||||
|
||||
import cn.pluss.platform.business.BusinessInfoService;
|
||||
import cn.pluss.platform.mapper.BusinessInfoMapper;
|
||||
import cn.pluss.platform.vo.BusinessInfoVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BusinessInfoServiceImpl implements BusinessInfoService {
|
||||
|
||||
@Autowired
|
||||
private BusinessInfoMapper businessInfoMapper;
|
||||
|
||||
@Override
|
||||
public Page<BusinessInfoVo> pageData(Page<BusinessInfoVo> page, BusinessInfoVo businessInfoVo) {
|
||||
return businessInfoMapper.selectPage(page, businessInfoVo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.pluss.platform.cacheInfo;
|
||||
|
||||
import cn.pluss.platform.entity.CacheInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 缓存信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author bzg
|
||||
* @since 2021-09-24
|
||||
*/
|
||||
public interface CacheInfoService extends IService<CacheInfo> {
|
||||
|
||||
/**
|
||||
* @description:根据keyCode获取信息
|
||||
* @date: 2021/9/24 17:19
|
||||
* @param keyCode:
|
||||
* @return cn.pluss.platform.entity.CacheInfo
|
||||
*/
|
||||
CacheInfo getCacheInfoByKeyCode(String keyCode);
|
||||
|
||||
/**
|
||||
* 获取生活圈缓存的数据
|
||||
* @date: 2021/12/7 17:01
|
||||
* @param keyCode:
|
||||
* @return java.lang.String
|
||||
*/
|
||||
String getShqCacheInfoByKeyCode(String keyCode);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.pluss.platform.cacheInfo.impl;
|
||||
|
||||
import cn.pluss.platform.cacheInfo.CacheInfoService;
|
||||
import cn.pluss.platform.entity.CacheInfo;
|
||||
import cn.pluss.platform.mapper.CacheInfoMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 缓存信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author bzg
|
||||
* @since 2021-09-24
|
||||
*/
|
||||
@Service
|
||||
public class CacheInfoServiceImpl extends ServiceImpl<CacheInfoMapper, CacheInfo> implements CacheInfoService {
|
||||
|
||||
@Override
|
||||
public CacheInfo getCacheInfoByKeyCode(String keyCode) {
|
||||
return baseMapper.selectOne(new QueryWrapper<CacheInfo>().eq("keyCode",keyCode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShqCacheInfoByKeyCode(String keyCode) {
|
||||
return baseMapper.getShqCacheInfoByKeyCode(keyCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package cn.pluss.platform.cash;
|
||||
|
||||
import cn.pluss.platform.entity.Cash;
|
||||
import cn.pluss.platform.mapper.CashMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CashService extends IService<Cash> {
|
||||
|
||||
/**
|
||||
* api后台专用方法, 保存提现申请信息
|
||||
*
|
||||
* @param cash
|
||||
*/
|
||||
void apiSaveCash(Cash cash);
|
||||
|
||||
/**
|
||||
* api后台专用方法, 保存提现申请信息, v2
|
||||
*
|
||||
* @param cash
|
||||
*/
|
||||
void apiSaveCashV2(Cash cash);
|
||||
|
||||
/**
|
||||
* 提现详情
|
||||
* @param cash 提现信息
|
||||
* @return 提现详情
|
||||
*/
|
||||
Cash cashDetail(Cash cash);
|
||||
|
||||
/**
|
||||
* api后台专用方法, 保存提现申请信息, v2
|
||||
*
|
||||
* @param cash
|
||||
*/
|
||||
void apiSaveCashV3(Cash cash);
|
||||
|
||||
Cash queryCash(Cash cash);
|
||||
|
||||
void updateCash(Cash cash);
|
||||
|
||||
void deleteUserIdCash(Cash cash);
|
||||
|
||||
List<Cash> queryCashPage(Map<String, Object> map);
|
||||
|
||||
Integer queryCashPageCount(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 已经成功提现的金额/申请提现中的金额(粉丝分润)
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
Double sumFansSuccessCash(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 已经成功提现(粉丝分润)
|
||||
*
|
||||
* @param map 参数
|
||||
* @return
|
||||
*/
|
||||
Double sumFansAlreadyCash(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 已经成功提现的金额/申请提现中的金额(推广分润)
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Double sumMerchantSuccessCash(@Param(value = "userId") Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* 通过并打款
|
||||
*
|
||||
* @param cash 提现记录相关信息
|
||||
*/
|
||||
void passAndRemit(Cash cash);
|
||||
|
||||
/**
|
||||
* 批量通过并打款
|
||||
*
|
||||
* @param idList id列表
|
||||
*/
|
||||
void batchPassAndRemit(List<String> idList);
|
||||
|
||||
/**
|
||||
* @param params:
|
||||
* @return java.util.Map<java.lang.String, java.lang.Object>
|
||||
* @description:统计提现信息记录
|
||||
* @date: 2021/10/15 16:38
|
||||
*/
|
||||
Map<String, Object> getCashCountData(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询有效的提现金额, 金额数量
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
default BigDecimal getSumValidCashAmtTotal(@Param("userId") String userId) {
|
||||
return ((CashMapper) getBaseMapper()).selectCashAmtTotal(userId, Cash.STATUS_SUCCESS, Cash.STATUS_CHECKING);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已经提现的金额总数
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
default BigDecimal getSumCashedAmtTotal(@Param("userId") String userId) {
|
||||
return ((CashMapper) getBaseMapper()).selectCashAmtTotal(userId, Cash.STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询审核中的提现金额
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
default BigDecimal getSumCheckingCashAmtTotal(@Param("userId") String userId) {
|
||||
return ((CashMapper) getBaseMapper()).selectCashAmtTotal(userId, Cash.STATUS_CHECKING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,579 @@
|
||||
package cn.pluss.platform.cash.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.pluss.platform.ali.AlipayService;
|
||||
import cn.pluss.platform.cash.CashService;
|
||||
import cn.pluss.platform.cashAccount.CashAccountService;
|
||||
import cn.pluss.platform.common.CommonRemarkService;
|
||||
import cn.pluss.platform.common.RiskBlacklistService;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.fans.FansService;
|
||||
import cn.pluss.platform.mapper.CashMapper;
|
||||
import cn.pluss.platform.mapper.FansMapper;
|
||||
import cn.pluss.platform.mapper.MerchantProfitMapper;
|
||||
import cn.pluss.platform.merchantProfit.MerchantProfitService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.userInfo.UserInfoService;
|
||||
import cn.pluss.platform.user.impl.GeneralPushUtil;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service("cashService")
|
||||
public class CashServiceImpl extends ServiceImpl<CashMapper, Cash> implements CashService {
|
||||
|
||||
@Setter(onMethod_ = {@Autowired, @Lazy})
|
||||
private CashService self;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired, @Lazy})
|
||||
private UserAppService userAppService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired, @Lazy})
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired, @Lazy})
|
||||
private CashAccountService cashAccountService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private CommonRemarkService remarkService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private AlipayService alipayService;
|
||||
|
||||
@Autowired @Lazy
|
||||
private MerchantProfitService mpService;
|
||||
|
||||
@Autowired
|
||||
private FansService fansService;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private GeneralPushUtil generalPushUtil;
|
||||
|
||||
@Autowired
|
||||
private RiskBlacklistService rbService;
|
||||
|
||||
@Resource
|
||||
private FansMapper fansMapper;
|
||||
|
||||
@Resource
|
||||
private MerchantProfitMapper mpMapper;
|
||||
|
||||
private void checkStatus(Integer userId) {
|
||||
RiskBlacklist condition = new RiskBlacklist();
|
||||
condition.setUserId(userId);
|
||||
RiskBlacklist entity = rbService.getOne(new QueryWrapper<>(condition));
|
||||
|
||||
if (entity != null) {
|
||||
throw new MsgException("该账户存在重大违规行为,暂不支持提现,请联系收银呗客服申诉");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPayPwd(Cash cash) {
|
||||
MsgException.checkNull(cash.getPayPassword(), "缺少支付密码");
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
cash.setUserId(userApp.getUserId());
|
||||
UserInfo userInfo = new UserInfo().setId(userApp.getUserId());
|
||||
userInfo = userInfoService.getOne(new QueryWrapper<>(userInfo));
|
||||
|
||||
String psdMd5 = SecureUtil.md5(cash.getPayPassword());
|
||||
MsgException.checkUnequals(psdMd5, userInfo.getPayPassword(), "支付密码错误");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apiSaveCash(Cash cash) {
|
||||
if(cash.getCashAmt().compareTo(BigDecimal.valueOf(Cash.MINIMUM_CASH)) < 0) {
|
||||
throw new MsgException("提现金额必须大于" + Cash.MINIMUM_CASH + "元");
|
||||
}
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
|
||||
Cash existData = new Cash();
|
||||
existData.setUserId(cash.getUserId());
|
||||
QueryWrapper<Cash> qWrapper = new QueryWrapper<>(existData);
|
||||
qWrapper.orderByDesc("createDt");
|
||||
qWrapper.last("limit 1");
|
||||
existData = getOne(qWrapper);
|
||||
|
||||
if (existData != null && DateUtil.isSameDay(new Date(), existData.getCreateDt())) {
|
||||
throw new MsgException("一天只能提现一次");
|
||||
}
|
||||
|
||||
cash.setCashNumber(StringUtil.getBillno());
|
||||
cash.setCreateDt(new Date());
|
||||
cash.setStatus(0);
|
||||
cash.setUserName(userApp.getUserName());
|
||||
cash.setMerchantName(userApp.getMerchantName());
|
||||
cash.setMerchantCode(userApp.getMerchantCode());
|
||||
|
||||
LambdaQueryWrapper<CashAccount> qWrapper2 = new LambdaQueryWrapper<CashAccount>()
|
||||
.eq(CashAccount::getUserId, cash.getUserId())
|
||||
.last("limit 1");
|
||||
CashAccount cashAccount = cashAccountService.getOne(qWrapper2);
|
||||
if (cashAccount != null) {
|
||||
cash.setAccountName(cashAccount.getAccountName());
|
||||
cash.setAccountNo(cashAccount.getAccountNo());
|
||||
} else {
|
||||
throw new MsgException("请先完善提现账户信息");
|
||||
}
|
||||
|
||||
if (StringUtil.isNotEmpty(userApp.getLogo())) {
|
||||
cash.setLogo(userApp.getLogo());
|
||||
}
|
||||
|
||||
save(cash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apiSaveCashV2(Cash cash) {
|
||||
Date limitDate = null;
|
||||
try {
|
||||
limitDate = DateUtils.parseDate("2022-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
||||
} catch (ParseException ignored) {
|
||||
}
|
||||
|
||||
if (limitDate != null && System.currentTimeMillis() > limitDate.getTime()) {
|
||||
throw new MsgException("提现功能维护中");
|
||||
}
|
||||
|
||||
checkPayPwd(cash);
|
||||
|
||||
apiSaveCash(cash);
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
|
||||
Cash existData = new Cash();
|
||||
existData.setUserId(cash.getUserId());
|
||||
QueryWrapper<Cash> qWrapper = new QueryWrapper<>(existData);
|
||||
qWrapper.orderByDesc("createDt");
|
||||
qWrapper.last("limit 1");
|
||||
existData = getOne(qWrapper);
|
||||
|
||||
if (existData != null && DateUtil.isSameDay(new Date(), existData.getCreateDt())) {
|
||||
throw new MsgException("一天只能提现一次");
|
||||
}
|
||||
|
||||
cash.setCashNumber(StringUtil.getBillno());
|
||||
cash.setCreateDt(new Date());
|
||||
cash.setStatus(0);
|
||||
cash.setUserName(userApp.getUserName());
|
||||
cash.setMerchantName(userApp.getMerchantName());
|
||||
cash.setMerchantCode(userApp.getMerchantCode());
|
||||
|
||||
LambdaQueryWrapper<CashAccount> qWrapper2 = new LambdaQueryWrapper<CashAccount>()
|
||||
.eq(CashAccount::getUserId, cash.getUserId())
|
||||
.last("limit 1");
|
||||
CashAccount cashAccount = cashAccountService.getOne(qWrapper2);
|
||||
if (cashAccount != null) {
|
||||
cash.setAccountName(cashAccount.getAccountName());
|
||||
cash.setAccountNo(cashAccount.getAccountNo());
|
||||
}
|
||||
|
||||
if (StringUtil.isNotEmpty(userApp.getLogo())) {
|
||||
cash.setLogo(userApp.getLogo());
|
||||
}
|
||||
|
||||
save(cash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cash cashDetail(Cash cash) {
|
||||
UserApp tokenUa = userAppService.queryUserAppByToken();
|
||||
cash.setUserId(tokenUa.getUserId());
|
||||
|
||||
checkStatus(tokenUa.getUserId().intValue());
|
||||
|
||||
if(cash.getCashAmt().compareTo(BigDecimal.valueOf(Cash.MINIMUM_CASH)) < 0) {
|
||||
throw new MsgException("提现金额必须大于" + Cash.MINIMUM_CASH + "元");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<Cash> qWrapper = Wrappers.lambdaQuery();
|
||||
qWrapper.eq(Cash::getUserId, cash.getUserId())
|
||||
.orderByDesc(Cash::getCreateDt)
|
||||
.last("limit 1");
|
||||
Cash existData = getOne(qWrapper);
|
||||
|
||||
if (existData != null && DateUtil.isSameDay(new Date(), existData.getCreateDt())) {
|
||||
throw new MsgException("一天只能提现一次");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<CashAccount> qWrapper2 = Wrappers.lambdaQuery();
|
||||
qWrapper2.eq(CashAccount::getUserId, cash.getUserId())
|
||||
.last("limit 1");
|
||||
CashAccount cashAccount = cashAccountService.getOne(qWrapper2);
|
||||
if (cashAccount != null) {
|
||||
cash.setAccountName(DesensitizedUtil.chineseName(cashAccount.getAccountName()));
|
||||
if (cashAccount.getAccountNo().contains("@")) {
|
||||
cash.setAccountNo(DesensitizedUtil.email(cashAccount.getAccountNo()));
|
||||
} else {
|
||||
cash.setAccountNo(DesensitizedUtil.mobilePhone(cashAccount.getAccountNo()));
|
||||
}
|
||||
} else {
|
||||
throw new MsgException("请先补充提现账户信息");
|
||||
}
|
||||
|
||||
// ======查询可提现金额
|
||||
// 查询商户所有分润
|
||||
BigDecimal totalProfit = mpService.getSumValidProfit(cash.getUserId() + "");
|
||||
if (totalProfit == null) {
|
||||
totalProfit = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(tokenUa.getMerchantCode())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("lastMerchantCode", tokenUa.getMerchantCode());
|
||||
// 查询可提现粉丝分润
|
||||
Double sum = fansService.queryFansSumShareMoney(map);
|
||||
if (sum != null) {
|
||||
BigDecimal fansProfit = BigDecimal.valueOf(sum);
|
||||
totalProfit = totalProfit.add(fansProfit);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询商户已提现总数
|
||||
BigDecimal totalCashAmt = getSumValidCashAmtTotal(cash.getUserId() + "");
|
||||
if (totalCashAmt == null) {
|
||||
totalCashAmt = BigDecimal.ZERO;
|
||||
}
|
||||
// 校验提现金额是否充足
|
||||
int flag = cash.getCashAmt().compareTo(totalProfit.subtract(totalCashAmt));
|
||||
if (flag > 0) {
|
||||
throw new MsgException("可提现金额不足!");
|
||||
}
|
||||
|
||||
cash.setRate(8);
|
||||
cash.setBaseServiceCharge(BigDecimal.valueOf(3));
|
||||
cash.setRatioCharge(cash.getCashAmt().multiply(BigDecimal.valueOf(0.08)).setScale(2, RoundingMode.HALF_EVEN));
|
||||
cash.setVirTotalCharge(cash.getBaseServiceCharge().add(cash.getRatioCharge()));
|
||||
cash.setVirRealCashAmt(cash.getCashAmt().subtract(cash.getVirTotalCharge()).setScale(2, RoundingMode.HALF_EVEN));
|
||||
return cash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apiSaveCashV3(Cash cash) {
|
||||
UserApp tokenUa = userAppService.queryUserAppByToken();
|
||||
cash.setUserId(tokenUa.getUserId());
|
||||
|
||||
checkStatus(tokenUa.getUserId().intValue());
|
||||
|
||||
if(cash.getCashAmt().compareTo(BigDecimal.valueOf(Cash.MINIMUM_CASH)) < 0) {
|
||||
throw new MsgException("提现金额必须大于" + Cash.MINIMUM_CASH + "元");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<Cash> qWrapper = Wrappers.lambdaQuery();
|
||||
qWrapper.eq(Cash::getUserId, cash.getUserId())
|
||||
.orderByDesc(Cash::getCreateDt)
|
||||
.last("limit 1");
|
||||
Cash existData = getOne(qWrapper);
|
||||
|
||||
if (existData != null && DateUtil.isSameDay(new Date(), existData.getCreateDt())) {
|
||||
throw new MsgException("一天只能提现一次");
|
||||
}
|
||||
|
||||
// ======查询可提现金额
|
||||
// 查询商户所有分润
|
||||
BigDecimal totalProfit = mpService.getSumValidProfit(cash.getUserId() + "");
|
||||
totalProfit = totalProfit == null? BigDecimal.ZERO: totalProfit;
|
||||
|
||||
if (!StringUtils.isEmpty(tokenUa.getMerchantCode())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("lastMerchantCode", tokenUa.getMerchantCode());
|
||||
// 查询可提现粉丝分润
|
||||
Double sum = fansService.queryFansSumShareMoney(map);
|
||||
if (sum != null) {
|
||||
BigDecimal fansProfit = BigDecimal.valueOf(sum);
|
||||
totalProfit = totalProfit.add(fansProfit);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询商户已提现总数
|
||||
BigDecimal totalCashAmt = getSumValidCashAmtTotal(cash.getUserId() + "");
|
||||
totalCashAmt = totalCashAmt == null? BigDecimal.ZERO: totalCashAmt;
|
||||
|
||||
// 校验提现金额是否充足
|
||||
int flag = cash.getCashAmt().compareTo(totalProfit.subtract(totalCashAmt));
|
||||
if (flag > 0) {
|
||||
throw new MsgException("可提现金额不足!");
|
||||
}
|
||||
|
||||
cash.setCashNumber(StringUtil.getBillno());
|
||||
cash.setCreateDt(new Date());
|
||||
cash.setStatus(Cash.STATUS_CHECKING);
|
||||
cash.setUserName(tokenUa.getUserName());
|
||||
cash.setMerchantName(tokenUa.getMerchantName());
|
||||
cash.setMerchantCode(tokenUa.getMerchantCode());
|
||||
cash.setRate(8);
|
||||
cash.setBaseServiceCharge(BigDecimal.valueOf(3));
|
||||
cash.setRatioCharge(cash.getCashAmt().multiply(BigDecimal.valueOf(0.08)));
|
||||
|
||||
LambdaQueryWrapper<CashAccount> qWrapper2 = Wrappers.lambdaQuery();
|
||||
qWrapper2.eq(CashAccount::getUserId, cash.getUserId())
|
||||
.last("limit 1");
|
||||
CashAccount cashAccount = cashAccountService.getOne(qWrapper2);
|
||||
log.info("申请提现的帐号信息:{}", JSONObject.toJSONString(cashAccount));
|
||||
if (cashAccount != null) {
|
||||
cash.setAccountName(cashAccount.getAccountName());
|
||||
cash.setAccountNo(cashAccount.getAccountNo());
|
||||
} else {
|
||||
throw new MsgException("请先补充提现账户信息");
|
||||
}
|
||||
|
||||
if (StringUtil.isNotEmpty(tokenUa.getLogo())) {
|
||||
cash.setLogo(tokenUa.getLogo());
|
||||
}
|
||||
|
||||
save(cash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cash queryCash(Cash cash) {
|
||||
return baseMapper.selectOne(new QueryWrapper<>(cash));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCash(Cash cash) {
|
||||
baseMapper.updateById(cash);
|
||||
}
|
||||
|
||||
public void updateUserIdCash(Cash cash) {
|
||||
UpdateWrapper<Cash> uWrapper = new UpdateWrapper<>();
|
||||
uWrapper.eq("userId", cash.getUserId());
|
||||
baseMapper.update(cash, uWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserIdCash(Cash cash) {
|
||||
QueryWrapper<Cash> qWrapper = new QueryWrapper<>();
|
||||
qWrapper.eq("userId", cash.getUserId());
|
||||
baseMapper.delete(qWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends IPage<Cash>> E page(E page, Wrapper<Cash> queryWrapper) {
|
||||
Cash cash = queryWrapper.getEntity();
|
||||
((QueryWrapper<Cash>) queryWrapper).eq(StringUtil.isNotEmpty(cash.getType()), "tpc.type", cash.getType());
|
||||
|
||||
((QueryWrapper<Cash>) queryWrapper).like(StringUtil.isNotEmpty(cash.getUserName()), "tpc.userName", cash.getUserName());
|
||||
|
||||
((QueryWrapper<Cash>) queryWrapper).eq(StringUtil.isNotEmpty(cash.getMerchantCode()), "tpc.merchantCode", cash.getMerchantCode());
|
||||
|
||||
((QueryWrapper<Cash>) queryWrapper).like(StringUtil.isNotEmpty(cash.getMerchantName()), "tpc.merchantName", cash.getMerchantName());
|
||||
|
||||
((QueryWrapper<Cash>) queryWrapper).eq(StringUtil.isNotEmpty(cash.getStatus()), "tpc.status", cash.getStatus());
|
||||
|
||||
((QueryWrapper<Cash>) queryWrapper).eq(StringUtil.isNotEmpty(cash.getPhone()), "ui.phone", cash.getPhone());
|
||||
|
||||
((QueryWrapper<Cash>) queryWrapper).eq(StringUtil.isNotEmpty(cash.getId()), "tpc.id", cash.getId());
|
||||
|
||||
((QueryWrapper<Cash>) queryWrapper).eq(StringUtil.isNotEmpty(cash.getUserId()), "tpc.userId", cash.getUserId());
|
||||
|
||||
((QueryWrapper<Cash>) queryWrapper).ge(StringUtil.isNotEmpty(cash.getBeginTime()), "tpc.createDt", cash.getBeginTime());
|
||||
|
||||
((QueryWrapper<Cash>) queryWrapper).le(StringUtil.isNotEmpty(cash.getEndTime()), "tpc.createDt", cash.getEndTime());
|
||||
|
||||
final E result = (E) baseMapper.queryCashPage2(page, queryWrapper);
|
||||
|
||||
List<Long> userIdList = new ArrayList<>();
|
||||
List<String> merchantCodeList = new ArrayList<>();
|
||||
for (Cash record : result.getRecords()) {
|
||||
userIdList.add(record.getUserId());
|
||||
merchantCodeList.add(record.getMerchantCode());
|
||||
}
|
||||
|
||||
final List<Fans> fansList = fansMapper.selectGroupData(merchantCodeList);
|
||||
final List<MerchantProfit> merchantProfitList = mpMapper.selectGroupMercProfit(userIdList);
|
||||
|
||||
for (Cash record : result.getRecords()) {
|
||||
final Iterator<Fans> fansIterator = fansList.iterator();
|
||||
|
||||
while (fansIterator.hasNext()) {
|
||||
final Fans next = fansIterator.next();
|
||||
if (next.getLastMerchantCode().equals(record.getMerchantCode())) {
|
||||
record.setTotalShareMoney(new BigDecimal(next.getShareMoney()));
|
||||
fansIterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<MerchantProfit> profitIterator = merchantProfitList.iterator();
|
||||
while (profitIterator.hasNext()) {
|
||||
final MerchantProfit next = profitIterator.next();
|
||||
if (next.getUserId().equals(record.getUserId())) {
|
||||
record.setTotalProfit(BigDecimal.valueOf(next.getPrice()));
|
||||
profitIterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cash> queryCashPage(Map<String, Object> map) {
|
||||
return baseMapper.queryCashPage(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryCashPageCount(Map<String, Object> map) {
|
||||
return baseMapper.queryCashPageCount(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double sumFansSuccessCash(Map<String, Object> map) {
|
||||
Double aDouble = baseMapper.sumFansSuccessCash(map);
|
||||
return aDouble == null ? new Double(0) : aDouble;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double sumFansAlreadyCash(Map<String, Object> map) {
|
||||
Double aDouble = baseMapper.sumFansAreadlyCash(map);
|
||||
return aDouble == null ? new Double(0) : aDouble;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double sumMerchantSuccessCash(Long userId) {
|
||||
Double aDouble = baseMapper.sumMerChantSuccessCash(userId);
|
||||
return aDouble == null ? new Double(0) : aDouble;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void passAndRemit(Cash cash) {
|
||||
String remark = cash.getRemark();
|
||||
cash = baseMapper.selectLockById(cash.getId());
|
||||
if (cash.getStatus() == 1) {
|
||||
throw new MsgException("当前打款记录已被处理");
|
||||
}
|
||||
|
||||
cash.setStatus(1);
|
||||
|
||||
// String token = request.getHeader("token");
|
||||
// cash.setUpdator(JwtUtils.get("userId", token).toString());
|
||||
cash.setUpdateDt(new Date());
|
||||
updateById(cash);
|
||||
|
||||
if (!StringUtils.isEmpty(remark)) {
|
||||
QueryWrapper<CommonRemark> qWrapper = new QueryWrapper<CommonRemark>()
|
||||
.eq("userId", cash.getUserId())
|
||||
.eq("code", "CASH");
|
||||
remarkService.remove(qWrapper);
|
||||
CommonRemark existData = new CommonRemark();
|
||||
existData.setUserId(cash.getUserId().intValue());
|
||||
existData.setCode("CASH");
|
||||
existData.setRemark(remark);
|
||||
remarkService.saveOrUpdate(existData);
|
||||
}
|
||||
|
||||
String accountName = cash.getAccountName();
|
||||
String accountNo = cash.getAccountNo();
|
||||
if (StringUtils.isEmpty(accountName)) {
|
||||
LambdaQueryWrapper<CashAccount> qWrapper2 = new LambdaQueryWrapper<CashAccount>()
|
||||
.eq(CashAccount::getUserId, cash.getUserId().intValue());
|
||||
CashAccount one = cashAccountService.getOne(qWrapper2);
|
||||
|
||||
if (one == null) {
|
||||
throw new MsgException("缺少打款账号");
|
||||
} else {
|
||||
accountName = one.getAccountName();
|
||||
accountNo = one.getAccountNo();
|
||||
|
||||
cash.setAccountNo(accountNo);
|
||||
cash.setAccountName(accountName);
|
||||
updateById(cash);
|
||||
}
|
||||
}
|
||||
|
||||
alipayService.remit(accountNo, accountName, cash.getVirRealCashAmt().toString());
|
||||
// 发送分润打款通知
|
||||
generalPushUtil.sendAllPlatByAlias(Collections.singletonList(cash.getUserId() + ""), "收银呗分润到账通知", "您的分润已结算至支付宝,快去查看哦!", "1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchPassAndRemit(List<String> idList) {
|
||||
// 获取要操作的提现记录
|
||||
LambdaQueryWrapper<Cash> qWrapper1 = new LambdaQueryWrapper<Cash>()
|
||||
.in(Cash::getId, idList);
|
||||
List<Cash> cashList = list(qWrapper1);
|
||||
|
||||
// 获取所有要操作的提现记录的提现账号信息
|
||||
List<String> noAccountUserIdList = new ArrayList<String>();
|
||||
for (Cash cash : cashList) {
|
||||
if (StringUtils.isEmpty(cash.getAccountName())) {
|
||||
noAccountUserIdList.add(cash.getUserId() + "");
|
||||
}
|
||||
}
|
||||
|
||||
if (!noAccountUserIdList.isEmpty()) {
|
||||
LambdaQueryWrapper<CashAccount> qWrapper2 = new LambdaQueryWrapper<CashAccount>()
|
||||
.in(CashAccount::getUserId, noAccountUserIdList);
|
||||
List<CashAccount> cashAccountList = cashAccountService.list(qWrapper2);
|
||||
|
||||
for (Cash cash : cashList) {
|
||||
if (cash.getAccountName() != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CashAccount cashAccount : cashAccountList) {
|
||||
if (cashAccount.getUserId().equals(cash.getUserId().intValue())) {
|
||||
cash.setAccountName(cashAccount.getAccountName());
|
||||
cash.setAccountNo(cashAccount.getAccountNo());
|
||||
updateById(cash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cashAccountList.size() != noAccountUserIdList.size()) {
|
||||
throw new MsgException("存在没有提供提现账户的记录");
|
||||
}
|
||||
}
|
||||
|
||||
for (Cash cash : cashList) {
|
||||
if (cash.getStatus() == 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
self.passAndRemit(cash);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description:统计提现信息记录
|
||||
* @date: 2021/10/15 16:39
|
||||
* @param params:
|
||||
* @return java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getCashCountData(Map<String, Object> params) {
|
||||
return baseMapper.getCashCountData(params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.pluss.platform.cashAccount;
|
||||
|
||||
import cn.pluss.platform.entity.CashAccount;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author bzg
|
||||
* @since 2021-07-23
|
||||
*/
|
||||
public interface CashAccountService extends IService<CashAccount> {
|
||||
|
||||
boolean apiSave(CashAccount entity);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.pluss.platform.cashAccount.impl;
|
||||
|
||||
import cn.pluss.platform.IdCardService;
|
||||
import cn.pluss.platform.cashAccount.CashAccountService;
|
||||
import cn.pluss.platform.entity.CashAccount;
|
||||
import cn.pluss.platform.entity.IdCard;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.CashAccountMapper;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author bzg
|
||||
* @since 2021-07-23
|
||||
*/
|
||||
@Service
|
||||
public class CashAccountServiceImpl extends ServiceImpl<CashAccountMapper, CashAccount> implements CashAccountService {
|
||||
|
||||
@Autowired @Lazy
|
||||
private UserAppService uaService;
|
||||
|
||||
@Autowired @Lazy
|
||||
private IdCardService idCardService;
|
||||
|
||||
@Override
|
||||
public boolean apiSave(CashAccount entity) {
|
||||
MsgException.checkNull(entity.getAccountName(), "缺少支付宝账户名");
|
||||
MsgException.checkNull(entity.getAccountNo(), "缺少支付号账号");
|
||||
|
||||
UserApp userApp = uaService.queryUserAppByToken();
|
||||
|
||||
IdCard certIdCard = idCardService.getCertIdCard(userApp.getUserId() + "");
|
||||
|
||||
MsgException.checkNull(certIdCard, "请先进行实名认证");
|
||||
|
||||
MsgException.checkUnequals(certIdCard.getCertName(), entity.getAccountName(), "支付宝账户名需与实名信息保持一致");
|
||||
|
||||
return save(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.entity.MakeMoney;
|
||||
import cn.pluss.platform.mapper.MakeMoneyMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
public abstract class BaseMakeMoneyService extends ServiceImpl<MakeMoneyMapper, MakeMoney> implements MakeMoneyService {
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.pluss.platform.converter.Converter;
|
||||
import cn.pluss.platform.entity.MerchantRateNew;
|
||||
import cn.pluss.platform.entity.MerchantRateNewRecord;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.entity.UserLevel;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.exception.RateNoChangeException;
|
||||
import cn.pluss.platform.mapper.MerchantRateMapper;
|
||||
import cn.pluss.platform.merchant.MerchantRateNewRecordService;
|
||||
import cn.pluss.platform.merchant.MerchantRateNewService;
|
||||
import cn.pluss.platform.user.UserLevelService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author djh
|
||||
*/
|
||||
@Data
|
||||
public abstract class BaseMchChannelRateNewService implements MchChannelRateNewService {
|
||||
|
||||
@Autowired
|
||||
protected MerchantRateNewService rateNewService;
|
||||
|
||||
@Resource
|
||||
protected MerchantRateMapper merchantRateMapper;
|
||||
|
||||
@Autowired
|
||||
protected UserLevelService ulService;
|
||||
|
||||
@Autowired
|
||||
protected MerchantRateNewRecordService rateNewRecordService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired, @Lazy})
|
||||
protected UserAppService userAppService;
|
||||
|
||||
@Override
|
||||
public void before(String userId, MerchantRateNew rate) {
|
||||
|
||||
if (userId == null) {
|
||||
throw new MsgException("用户id不能为空");
|
||||
}
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
if (userApp == null) {
|
||||
throw new MsgException("拒绝访问");
|
||||
}
|
||||
|
||||
if (!"SV2".equals(userApp.getRoleCode())) {
|
||||
throw new MsgException("暂无权限");
|
||||
}
|
||||
|
||||
UserLevel userLevel = ulService.getLevelInfoByRoleLevel(userApp.getRoleCode(), userApp.getLevelCode());
|
||||
|
||||
MsgException.checkNull(userLevel, "数据异常");
|
||||
|
||||
//费率校验
|
||||
rateValueCheck(rate.getWxRate(), userLevel.getRate().intValue());
|
||||
rateValueCheck(rate.getAliRate(), userLevel.getRate().intValue());
|
||||
rateValueCheckBank(rate.getBankRate(), userLevel.getRate().intValue());
|
||||
rateValueCheckBankLarge(rate.getBankRateLarge(), userLevel.getRate().intValue());
|
||||
|
||||
UserApp optedUserApp = userAppService.getUserAppByUserId(userId);
|
||||
|
||||
MerchantRateNewRecord validRecord = rateNewRecordService.getValidRecordByMerchantCode(optedUserApp.getMerchantCode(), getChannelId());
|
||||
if (validRecord != null) {
|
||||
if (validRecord.getStatus().equals(MerchantRateNewRecord.STATUS_IN_REVIEW) ||
|
||||
validRecord.getStatus().equals(MerchantRateNewRecord.STATUS_SUCCESS_NOT_EFFECT) ) {
|
||||
MsgException.throwException("当前费率修改正在审核中");
|
||||
}
|
||||
|
||||
if (DateUtil.isSameDay(validRecord.getCreateTime(), new Date())) {
|
||||
throw new MsgException("请于一天之后再修改费率");
|
||||
}
|
||||
}
|
||||
|
||||
MerchantRateNew merchantRate = rateNewService.getByUserId(userId, getChannelId());
|
||||
|
||||
if (merchantRate == null) {
|
||||
merchantRate = getDefaultRate();
|
||||
} else {
|
||||
rate.setId(merchantRate.getId());
|
||||
}
|
||||
|
||||
boolean flagWx = rate.getWxRate().equals(merchantRate.getWxRate());
|
||||
boolean flagAli = rate.getAliRate().equals(merchantRate.getAliRate());
|
||||
boolean flagBank = rate.getBankRate().equals(merchantRate.getBankRate());
|
||||
// boolean flagBankLarge = ("1".equals(getChannelId()) || "3".equals(getChannelId()) || rate.getBankRateLarge().equals(merchantRate.getBankRateLarge()));
|
||||
boolean flagBankLarge = true;
|
||||
if (flagWx && flagAli && flagBank && flagBankLarge) {
|
||||
throw new RateNoChangeException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(String userId, MerchantRateNew merchantRate) {
|
||||
// 更新本地数据库保存的费率
|
||||
// rateNewService.saveOrUpdate(merchantRate);
|
||||
|
||||
// 保存费率修改记录
|
||||
MerchantRateNewRecord merchantRateRecord = Converter.INSTANCE.trans(merchantRate);
|
||||
merchantRateRecord.setCreateTime(new Date());
|
||||
merchantRateRecord.setUpdateTime(new Date());
|
||||
rateNewRecordService.save(merchantRateRecord);
|
||||
}
|
||||
|
||||
private void rateValueCheck(int rateValue, int minRate) {
|
||||
if (rateValue < minRate || rateValue > 38) {
|
||||
throw new MsgException("商户支付宝或微信费率应在0." + minRate + "%到0.38%之间");
|
||||
}
|
||||
}
|
||||
|
||||
private void rateValueCheckBank(int rateValue, int minRate) {
|
||||
if (rateValue < minRate || rateValue > 38) {
|
||||
throw new MsgException("商户费率应在0." + (minRate + 2) + "%到0.40%之间");
|
||||
}
|
||||
}
|
||||
|
||||
private void rateValueCheckBankLarge(int rateValue, int minRate) {
|
||||
if ("1".equals(getChannelId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rateValue < minRate || rateValue > 38) {
|
||||
throw new MsgException("商户费率应在0." + ((minRate - 53) * 2 + 21) + "%到0.60%之间");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.MerchantRateRecordService;
|
||||
import cn.pluss.platform.entity.MerchantRate;
|
||||
import cn.pluss.platform.entity.MerchantRateRecord;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.exception.RateNoChangeException;
|
||||
import cn.pluss.platform.mapper.MerchantRateMapper;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public abstract class BaseMchChannelRateService implements MchChannelRateService {
|
||||
|
||||
@Resource
|
||||
protected MerchantRateMapper merchantRateMapper;
|
||||
|
||||
@Autowired
|
||||
protected MerchantRateRecordService merchantRateRecordService;
|
||||
|
||||
@Setter(onMethod_ = {@Autowired, @Lazy})
|
||||
protected UserAppService userAppService;
|
||||
|
||||
@Override
|
||||
public MerchantRate before(String userId, Integer rate) {
|
||||
if (userId == null) {
|
||||
throw new MsgException("用户id不能为空");
|
||||
}
|
||||
|
||||
MerchantRate merchantRate;
|
||||
QueryWrapper<MerchantRate> merchantRateQueryWrapper = new QueryWrapper<MerchantRate>().eq("userId", userId);
|
||||
merchantRate = merchantRateMapper.selectOne(merchantRateQueryWrapper);
|
||||
if (merchantRate != null && System.currentTimeMillis() - merchantRate.getUpdateTime().getTime() < 3600 * 24 * 1000L) {
|
||||
throw new MsgException("请于一天之后再修改费率");
|
||||
}
|
||||
|
||||
boolean noChangeFlag = (merchantRate == null && rate.equals(38)) || (merchantRate != null && rate.equals(merchantRate.getRate()));
|
||||
if (noChangeFlag) {
|
||||
throw new RateNoChangeException();
|
||||
}
|
||||
|
||||
QueryWrapper<MerchantRate> queryWrapper = new QueryWrapper<MerchantRate>().eq("userId", userId);
|
||||
return merchantRateMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(String userId, Integer rate, MerchantRate merchantRate) {
|
||||
// 更新本地数据库保存的费率
|
||||
if (merchantRate == null) {
|
||||
merchantRate = new MerchantRate().setUserId(userId);
|
||||
merchantRate.setRate(rate);
|
||||
merchantRate.setUpdateTime(new Date());
|
||||
merchantRate.setPreviousRate(38);
|
||||
merchantRateMapper.insert(merchantRate);
|
||||
} else {
|
||||
// 保存前一天的费率
|
||||
merchantRate.setPreviousRate(merchantRate.getRate());
|
||||
merchantRate.setRate(rate);
|
||||
merchantRate.setUpdateTime(new Date());
|
||||
merchantRateMapper.updateById(merchantRate);
|
||||
}
|
||||
|
||||
// 保存费率修改记录
|
||||
MerchantRateRecord merchantRateRecord = new MerchantRateRecord();
|
||||
merchantRateRecord.setRate(rate);
|
||||
merchantRateRecord.setUserId(userId);
|
||||
merchantRateRecord.setCreateTime(new Date());
|
||||
merchantRateRecordService.save(merchantRateRecord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.IdCardService;
|
||||
import cn.pluss.platform.MerchantAuditRecordService;
|
||||
import cn.pluss.platform.entity.IdCard;
|
||||
import cn.pluss.platform.entity.MerchantBaseInfo;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.merchant.AccountService;
|
||||
import cn.pluss.platform.merchant.MerchantBaseInfoService;
|
||||
import cn.pluss.platform.merchantChannelStatus.MerchantChannelStatusService;
|
||||
import cn.pluss.platform.mswitch.CommonSwitchService;
|
||||
import cn.pluss.platform.region.RegionReflectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
/**
|
||||
* @author DJH
|
||||
* 进件通用方法放到这里
|
||||
*/
|
||||
public abstract class BaseMerchantAuditService implements MerchantAuditService {
|
||||
|
||||
@Autowired
|
||||
protected RegionReflectService regionReflectService;
|
||||
|
||||
@Autowired
|
||||
protected CommonSwitchService commonSwitchService;
|
||||
|
||||
@Autowired
|
||||
protected AccountService accountService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
protected MerchantBaseInfoService merchantBaseInfoService;
|
||||
|
||||
@Autowired
|
||||
protected IdCardService idCardService;
|
||||
|
||||
@Autowired
|
||||
protected MerchantChannelStatusService mcsService;
|
||||
|
||||
@Autowired
|
||||
protected MerchantAuditRecordService merchAuditRecService;
|
||||
|
||||
/**
|
||||
* 结算卡修改申请通知模板
|
||||
*/
|
||||
public static String editApplyNoticeTemplate = "尊敬的商户“$1”,您的$2结算卡修改申请已提交,结算卡修改较为敏感,需要支付通道人工审核,一般三个工作日内修改完毕,修改结果会通过APP推送通知。修改通过后先小额支付一笔,确认到账新卡后再恢复使用,请知悉。";
|
||||
|
||||
/**
|
||||
* 结算卡修改成功通知模板
|
||||
*/
|
||||
public static String editApplyResultNoticeTemplate = "尊敬的商户“$1”,您的$2结算卡已修改完毕,为保险起见可以先交易一笔小额的, 比如一块钱 ,看是否到账新卡,如到新卡您再正常使用。请知悉!";
|
||||
|
||||
@Override
|
||||
public void merchantAuditCheck(String userId, boolean isFailCheck) {
|
||||
if (!commonSwitchService.allowMerchantRegister()) {
|
||||
MsgException.throwException("当前不允许进件!");
|
||||
}
|
||||
|
||||
MerchantBaseInfo merchantBaseInfo = merchantBaseInfoService.getMerchantBaseInfoByUserId(userId);
|
||||
MsgException.checkNull(merchantBaseInfo, "请完善经营信息");
|
||||
|
||||
String merchantType = merchantBaseInfo.getMerchantType();
|
||||
String principalPerson = merchantBaseInfo.getPrincipalPerson();
|
||||
if (!"1".equals(merchantType)) {
|
||||
MsgException.checkBlank(principalPerson, "请完善营业执照信息");
|
||||
|
||||
IdCard legalIdCard = idCardService.getLegalIdCard(userId);
|
||||
MsgException.checkNull(legalIdCard, "请完善法人信息");
|
||||
}
|
||||
|
||||
accountService.checkCert(merchantBaseInfo.getUserId(), "同一证件只能注册三个小微商户, 如有增加需求请联系客服");
|
||||
|
||||
if (isFailCheck) {
|
||||
merchAuditRecService.checkFailCount(merchantBaseInfo.getMerchantCode(), "连续三次复审驳回,请联系客服进件");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.entity.MakeMoney;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2020-09-10
|
||||
*/
|
||||
public interface MakeMoneyService extends IService<MakeMoney> {
|
||||
|
||||
void dealCallbackData(JSONObject data);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.api.ResultCode;
|
||||
import cn.pluss.platform.entity.MerchantRateNew;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.exception.RateNoChangeException;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 多种支付方式费率分开
|
||||
*/
|
||||
public interface MchChannelRateNewService {
|
||||
|
||||
/**
|
||||
* 修改商户的费率
|
||||
*/
|
||||
void before(String userId, MerchantRateNew merchantRate);
|
||||
|
||||
/**
|
||||
* 渠道操作
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void process(String userId, MerchantRateNew merchantRate);
|
||||
|
||||
void after(String userId, MerchantRateNew merchantRate);
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
default void changeRate(String userId, MerchantRateNew rate, boolean checkFlag) {
|
||||
if (checkFlag) {
|
||||
try {
|
||||
before(userId, rate);
|
||||
} catch (RateNoChangeException e) {
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new MsgException(ResultCode.SERVICE_UNAVAILABLE, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
process(userId, rate);
|
||||
|
||||
after(userId, rate);
|
||||
}
|
||||
|
||||
String getChannelId();
|
||||
|
||||
MerchantRateNew getDefaultRate();
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.entity.MerchantRate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface MchChannelRateService {
|
||||
|
||||
/**
|
||||
* 修改商户的费率
|
||||
*/
|
||||
MerchantRate before(String userId, Integer rate);
|
||||
|
||||
/**
|
||||
* 渠道操作
|
||||
* @param userId
|
||||
* @param rate
|
||||
*/
|
||||
void process(String userId, Integer rate, MerchantRate merchantRate);
|
||||
|
||||
void after(String userId, Integer rate, MerchantRate merchantRate);
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
default void changeRate(String userId, Integer rate) {
|
||||
MerchantRate merchantRate = before(userId, rate);
|
||||
process(userId, rate, merchantRate);
|
||||
after(userId, rate, merchantRate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.suixingfu.SxfConstants;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
/**
|
||||
* 机具操作回调数据处理
|
||||
* @author DJH
|
||||
*/
|
||||
public interface MchMachineCallbackService {
|
||||
|
||||
String OPERATION_PAY = "operationPay";
|
||||
String OPERATION_REFUND = "operationRefund";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 机具操作回调数据处理
|
||||
* @param param 回调参数
|
||||
*/
|
||||
@Async
|
||||
default void orderCallback(JSONObject param) {
|
||||
if (param.getString("ordNo") != null && param.getString("ordNo").startsWith("SXF")) {
|
||||
// SXF开头的订单,并不是机具回调的订单
|
||||
return;
|
||||
}
|
||||
|
||||
String operationType = getOperationType(param);
|
||||
if (operationType == null) {
|
||||
throw new MsgException("未知操作");
|
||||
}
|
||||
|
||||
switch (operationType) {
|
||||
case OPERATION_PAY:
|
||||
payCallback(param);
|
||||
break;
|
||||
case OPERATION_REFUND:
|
||||
refundCallback(param);
|
||||
break;
|
||||
case SxfConstants.SXF_POS_OPERATION:
|
||||
posCallback(param);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description:pos 机相关操作
|
||||
* @date: 2021/10/28 10:24
|
||||
* @param param:
|
||||
*/
|
||||
void posCallback(JSONObject param);
|
||||
|
||||
/**
|
||||
* 操作类型判断
|
||||
* @param param 参数
|
||||
* @return 参数类型,OPERATION_PAY 或者 OPERATION_REFUND
|
||||
*/
|
||||
String getOperationType(JSONObject param);
|
||||
|
||||
/**
|
||||
* 支付回调操作
|
||||
* @param param 参数
|
||||
*/
|
||||
void payCallback(JSONObject param);
|
||||
|
||||
/**
|
||||
* 退款回调操作
|
||||
* @param param 参数
|
||||
*/
|
||||
void refundCallback(JSONObject param);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.entity.JftMercPaymentChannel;
|
||||
import cn.pluss.platform.entity.MerchantChannelStatus;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* 商户协议相关功能
|
||||
* @author djh
|
||||
*/
|
||||
public interface MerchProtocolService {
|
||||
|
||||
/**
|
||||
* 请求签约状态,若未发起签约,则发起签约
|
||||
* @param mcs 商户通道信息
|
||||
* @return 预留返回值,根据具体的业务需求,选择使用
|
||||
*/
|
||||
default JSONObject reqMerProtocolStatus(MerchantChannelStatus mcs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求发起签约
|
||||
* @param mcs 商户通道信息
|
||||
* @return 预留返回值,根据具体的业务需求,选择使用
|
||||
*/
|
||||
default JSONObject sendProtocolMsg(MerchantChannelStatus mcs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求签约状态,若未发起签约,则发起签约
|
||||
* @param jpc 商户通道信息
|
||||
* @return 预留返回值,根据具体的业务需求,选择使用
|
||||
*/
|
||||
default JSONObject reqMerProtocolStatus(JftMercPaymentChannel jpc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求发起签约
|
||||
* @param jpc 商户通道信息
|
||||
* @return 预留返回值,根据具体的业务需求,选择使用
|
||||
*/
|
||||
default JSONObject sendProtocolMsg(JftMercPaymentChannel jpc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.entity.MerchantImage;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 进件接口定义
|
||||
* @author DJH
|
||||
*/
|
||||
public interface MerchantAuditService {
|
||||
|
||||
/**
|
||||
* 图片上传, 并将上传的图片code保存到传入的实体类中
|
||||
* @param merchantImage 图片信息
|
||||
*/
|
||||
void imageUpload(MerchantImage merchantImage);
|
||||
|
||||
/**
|
||||
* @param url 图片url,本地存储或OSS
|
||||
* @param picType 图片类型
|
||||
*/
|
||||
void imageUpload(String url, String picType);
|
||||
|
||||
/**
|
||||
* 进件
|
||||
* @param userId 用户id
|
||||
*/
|
||||
void merchantAudit(String userId, boolean isFailCheck);
|
||||
|
||||
void merchantAuditCheck(String userId, boolean isFailCheck);
|
||||
|
||||
/**
|
||||
* 修改进件信息,当前特指修改结算信息
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
void editMerchantAudit(String userId);
|
||||
|
||||
/**
|
||||
* 手动查询进件结果
|
||||
* @param result 查询进件信息参数
|
||||
*/
|
||||
JSONObject merchantAuditResult(Map<String, Object> result) throws Exception ;
|
||||
|
||||
/**
|
||||
* 进件回调
|
||||
* @param auditResult 进件回调的数据
|
||||
*/
|
||||
JSONObject merchantAuditCallback(JSONObject auditResult) throws Exception;
|
||||
|
||||
/**
|
||||
* 修改进件
|
||||
* @param auditResult 回调信息
|
||||
* @return 返回信息
|
||||
* @throws Exception 可能存在得异常信息
|
||||
*/
|
||||
JSONObject editMerchantCallback(JSONObject auditResult) throws Exception;
|
||||
|
||||
/**
|
||||
* 图片类型转换,源照片类型主要为乐刷定义的图片类型,参考MerchantImage
|
||||
*
|
||||
* @param imageType 图片类型
|
||||
* @return 对应通道的图片定义类型
|
||||
*/
|
||||
String imgTypeTransform(String imageType);
|
||||
|
||||
void checkSign(JSONObject receiveData) throws Exception;
|
||||
|
||||
default void step1(String userId) {}
|
||||
|
||||
default void step2(String userId) {}
|
||||
|
||||
default void step3(String userId) {}
|
||||
|
||||
default void step4(String userId) {}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import cn.pluss.platform.entity.SubMerchantApplyOrder;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* 商户认证接口定义
|
||||
*/
|
||||
public interface MerchantCertService {
|
||||
|
||||
/**
|
||||
* 商户微信实名认证
|
||||
* @param merchantId 商户渠道编号
|
||||
* @param merchantCode 商户code
|
||||
*/
|
||||
void wxCert(String merchantId, String merchantCode);
|
||||
|
||||
/**
|
||||
* 商户微信二次实名认证,失败后认证
|
||||
* @param merchantId 商户渠道编号
|
||||
* @param merchantCode 商户code
|
||||
*/
|
||||
void wxReCert(String merchantId, String merchantCode);
|
||||
|
||||
/**
|
||||
* 商户微信实名认证结果查询
|
||||
* @param merchantId 商户编号
|
||||
* @param wxApplyNo
|
||||
*/
|
||||
JSONObject wxCertResult(String merchantId, String wxApplyNo);
|
||||
|
||||
/**
|
||||
* 商户微信实名申请回调
|
||||
*/
|
||||
JSONObject wxCertCallback(JSONObject certResult);
|
||||
|
||||
/**
|
||||
* 商户微信认证申请撤销
|
||||
* 认证信息
|
||||
*/
|
||||
void wxCertCancel(String merchantId, SubMerchantApplyOrder subMerchantApplyOrder);
|
||||
|
||||
/**
|
||||
* 微信认证授权状态
|
||||
* @param merchantId 通道商编
|
||||
*/
|
||||
default void wxCertAuthStatus(String merchantId) {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.pluss.platform.channel;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* @author DJH
|
||||
* 支付插件服务接口类
|
||||
*/
|
||||
//public interface PluginService {
|
||||
//
|
||||
// /**
|
||||
// * 插件进件请求
|
||||
// * @param userId 用户id
|
||||
// */
|
||||
// void audit(String userId);
|
||||
//
|
||||
// /**
|
||||
// * 插件进件回调
|
||||
// * @param jsonObject 回调参数
|
||||
// */
|
||||
// void auditCallback(JSONObject jsonObject);
|
||||
//
|
||||
// /**
|
||||
// * 获取终端列表
|
||||
// * @param posMerId pos机商编
|
||||
// */
|
||||
// JSONObject termList(String posMerId);
|
||||
//}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.pluss.platform.channel.ys;
|
||||
|
||||
/**
|
||||
* 银盛通道额外的功能
|
||||
* @author DJH
|
||||
*/
|
||||
public interface YsExtensionService {
|
||||
|
||||
/**
|
||||
* 报备,进件自动报备失败时使用
|
||||
* @param userId 用户id
|
||||
*/
|
||||
void report(Long userId);
|
||||
|
||||
/**
|
||||
* 重新报备,
|
||||
* 报备过的的商户重新报备
|
||||
* @param userId 用户id
|
||||
*/
|
||||
void reportAgain(Long userId);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.pluss.platform.common;
|
||||
|
||||
import cn.pluss.platform.ipLocation.IpLocationService;
|
||||
import com.aliyuncs.auth.sts.AssumeRoleResponse;
|
||||
|
||||
/**
|
||||
* @author djh
|
||||
* 提供阿里云服务部分功能接口调用
|
||||
*/
|
||||
public interface AliyunService extends IpLocationService {
|
||||
|
||||
/**
|
||||
* 银行卡四要素
|
||||
* @param phone 手机号
|
||||
* @param bankCardNo 银行卡号
|
||||
* @param certNo 身份证号
|
||||
* @param realName 姓名
|
||||
* @return 校验结果
|
||||
*/
|
||||
void checkBankCorrect(String phone, String bankCardNo, String certNo, String realName);
|
||||
|
||||
/**
|
||||
* 银行卡四要素
|
||||
* @param phone 手机号
|
||||
* @param bankCardNo 银行卡号
|
||||
* @param certNo 身份证号
|
||||
* @param realName 姓名
|
||||
* @return 校验结果
|
||||
*/
|
||||
void checkBankCorrect(String phone, String bankCardNo, String certNo, String realName, String errorMsg);
|
||||
|
||||
AssumeRoleResponse.Credentials stsToken(String userId);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.pluss.platform.common;
|
||||
|
||||
import cn.pluss.platform.entity.CommonRemark;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import lombok.val;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用备注表,存储一些通用备注 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-06-24
|
||||
*/
|
||||
public interface CommonRemarkService extends IService<CommonRemark> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.pluss.platform.common;
|
||||
|
||||
import cn.pluss.platform.dto.RiskBlacklistDTO;
|
||||
import cn.pluss.platform.entity.RiskBlacklist;
|
||||
import cn.pluss.platform.vo.RiskBlacklistVO;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 风控黑名单表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-09-07
|
||||
*/
|
||||
public interface RiskBlacklistService extends IService<RiskBlacklist> {
|
||||
|
||||
/**
|
||||
* 添加黑名单数据并关闭商户交易权限
|
||||
* @param riskBlacklistDTO 黑名单数据
|
||||
*/
|
||||
void addData(RiskBlacklistDTO riskBlacklistDTO);
|
||||
|
||||
/**
|
||||
* 拉黑单商户,并拉黑结算信息相关的账号信息
|
||||
* @param riskBlacklistDTO 黑名单数据
|
||||
*/
|
||||
void closeMerch(RiskBlacklistDTO riskBlacklistDTO);
|
||||
|
||||
Page<RiskBlacklistVO> page(Page<RiskBlacklistVO> page, Map<String, Object> condition);
|
||||
|
||||
/**
|
||||
* 批量拉黑
|
||||
* @param riskBlacklistDTO 黑名单数据
|
||||
*/
|
||||
void batchAddData(RiskBlacklistDTO riskBlacklistDTO);
|
||||
|
||||
/**
|
||||
* 解除拉黑
|
||||
* @param opUserId 操作人用户id
|
||||
* @param userId 用户id
|
||||
*/
|
||||
void relieve(Long opUserId, Long userId);
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package cn.pluss.platform.common.impl;
|
||||
|
||||
import cn.pluss.platform.common.AliyunService;
|
||||
import cn.pluss.platform.config.OssConfig;
|
||||
import cn.pluss.platform.config.StsConfig;
|
||||
import cn.pluss.platform.dict.Bank4CacheService;
|
||||
import cn.pluss.platform.entity.Bank4Cache;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.util.HttpResult;
|
||||
import cn.pluss.platform.util.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.auth.sts.AssumeRoleRequest;
|
||||
import com.aliyuncs.auth.sts.AssumeRoleResponse;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.exceptions.ServerException;
|
||||
import com.aliyuncs.geoip.model.v20200101.DescribeIpv4LocationRequest;
|
||||
import com.aliyuncs.geoip.model.v20200101.DescribeIpv4LocationResponse;
|
||||
import com.aliyuncs.http.MethodType;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.aliyuncs.profile.IClientProfile;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AliyunServiceImpl implements AliyunService {
|
||||
|
||||
@Autowired
|
||||
private Bank4CacheService bank4CacheService;
|
||||
|
||||
private final OssConfig ossConfig;
|
||||
|
||||
private final StsConfig stsConfig;
|
||||
|
||||
@Value("${aliyun.bankcard.app-code}")
|
||||
private String appCode;
|
||||
|
||||
@Value("${aliyun.bankcard.bank-url}")
|
||||
private String bankCheckUrl;
|
||||
|
||||
/**
|
||||
* 不好用
|
||||
* @param ip ip
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DescribeIpv4LocationResponse getLocation(String ip) {
|
||||
log.info("顾客 remote ip: {}", ip);
|
||||
//
|
||||
//
|
||||
DefaultProfile profile = DefaultProfile.getProfile(ossConfig.getRegionId(), ossConfig.getKeyid(), ossConfig.getKeysecret());
|
||||
IAcsClient client = new DefaultAcsClient(profile);
|
||||
|
||||
DescribeIpv4LocationRequest request = new DescribeIpv4LocationRequest();
|
||||
request.setIp(ip);
|
||||
|
||||
try {
|
||||
DescribeIpv4LocationResponse response = client.getAcsResponse(request);
|
||||
log.info(new Gson().toJson(response));
|
||||
return response;
|
||||
} catch (ServerException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClientException e) {
|
||||
log.error("ErrCode:" + e.getErrCode());
|
||||
log.error("ErrMsg:" + e.getErrMsg());
|
||||
log.error("RequestId:" + e.getRequestId());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkBankCorrect(String phone, String bankCardNo, String certNo, String realName) {
|
||||
Bank4Cache bank4Cache = new Bank4Cache();
|
||||
bank4Cache.setPhone(phone);
|
||||
bank4Cache.setBankCardNo(bankCardNo);
|
||||
bank4Cache.setIdCardNo(certNo);
|
||||
bank4Cache.setName(realName);
|
||||
Calendar instance = Calendar.getInstance();
|
||||
instance.add(Calendar.DAY_OF_MONTH, -1);
|
||||
bank4Cache.setCreateTimeStart(instance.getTime());
|
||||
|
||||
Bank4Cache one = bank4CacheService.getOne(new QueryWrapper<>(bank4Cache).orderByDesc("createTime").last("limit 1"));
|
||||
if (one != null) {
|
||||
if (one.getStatus().equals(Bank4Cache.STATUS_PASS)) {
|
||||
return;
|
||||
} else {
|
||||
log.error("银行卡四要素检查:" + one.getRemark());
|
||||
throw new MsgException("身份证、银行卡或预留手机号信息不正确");
|
||||
}
|
||||
}
|
||||
|
||||
// 调用阿里云银行卡认证接口
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", "APPCODE " + appCode);
|
||||
Map<String, Object> querys = new HashMap<>();
|
||||
querys.put("Mobile", phone);
|
||||
querys.put("bankcard", bankCardNo);
|
||||
querys.put("cardNo", certNo);
|
||||
querys.put("realName", realName);
|
||||
HttpResult response = null;
|
||||
try {
|
||||
response = HttpUtil.doGet(bankCheckUrl, headers, querys);
|
||||
log.info(response.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(response.getBody());
|
||||
|
||||
if (200 != response.getCode()) {
|
||||
if (403 == response.getCode()) {
|
||||
throw new MsgException("银行卡认证接口已欠费,请联系平台");
|
||||
} else {
|
||||
throw new MsgException("银行卡认证失败");
|
||||
}
|
||||
}
|
||||
if (!"0".equalsIgnoreCase(jsonObject.getString("error_code"))) {
|
||||
log.error("银行卡四要素检查:" + jsonObject.getString("reason"));
|
||||
bank4Cache.setRemark(jsonObject.getString("reason"));
|
||||
bank4Cache.setStatus(Bank4Cache.STATUS_FAIL);
|
||||
bank4CacheService.save(bank4Cache);
|
||||
throw new MsgException("身份证、银行卡或预留手机号信息不正确");
|
||||
} else {
|
||||
bank4Cache.setStatus(Bank4Cache.STATUS_PASS);
|
||||
bank4CacheService.save(bank4Cache);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkBankCorrect(String phone, String bankCardNo, String certNo, String realName, String errorMsg) {
|
||||
try {
|
||||
checkBankCorrect(phone, bankCardNo, certNo, realName);
|
||||
} catch (Exception e) {
|
||||
throw new MsgException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssumeRoleResponse.Credentials stsToken(String userId) {
|
||||
String endpoint = stsConfig.getEndpoint().replace("https://", "");
|
||||
String accessKeyId = stsConfig.getKeyid();
|
||||
String accessKeySecret = stsConfig.getKeysecret();
|
||||
String roleArn = stsConfig.getRoleArn();
|
||||
String roleSessionName = "-" + userId;
|
||||
|
||||
// 允许所有目录权限
|
||||
JSONObject policyMap = new JSONObject();
|
||||
List<JSONObject> statementList= new LinkedList<>();
|
||||
policyMap.put("Version", "1");
|
||||
JSONObject statementMap = new JSONObject();
|
||||
statementMap.put("Action", new String[] {"oss:*"});
|
||||
statementMap.put("Resource", new String[] {"acs:oss:*:*:*"});
|
||||
statementMap.put("Effect", "Allow");
|
||||
statementList.add(statementMap);
|
||||
policyMap.put("Statement", statementList);
|
||||
|
||||
try {
|
||||
// 添加endpoint(直接使用STS endpoint,前两个参数留空,无需添加region ID)
|
||||
DefaultProfile.addEndpoint( "", "Sts", endpoint);
|
||||
// 构造default profile(参数留空,无需添加region ID)
|
||||
IClientProfile profile = DefaultProfile.getProfile("", accessKeyId, accessKeySecret);
|
||||
// 用profile构造client
|
||||
DefaultAcsClient client = new DefaultAcsClient(profile);
|
||||
final AssumeRoleRequest request = new AssumeRoleRequest();
|
||||
request.setSysMethod(MethodType.POST);
|
||||
request.setRoleArn(roleArn);
|
||||
request.setRoleSessionName(roleSessionName);
|
||||
// 若policy为空,则用户将获得该角色下所有权限
|
||||
request.setPolicy(policyMap.toJSONString());
|
||||
// 设置凭证有效时间
|
||||
request.setDurationSeconds(3600L);
|
||||
final AssumeRoleResponse response = client.getAcsResponse(request);
|
||||
return response.getCredentials();
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
log.error("无法获取oss上传token");
|
||||
throw new MsgException("无法获取oss上传凭证");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.pluss.platform.common.impl;
|
||||
|
||||
import cn.pluss.platform.common.CommonRemarkService;
|
||||
import cn.pluss.platform.entity.CommonRemark;
|
||||
import cn.pluss.platform.mapper.CommonRemarkMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用备注表,存储一些通用备注 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Djh
|
||||
* @since 2021-06-24
|
||||
*/
|
||||
@Service
|
||||
public class CommonRemarkServiceImpl extends ServiceImpl<CommonRemarkMapper, CommonRemark> implements CommonRemarkService {
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user