Authored by chenchao

add apply 2 super enter seller

package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
import com.yohobuy.ufo.model.order.resp.SellerResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.order.service.IStoredSellerDepositService;
import com.yohoufo.order.service.IStoredSellerService;
import com.yohoufo.order.service.impl.SellerService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
/**
* Created by chao.chen on 2019/1/11.
*/
@Controller
public class SellerController {
private final Logger logger = LoggerUtils.getSellerOrderLogger();
@Autowired
private IStoredSellerDepositService storedSellerDepositService;
@Autowired
private IStoredSellerService storedSellerService;
@Autowired
private SellerService sellerService;
/**
* 商户退驻
*/
@RequestMapping(params = "method=ufo.sellerOrder.quitStoredSeller")
@ResponseBody
public ApiResponse quitStoredSeller(@RequestParam("uid") Integer uid) throws GatewayException {
logger.info("enter StoredSellerController quitStoredSeller param uid is {}", uid);
//(1) 优先校验请求的参数
if (uid == null || uid <=0 ){
throw new GatewayException(400, "参数错误,uid不存在!");
}
storedSellerDepositService.quitStoredSellerAndReturnDeposit(uid);
return new ApiResponse();
}
/**
* 入驻商户的状态
* 芝麻认证状态
* 入驻状态
*/
@RequestMapping(params = "method=ufo.sellerOrder.entryStatus")
@ResponseBody
public ApiResponse entryStatus(@RequestParam("uid") Integer uid) {
logger.info("enter StoredSellerController entryStatus param uid is {}", uid);
//(1) 优先校验请求的参数
if (uid == null || uid <=0 ){
throw new UfoServiceException(400, "参数错误,uid不存在!");
}
SellerResp resp = storedSellerService.entryStatus(uid);
ApiResponse apiResponse = new ApiResponse();
apiResponse.setData(resp);
return apiResponse;
}
/**
* 是否入驻商户
*/
@RequestMapping(params = "method=ufo.sellerOrder.isStoredSeller")
@ResponseBody
public ApiResponse isStoredSeller(@RequestParam("uid") Integer uid) {
logger.info("enter StoredSellerController isStoredSeller param uid is {}", uid);
//(1) 优先校验请求的参数
if (uid == null || uid <=0 ){
throw new UfoServiceException(400, "参数错误,uid不存在!");
}
boolean isStoredSeller=storedSellerService.isStoredSeller(uid);
ApiResponse apiResponse = new ApiResponse();
apiResponse.setData(isStoredSeller);
return apiResponse;
}
@RequestMapping(params = "method=ufo.seller.entryThresholds")
@ResponseBody
public ApiResponse getEntryThresholds() {
Map<EntrySellerType,EntryThreshold> data = sellerService.getEntryThreshold();
logger.info("enter ufo.seller.entryThresholds data {}", data);
return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("升级预充值阈值").build();
}
@RequestMapping(params = "method=ufo.seller.applySuperEnter")
@ResponseBody
public ApiResponse applySuperEnter(@RequestParam("uid") Integer uid) {
logger.info("enter ufo.seller.applySuperEnter uid {}", uid);
Boolean data = sellerService.applySuperEnter(uid);
String msg = "升级超级卖家";
if (data){
msg += "成功";
}else{
msg += "失败";
}
return new ApiResponse.ApiResponseBuilder().data(data).code(200).message(msg).build();
}
}
... ...
package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
import com.yohobuy.ufo.model.order.resp.SellerResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.order.model.request.ShoppingRequest;
import com.yohoufo.order.model.response.OrderSubmitResponse;
import com.yohoufo.order.service.IStoredSellerDepositService;
import com.yohoufo.order.service.IStoredSellerService;
import com.yohoufo.order.service.impl.SellerService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 入驻商户保证金
* Created by craig.qin on 2018/9/13.
... ... @@ -37,11 +25,6 @@ public class StoredSellerDepositController {
@Autowired
private IStoredSellerDepositService storedSellerDepositService;
@Autowired
private IStoredSellerService storedSellerService;
@Autowired
private SellerService sellerService;
/**
* 预存保证金
... ... @@ -66,70 +49,7 @@ public class StoredSellerDepositController {
return new ApiResponse.ApiResponseBuilder().data(orderSubmitResponse).code(200).message("保证金充值订单生成,请支付").build();
}
/**
* 商户退驻
*/
@RequestMapping(params = "method=ufo.sellerOrder.quitStoredSeller")
@ResponseBody
public ApiResponse quitStoredSeller(@RequestParam("uid") Integer uid) throws GatewayException {
logger.info("enter StoredSellerController quitStoredSeller param uid is {}", uid);
//(1) 优先校验请求的参数
if (uid == null || uid <=0 ){
throw new GatewayException(400, "参数错误,uid不存在!");
}
storedSellerDepositService.quitStoredSellerAndReturnDeposit(uid);
return new ApiResponse();
}
/**
* 入驻商户的状态
* 芝麻认证状态
* 入驻状态
*/
@RequestMapping(params = "method=ufo.sellerOrder.entryStatus")
@ResponseBody
public ApiResponse entryStatus(@RequestParam("uid") Integer uid) throws GatewayException {
logger.info("enter StoredSellerController entryStatus param uid is {}", uid);
//(1) 优先校验请求的参数
if (uid == null || uid <=0 ){
throw new GatewayException(400, "参数错误,uid不存在!");
}
SellerResp map = storedSellerService.entryStatus(uid);
ApiResponse apiResponse = new ApiResponse();
apiResponse.setData(map);
return apiResponse;
}
/**
* 是否入驻商户
*/
@RequestMapping(params = "method=ufo.sellerOrder.isStoredSeller")
@ResponseBody
public ApiResponse isStoredSeller(@RequestParam("uid") Integer uid) throws GatewayException {
logger.info("enter StoredSellerController isStoredSeller param uid is {}", uid);
//(1) 优先校验请求的参数
if (uid == null || uid <=0 ){
throw new GatewayException(400, "参数错误,uid不存在!");
}
boolean isStoredSeller=storedSellerService.isStoredSeller(uid);
ApiResponse apiResponse = new ApiResponse();
apiResponse.setData(isStoredSeller);
return apiResponse;
}
@RequestMapping(params = "method=ufo.seller.entryThresholds")
@ResponseBody
public ApiResponse getEntryThresholds() {
Map<EntrySellerType,EntryThreshold> data = sellerService.getEntryThreshold();
logger.info("enter ufo.seller.entryThresholds data {}", data);
return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("升级预充值阈值").build();
}
}
... ...
... ... @@ -354,6 +354,20 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
}
return buildOrderInfo(buyerOrder);
}
public BigDecimal getWalletLeftAmount(Integer uid){
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
BigDecimal defaultLeft = BigDecimal.ZERO;
if (sw == null) {
logger.warn("getWalletLeftAmount SellerWallet not exist uid {}", uid);
return defaultLeft;
}
if (sw.getStatus() == null || sw.getStatus() == 0) {
logger.warn("getWalletLeftAmount SellerWallet cannot use uid {}", uid);
return defaultLeft;
}
return sw.getAmount().add(sw.getLockAmount());
}
public com.yohoufo.common.ApiResponse getMerchantWalletInfo(Integer uid) {
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
... ...
... ... @@ -10,6 +10,7 @@ import com.yohoufo.dal.order.model.StoredSeller;
import com.yohoufo.dal.order.model.SuperEntrySeller;
import com.yohoufo.order.common.SurperEntrySellerStatus;
import com.yohoufo.order.service.IStoredSellerService;
import com.yohoufo.order.service.MerchantOrderPaymentService;
import com.yohoufo.order.service.cache.StoredSellerCacheService;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.user.cache.CacheKeyEnum;
... ... @@ -47,6 +48,9 @@ public class SellerService {
@Autowired
private StoredSellerMapper storedSellerMapper;
@Autowired
private MerchantOrderPaymentService merchantOrderPaymentService;
/**更低出价提醒
* 1)当有新卖家出价成功或调价成功时,给所有正在出售该sku(尺码)的其他卖家推送一条消息(push+消息盒子)
*2)同一卖家的同一SKU 1小时内仅推送一条提醒(最先推送的那条)
... ... @@ -197,5 +201,15 @@ public class SellerService {
return map;
}
public Boolean applySuperEnter(Integer uid){
BigDecimal leftInWallet = merchantOrderPaymentService.getWalletLeftAmount(uid);
//TODO 前提:1. 当前卖家是 普通个人 or 入驻非超级 2. 钱包余额大于等于超级的阈值
Map<EntrySellerType,EntryThreshold> entryThreshold = getEntryThreshold();
EntryThreshold set = entryThreshold.get(EntrySellerType.SUPER_ENTRY);
boolean isFatWallet = leftInWallet.compareTo(set.getPrepaymentAmount()) >= 0;
logger.info("applySuperEnter uid {} leftInWallet {} super EntryThreshold {} isFatWallet {}",
uid, leftInWallet, set, isFatWallet);
//TODO 申请记录(新增 or 修改) 入驻卖家(enter_type level_func 功能菜单)
return isFatWallet;
}
}
... ...