Authored by tanling

入驻充值

... ... @@ -10,7 +10,7 @@ public interface IEntrySellerRechargeService {
* 首次入驻
* @param entrySellerRecharge
*/
void firstEntry(EntrySellerRecharge entrySellerRecharge);
public void firstEntry(EntrySellerRecharge entrySellerRecharge);
... ... @@ -18,7 +18,7 @@ public interface IEntrySellerRechargeService {
* 重新入驻
* @param entrySellerRecharge
*/
void againEntry(EntrySellerRecharge entrySellerRecharge);
public void againEntry(EntrySellerRecharge entrySellerRecharge);
... ... @@ -26,7 +26,7 @@ public interface IEntrySellerRechargeService {
* 充值
* @param entrySellerRecharge
*/
void recharge(EntrySellerRecharge entrySellerRecharge);
public void recharge(EntrySellerRecharge entrySellerRecharge);
... ...
... ... @@ -60,6 +60,9 @@ public class EntrySellerRechargeHandler implements IEventHandler<EntrySellerRech
@Autowired
IEntrySellerRechargeService entrySellerRechargeService;
@Autowired
UfoServiceCaller ufoServiceCaller;
@Override
public void handle(EntrySellerRechargeEvent event) {
... ... @@ -73,7 +76,10 @@ public class EntrySellerRechargeHandler implements IEventHandler<EntrySellerRech
tradeBillsService.addPayRechargeEnsureRecord(orderInfo.getUid(), orderCode, payment, orderInfo.getAmount());
EntrySellerRecharge entrySellerRecharge = new EntrySellerRecharge(uid, amount, orderCode, payment);
EntrySellerRecharge entrySellerRecharge = EntrySellerRecharge.builder().amount(amount)
.orderCode(orderCode)
.uid(uid)
.payment(payment).build();
// 明确 充值场景
SellerEntryRecharge sellerEntryRecharge = getSellerEntryRecharge(orderInfo.getUid(), orderInfo.getType());
... ... @@ -84,13 +90,30 @@ public class EntrySellerRechargeHandler implements IEventHandler<EntrySellerRech
case FIRST_ENTRY:
logger.error("seller entry firstEntry {}", entrySellerRecharge);
// 1.检查是否是 芝麻认证的用户
String firstEntryCertNo = geytZhiMaCertNo(uid);
if (StringUtils.isBlank(firstEntryCertNo)){
logger.error("frist_entry geytZhiMaCertNo null uid: {}", uid);
return true;
}
entrySellerRecharge.setCertNo(firstEntryCertNo);
entrySellerRechargeService.firstEntry(entrySellerRecharge);
break;
case AGAIN_ENTRY:
logger.error("seller entry againEntry {}", entrySellerRecharge);
// 1.检查是否是 芝麻认证的用户
String againEntryCertNo = geytZhiMaCertNo(uid);
if (StringUtils.isBlank(againEntryCertNo)){
logger.error("again entry geytZhiMaCertNo null uid: {}", uid);
return true;
}
entrySellerRecharge.setCertNo(againEntryCertNo);
entrySellerRechargeService.againEntry(entrySellerRecharge);
break;
... ... @@ -109,7 +132,7 @@ public class EntrySellerRechargeHandler implements IEventHandler<EntrySellerRech
return true;
});
}catch (Exception e){
logger.error("entry seller recharge e {}", e);
logger.error("entry seller recharge orderInfo {}, e {}",orderInfo, e);
return;
}
... ... @@ -123,21 +146,17 @@ public class EntrySellerRechargeHandler implements IEventHandler<EntrySellerRech
private SellerEntryRecharge getSellerEntryRecharge(int uid, int type) {
if (type == TYPE_FIRST_RECHARGE){
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
SellerEntryRecharge sellerEntryRecharge = null;
if (type == TYPE_FIRST_RECHARGE){
if (sw != null){
sellerEntryRecharge = SellerEntryRecharge.AGAIN_ENTRY;
return SellerEntryRecharge.AGAIN_ENTRY;
}else{
sellerEntryRecharge = SellerEntryRecharge.FIRST_ENTRY;
return SellerEntryRecharge.FIRST_ENTRY;
}
}else{
sellerEntryRecharge = SellerEntryRecharge.RECHARGE;
return SellerEntryRecharge.RECHARGE;
}
return sellerEntryRecharge;
}
... ... @@ -150,4 +169,21 @@ public class EntrySellerRechargeHandler implements IEventHandler<EntrySellerRech
FIRST_ENTRY, AGAIN_ENTRY, RECHARGE
}
private String geytZhiMaCertNo(int uid){
ZhiMaCert cert = null;
try {
ApiResponse<?> resp = ufoServiceCaller.call("ufo.user.zhiMaCertInfo", ApiResponse.class, uid);
cert = (ZhiMaCert) resp.getData();
} catch (Exception e) {
logger.error("geytZhiMaCertNo uid {}", uid);
return null;
}
if(cert == null || StringUtils.isBlank(cert.getCertNo())) {
logger.error("geytZhiMaCertNo uid {}", uid);
return null;
}
return cert.getCertNo();
}
}
... ...
... ... @@ -3,6 +3,8 @@ package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.yoho.core.config.ConfigReader;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
... ... @@ -99,18 +101,12 @@ public class EntrySellerRechargeServiceImpl implements IEntrySellerRechargeServi
@Database(ForceMaster = true, DataSource = "ufo_order")
public void againEntry(EntrySellerRecharge entrySellerRecharge){
logger.error("seller entry againEntry {}", entrySellerRecharge);
int uid = entrySellerRecharge.getUid();
BigDecimal amount = entrySellerRecharge.getAmount();
long orderCode = entrySellerRecharge.getOrderCode();
int payment = entrySellerRecharge.getPayment();
// 1. 检查芝麻认证用户
String againEntryCertNo = geytZhiMaCertNo(uid);
if (StringUtils.isBlank(againEntryCertNo)){
logger.error("again_entry geytZhiMaCertNo null ,uid={}", uid);
return;
}
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
if (sw == null){
... ... @@ -118,11 +114,11 @@ public class EntrySellerRechargeServiceImpl implements IEntrySellerRechargeServi
return;
}
// 2.检查是否达到了 入驻上线
if (!canRejoin(uid, sw.getJoinTimes(), againEntryCertNo)){
logger.error("again_entry joinTimes maxTimes,uid: {},times: {}", uid, sw.getJoinTimes());
return;
}
// // 2.检查是否达到了 入驻上限 ==> 都已经支付成功回调了,才来检查是否超过入驻上限?
// if (!canRejoin(uid, sw.getJoinTimes(), entrySellerRecharge.getCertNo())){
// logger.error("again_entry joinTimes maxTimes,uid: {},times: {}", uid, sw.getJoinTimes());
// return;
// }
// 3. 更新 钱包总表
int uptCnt = sellerWalletMapper.rejoin(uid, amount, null, TimeUtils.getTimeStampSecond(), sw.getJoinTimes() + 1);
... ... @@ -135,10 +131,10 @@ public class EntrySellerRechargeServiceImpl implements IEntrySellerRechargeServi
clearOldEntryData(orderCode, uid);
// 5. 增加入驻次数
addJoinHistory(uid, againEntryCertNo);
addJoinHistory(uid, entrySellerRecharge.getCertNo());
// 6. 增加明细
addSellerWalletDetail(orderCode, uid, sw.getId(), amount, payment);
addSellerWalletDetail(orderCode, uid, sw.getId(), amount, entrySellerRecharge.getPayment());
}
... ... @@ -149,24 +145,19 @@ public class EntrySellerRechargeServiceImpl implements IEntrySellerRechargeServi
@Database(ForceMaster = true, DataSource = "ufo_order")
public void firstEntry(EntrySellerRecharge entrySellerRecharge){
logger.error("seller entry firstEntry {}", entrySellerRecharge);
int uid = entrySellerRecharge.getUid();
BigDecimal amount = entrySellerRecharge.getAmount();
long orderCode = entrySellerRecharge.getOrderCode();
int payment = entrySellerRecharge.getPayment();
// 1.检查是否是 芝麻认证的用户
String firstEntryCertNo = geytZhiMaCertNo(uid);
if (StringUtils.isBlank(firstEntryCertNo)){
logger.error("frist_entry geytZhiMaCertNo null uid: {}", uid);
return;
}
// 2. 增加钱包总表
SellerWallet sw = addSellerWallet(amount, uid);
// 3.入驻次数记录
addJoinHistory(uid, firstEntryCertNo);
addJoinHistory(uid, entrySellerRecharge.getCertNo());
// 4.增加明细
addSellerWalletDetail(orderCode, uid, sw.getId(), amount, payment);
... ... @@ -190,22 +181,7 @@ public class EntrySellerRechargeServiceImpl implements IEntrySellerRechargeServi
}
private String geytZhiMaCertNo(int uid){
ZhiMaCert cert = null;
try {
ApiResponse<?> resp = ufoServiceCaller.call("ufo.user.zhiMaCertInfo", ApiResponse.class, uid);
cert = (ZhiMaCert) resp.getData();
} catch (Exception e) {
logger.error("geytZhiMaCertNo uid {}", uid);
return null;
}
if(cert == null || StringUtils.isBlank(cert.getCertNo())) {
logger.error("geytZhiMaCertNo uid {}", uid);
return null;
}
return cert.getCertNo();
}
private SellerWallet addSellerWallet(BigDecimal amount, Integer uid) {
... ...
... ... @@ -18,7 +18,7 @@
<properties>
<qiniu.version>7.0.5</qiniu.version>
<project-name>yohoufo-fore</project-name>
<model.version>24.0-SNAPSHOT</model.version>
<model.version>25.0-SNAPSHOT</model.version>
<lombok.version>1.16.16</lombok.version>
</properties>
... ...