...
|
...
|
@@ -8,8 +8,11 @@ import com.yoho.core.transaction.annoation.TxCompensateArgs; |
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohoufo.common.ApiResponse;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import lombok.Data;
|
|
|
import lombok.ToString;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.math.BigDecimal;
|
...
|
...
|
@@ -22,7 +25,13 @@ import java.util.Objects; |
|
|
|
|
|
|
|
|
@Component
|
|
|
public class BargainProxyService extends AbsServiceCaller implements Compensator {
|
|
|
public class BargainProxyService implements Compensator {
|
|
|
|
|
|
private final static Logger logger = LoggerUtils.getBuyerOrderLogger();
|
|
|
|
|
|
@Autowired
|
|
|
private BaseServiceCaller baseServiceCaller;
|
|
|
|
|
|
/**
|
|
|
* 获取用户砍价商品的最终价格
|
|
|
* 所有的业务校验都在activity服务端实现,如活动时间、是否达成
|
...
|
...
|
@@ -33,12 +42,12 @@ public class BargainProxyService extends AbsServiceCaller implements Compensator |
|
|
*/
|
|
|
public CutDownPriceProductOrderBo queryCutPriceProductForOrder(int uid, int cutRecordId) {
|
|
|
logger.info("getActivityPrice by uid {},cutRecordId {}", uid, cutRecordId);
|
|
|
String url = erpGatewayUrl + "/erp/activity/cutPrice/queryCutPriceProductForOrder";
|
|
|
String url = baseServiceCaller.getErpGatewayUrl() + "/erp/activity/cutPrice/queryCutPriceProductForOrder";
|
|
|
CutPriceHelpUserRequestBO requestBO = new CutPriceHelpUserRequestBO();
|
|
|
requestBO.setUserId(uid);
|
|
|
requestBO.setCutRecordId(cutRecordId);
|
|
|
ApiResponse response = proxyPost("activity.queryCutPriceProductForOrder", url, requestBO);
|
|
|
CutDownPriceProductOrderBo cutDownPriceProductOrderBo = getResultFromApiResponse(response, CutDownPriceProductOrderBo.class);
|
|
|
ApiResponse response = baseServiceCaller.proxyPost("activity.queryCutPriceProductForOrder", url, requestBO);
|
|
|
CutDownPriceProductOrderBo cutDownPriceProductOrderBo = baseServiceCaller.getResultFromApiResponse(response, CutDownPriceProductOrderBo.class);
|
|
|
if (Objects.isNull(cutDownPriceProductOrderBo)) {
|
|
|
logger.warn("can't getActivityPrice by uid {},cutRecordId {}", uid, cutRecordId);
|
|
|
throw new UfoServiceException(500, "未查询到用户砍价商品信息");
|
...
|
...
|
@@ -59,12 +68,12 @@ public class BargainProxyService extends AbsServiceCaller implements Compensator |
|
|
public void addCutPriceUseRecord(@TxCompensateArgs("uid") int uid, @TxCompensateArgs("orderCode") long orderCode,
|
|
|
@TxCompensateArgs("cutRecordId") int cutRecordId) throws ServiceException {
|
|
|
logger.debug("addCutPriceUseRecord by uid {},cutRecordId {},orderCode {}", uid, cutRecordId, orderCode);
|
|
|
String url = erpGatewayUrl + "/erp/activity/cutPrice/addCutPriceUseRecord";
|
|
|
String url = baseServiceCaller.getErpGatewayUrl() + "/erp/activity/cutPrice/addCutPriceUseRecord";
|
|
|
CutPriceHelpUserRequestBO requestBO = new CutPriceHelpUserRequestBO();
|
|
|
requestBO.setUserId(uid);
|
|
|
requestBO.setCutRecordId(cutRecordId);
|
|
|
requestBO.setOrderCode(orderCode);
|
|
|
ApiResponse response = proxyPost("activity.addCutPriceUseRecord", url, requestBO);
|
|
|
ApiResponse response = baseServiceCaller.proxyPost("activity.addCutPriceUseRecord", url, requestBO);
|
|
|
logger.info("addCutPriceUseRecord(uid:{},cutRecordId:{},orderCode:{}),result is {}",
|
|
|
uid, cutRecordId, orderCode, response);
|
|
|
if (response == null || response.getCode() != 200) {
|
...
|
...
|
@@ -86,12 +95,12 @@ public class BargainProxyService extends AbsServiceCaller implements Compensator |
|
|
*/
|
|
|
public void cancelCutPriceUseRecord(int uid, long orderCode, int cutRecordId) throws ServiceException {
|
|
|
logger.debug("cancelCutPriceUseRecord by uid {},orderCode {},cutRecordId {}", uid, orderCode, cutRecordId);
|
|
|
String url = erpGatewayUrl + "/erp/activity/cutPrice/cancelCutPriceUseRecord";
|
|
|
String url = baseServiceCaller.getErpGatewayUrl() + "/erp/activity/cutPrice/cancelCutPriceUseRecord";
|
|
|
CutPriceHelpUserRequestBO requestBO = new CutPriceHelpUserRequestBO();
|
|
|
requestBO.setUserId(uid);
|
|
|
requestBO.setCutRecordId(cutRecordId);
|
|
|
requestBO.setOrderCode(orderCode);
|
|
|
ApiResponse response = proxyPost("activity.cancelCutPriceUseRecord", url, requestBO);
|
|
|
ApiResponse response = baseServiceCaller.proxyPost("activity.cancelCutPriceUseRecord", url, requestBO);
|
|
|
logger.info("cancelCutPriceUseRecord(uid:{},cutRecordId:{},orderCode:{}),result is {}", uid, cutRecordId, orderCode, response);
|
|
|
if (response != null && response.getCode() == 200) {
|
|
|
logger.info("[{}] cancelCutPriceUseRecord success,cutRecordId {}", orderCode, cutRecordId);
|
...
|
...
|
@@ -111,12 +120,12 @@ public class BargainProxyService extends AbsServiceCaller implements Compensator |
|
|
*/
|
|
|
public void payCutPrice(int uid, long orderCode, int cutRecordId) throws ServiceException {
|
|
|
logger.debug("payCutPrice by uid {},orderCode {},cutRecordId {}", uid, orderCode, cutRecordId);
|
|
|
String url = erpGatewayUrl + "/erp/activity/cutPrice/payCutPrice";
|
|
|
String url = baseServiceCaller.getErpGatewayUrl() + "/erp/activity/cutPrice/payCutPrice";
|
|
|
CutPriceHelpUserRequestBO requestBO = new CutPriceHelpUserRequestBO();
|
|
|
requestBO.setUserId(uid);
|
|
|
requestBO.setCutRecordId(cutRecordId);
|
|
|
requestBO.setOrderCode(orderCode);
|
|
|
ApiResponse response = proxyPost("activity.payCutPrice", url, requestBO);
|
|
|
ApiResponse response = baseServiceCaller.proxyPost("activity.payCutPrice", url, requestBO);
|
|
|
logger.info("payCutPrice(uid:{},cutRecordId:{},orderCode:{}),result is {}", uid, cutRecordId, orderCode, response);
|
|
|
if (response != null && response.getCode() == 200) {
|
|
|
logger.info("[{}] payCutPrice success,cutRecordId {}", orderCode, cutRecordId);
|
...
|
...
|
|