|
@@ -1,21 +1,33 @@
|
|
package com.chelvc.cloud.vehicle.server.service.impl;
|
|
package com.chelvc.cloud.vehicle.server.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.chelvc.cloud.vehicle.client.constant.TradeConstant;
|
|
import com.chelvc.cloud.vehicle.server.dao.MerchantRelationMapper;
|
|
import com.chelvc.cloud.vehicle.server.dao.MerchantRelationMapper;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.Merchant;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.MerchantApplyRecord;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.MerchantAuth;
|
|
import com.chelvc.cloud.vehicle.server.entity.MerchantRelation;
|
|
import com.chelvc.cloud.vehicle.server.entity.MerchantRelation;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.handle.TradeHandle;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.service.MerchantApplyRecordService;
|
|
import com.chelvc.cloud.vehicle.server.service.MerchantRelationService;
|
|
import com.chelvc.cloud.vehicle.server.service.MerchantRelationService;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.service.MerchantService;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.UUID;
|
|
|
|
+
|
|
@Service
|
|
@Service
|
|
@RequiredArgsConstructor(onConstructor = @__({@Autowired,@Lazy}))
|
|
@RequiredArgsConstructor(onConstructor = @__({@Autowired,@Lazy}))
|
|
public class MerchantRelationServiceImpl extends ServiceImpl<MerchantRelationMapper,
|
|
public class MerchantRelationServiceImpl extends ServiceImpl<MerchantRelationMapper,
|
|
MerchantRelation> implements MerchantRelationService {
|
|
MerchantRelation> implements MerchantRelationService {
|
|
-
|
|
|
|
|
|
+ private final MerchantService merchantService;
|
|
|
|
+ private final MerchantApplyRecordService merchantApplyRecordService;
|
|
@Override
|
|
@Override
|
|
public MerchantRelation queryByUserIdAndType(Long userId, Integer type) {
|
|
public MerchantRelation queryByUserIdAndType(Long userId, Integer type) {
|
|
LambdaQueryWrapper<MerchantRelation> wrapper = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<MerchantRelation> wrapper = Wrappers.lambdaQuery();
|
|
@@ -23,4 +35,101 @@ public class MerchantRelationServiceImpl extends ServiceImpl<MerchantRelationMap
|
|
wrapper.eq(MerchantRelation::getType, type);
|
|
wrapper.eq(MerchantRelation::getType, type);
|
|
return baseMapper.selectOne(wrapper);
|
|
return baseMapper.selectOne(wrapper);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void registerMerchantId(MerchantAuth merchantAuth) {
|
|
|
|
+ Merchant merchant = merchantService.getById(merchantAuth.getId());
|
|
|
|
+ String requestId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ String operationType = "CREATE";
|
|
|
|
+ jsonObject.put("merchantId", TradeConstant.PARTNER_ID);
|
|
|
|
+ jsonObject.put("requestId", requestId);
|
|
|
|
+ jsonObject.put("operationType", operationType);
|
|
|
|
+ jsonObject.put("notifyUrl", TradeConstant.MERCHANT_NET_IN_NOTIFY_URL);
|
|
|
|
+ jsonObject.put("extendedParameters", "sendActiveEmail:FALSE,sendExpressPayMsg:FALSE");
|
|
|
|
+
|
|
|
|
+ //商户基本信息
|
|
|
|
+ JSONObject baseInfo = new JSONObject();
|
|
|
|
+ baseInfo.put("signedType", "BY_SPLIT_BILL");
|
|
|
|
+ baseInfo.put("signedName", merchantAuth.getLegalRepresentativeName());
|
|
|
|
+ baseInfo.put("registerRole", "INDIVIDUAL_BUSINESS"); //个体工商户
|
|
|
|
+ baseInfo.put("cerType", "INDIVIDUAL_BUSINESS_LICENCE "); //个体工商户营业执照
|
|
|
|
+ baseInfo.put("signedShorthand", merchantAuth.getStoreName());
|
|
|
|
+ baseInfo.put("businessAddressProvince", merchant.getProvince());
|
|
|
|
+ baseInfo.put("businessAddressCity", merchant.getCity());
|
|
|
|
+ baseInfo.put("businessAddressArea", merchant.getDistrict());
|
|
|
|
+ baseInfo.put("businessAddress", merchant.getAddress());
|
|
|
|
+ baseInfo.put("contactName", merchant.getLiaison());
|
|
|
|
+ baseInfo.put("contactEmail", merchantAuth.getEmail());
|
|
|
|
+ baseInfo.put("contactPhone", merchant.getMobile());
|
|
|
|
+ jsonObject.put("baseInfo", baseInfo);
|
|
|
|
+
|
|
|
|
+ //结算信息
|
|
|
|
+ JSONObject bankCardInfo = new JSONObject();
|
|
|
|
+ //bankCardInfo.put("bankName", ""); //开户行名称
|
|
|
|
+ //bankCardInfo.put("bankBranchName", ""); //支行名称
|
|
|
|
+ bankCardInfo.put("accountName", "");
|
|
|
|
+ bankCardInfo.put("bankCardNo", "");
|
|
|
|
+ bankCardInfo.put("accountType", "PRIVATE");
|
|
|
|
+ bankCardInfo.put("liquidationType", "WITHDRAW");
|
|
|
|
+ bankCardInfo.put("withdrawRateType", "SINGLE");
|
|
|
|
+ bankCardInfo.put("withdrawRate", "0.00");
|
|
|
|
+ bankCardInfo.put("reservedPhoneNo", ""); //银行预留手机号
|
|
|
|
+ jsonObject.put("bankCardInfo", bankCardInfo);
|
|
|
|
+
|
|
|
|
+ //商户资质信息
|
|
|
|
+ JSONObject certificateInfo = new JSONObject();
|
|
|
|
+ certificateInfo.put("legalPersonName", merchantAuth.getLegalRepresentativeName());
|
|
|
|
+ certificateInfo.put("legalPersonPhone", merchantAuth.getMobileNumber());
|
|
|
|
+ certificateInfo.put("legalPersonIdType", "IDCARD");
|
|
|
|
+ certificateInfo.put("legalPersonIdNo", merchantAuth.getIdCardNumber());
|
|
|
|
+ certificateInfo.put("idEffectiveDateStart", ""); //身份证号有效期开始
|
|
|
|
+ certificateInfo.put("idEffectiveDateEnd", merchantAuth.getIdCardExpirationDate());
|
|
|
|
+ certificateInfo.put("cerNo", merchantAuth.getBusinessLicenseId());
|
|
|
|
+ certificateInfo.put("sellingArea", "C");
|
|
|
|
+ certificateInfo.put("staffSize", "C");
|
|
|
|
+ certificateInfo.put("businessLicensePath", ""); //营业执照照片路径
|
|
|
|
+ certificateInfo.put("openAccountPath", ""); // 开户许可证照片路径
|
|
|
|
+ certificateInfo.put("legalIdCardProsPath", ""); // 法人证件人像面路径
|
|
|
|
+ certificateInfo.put("legalIdCardConsPath", ""); // 法人证件国徽面路径
|
|
|
|
+ certificateInfo.put("legalPersonBankCardPath", ""); // 法人银行卡图影印件路径
|
|
|
|
+ jsonObject.put("certificateInfo", certificateInfo);
|
|
|
|
+
|
|
|
|
+ //商户合同信息
|
|
|
|
+ JSONObject contractInfo = new JSONObject();
|
|
|
|
+ contractInfo.put("receiverName", merchant.getLiaison());
|
|
|
|
+ contractInfo.put("receiverPhone", merchant.getMobile());
|
|
|
|
+ contractInfo.put("receiverAddress", merchant.getAddress());
|
|
|
|
+ jsonObject.put("contractInfo", contractInfo);
|
|
|
|
+
|
|
|
|
+ JSONObject json = TradeHandle.handle(String.valueOf(jsonObject), TradeConstant.DECLARE_URL,
|
|
|
|
+ TradeConstant.PARTNER_ID, null);
|
|
|
|
+ String status = json.getString("status");
|
|
|
|
+ int recordStatus = 0;
|
|
|
|
+ if("SUCCESS".equals(status)){
|
|
|
|
+ recordStatus = 2;
|
|
|
|
+ } else {
|
|
|
|
+ recordStatus = 1;
|
|
|
|
+ }
|
|
|
|
+ String subMerchantId = json.getString("subMerchantId");
|
|
|
|
+ MerchantApplyRecord record = new MerchantApplyRecord();
|
|
|
|
+ record.setUserId(merchantAuth.getId());
|
|
|
|
+ record.setType(2);
|
|
|
|
+ record.setRequestId(requestId);
|
|
|
|
+ record.setStatus(recordStatus);
|
|
|
|
+ record.setOperationType("CREATE");
|
|
|
|
+ record.setExamineStatus("PROCESSING");
|
|
|
|
+ record.setSubMerchantId(subMerchantId);
|
|
|
|
+ record.setCreateTime(new Date());
|
|
|
|
+ merchantApplyRecordService.insert(record);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int insert(Long userId, Integer type, String sxyMerchantId) {
|
|
|
|
+ MerchantRelation relation = new MerchantRelation();
|
|
|
|
+ relation.setType(type);
|
|
|
|
+ relation.setUserId(userId);
|
|
|
|
+ relation.setSxyMerchantId(sxyMerchantId);
|
|
|
|
+ return baseMapper.insert(relation);
|
|
|
|
+ }
|
|
}
|
|
}
|