Commit d1a4fca3 by xiaoer.li@freemud.com

增加混合支付开关

parent 9d45ef7a
package cn.freemud.entities.dto;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.entities.dto SvcComPayRequestDto
* @Description: TDO 描述....
* @author: 铁牌灵魂工程师
* @date: 2020/11/27
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
@NoArgsConstructor
public class SvcComPayRequestDto {
private String partnerId;
private String storeId;
}
package cn.freemud.entities.dto;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.entities.dto SvcComPayResoonseDto
* @Description: TDO 描述....
* @author: 铁牌灵魂工程师
* @date: 2020/11/27
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
@NoArgsConstructor
public class SvcComPayResponseDto {
private Integer code;
private String message;
private Result result;
@Data
@NoArgsConstructor
static public class Result {
private Boolean value;
}
}
......@@ -266,6 +266,8 @@ public class OrderServiceImpl implements Orderservice {
@Autowired
private AssortmentOpenPlatformIappWxappStoreManager assortmentOpenPlatformIappWxappStoreManager;
@Autowired
private SvcComPayClient svcComPayClient;
@Override
public BaseResponse checkBeforeCreateOrder(CheckBeforeCreateOrderRequestVo requestVo) {
String trackingNo = LogTreadLocal.getTrackingNo();
......@@ -2320,11 +2322,10 @@ public class OrderServiceImpl implements Orderservice {
, String storeId
, String trackingNo) {
boolean tigger = false;
OrderPayResponse orderPayResponse = new OrderPayResponse();
tigger = true;
boolean check = this.checkSvcComPay(orderBean.getCompanyId(), orderBean.getShopId());
//混合支付
if (tigger && StringUtils.isNotBlank(channel)) {
if (check && StringUtils.isNotBlank(channel)) {
log.info("混合支付:");
String partnerPayOvertime = this.getPartnerPayOvertime(orderBean.getCompanyId());
orderPayResponse = comPayOrder(cardCode,orderBean,paymentRequest,partnerPayOvertime,totalAmount.intValue(),channel,storeId,LogThreadLocal.getTrackingNo());
......@@ -3338,4 +3339,28 @@ public class OrderServiceImpl implements Orderservice {
// // TODO: 2019/9/10 hubowen mq推送变更
// backOrdersStatusChange(orderBean.getOid(), orderBean.getStatus());
//}
/**
* 获取混合支付是否开启
* @param partnerId
* @return
*/
private boolean checkSvcComPay(String partnerId,String storeId) {
SvcComPayRequestDto requestDto = new SvcComPayRequestDto();
requestDto.setPartnerId(partnerId);
requestDto.setStoreId(storeId);
SvcComPayResponseDto query = null;
for (int i=0;i<3;i++) {
query = svcComPayClient.query(requestDto);
if (query!=null) break;
}
if (query==null || !ResponseResult.SUCCESS.getCode().equals(query.getCode())) {
return false;
}
if (partnerId.equals(query.getResult().getValue())) {
return true;
}
else {
return false;
}
}
}
package cn.freemud.service.thirdparty;
import cn.freemud.entities.dto.SvcComPayRequestDto;
import cn.freemud.entities.dto.SvcComPayResponseDto;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.service.thirdparty SvcClient
* @Description: TDO 描述....
* @author: 铁牌灵魂工程师
* @date: 2020/11/27
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@FeignClient(name="payment-center-management", url = "${saas.svc.switch.feign.url}")
@RequestMapping(produces = {"application/json;charset=UTF-8"})
public interface SvcComPayClient {
@PostMapping("/paymentmanager/partnerSetting/queryAssociationPaymentFlagPartnerSetting")
SvcComPayResponseDto query(SvcComPayRequestDto svcComPayRequestDto);
}
package cn.freemud.entities.dto;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.entities.dto SvcComPayRequestDto
* @Description: TDO 描述....
* @author: 铁牌灵魂工程师
* @date: 2020/11/27
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
@NoArgsConstructor
public class SvcComPayRequestDto {
private String partnerId;
private String storeId;
}
package cn.freemud.entities.dto;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.entities.dto SvcComPayResoonseDto
* @Description: TDO 描述....
* @author: 铁牌灵魂工程师
* @date: 2020/11/27
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
@NoArgsConstructor
public class SvcComPayResponseDto {
private Integer code;
private String message;
private Result result;
@Data
@NoArgsConstructor
static public class Result {
private Boolean value;
}
}
......@@ -151,6 +151,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
private ActivityService activityService;
@Autowired
private RedisCache redisCache;
@Autowired
private SvcComPayClient svcComPayClient;
private static final String limitCartKey = "ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_";
......@@ -1643,30 +1645,49 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (response.getData() == null || response.getData().getData() == null || response.getData().getData().getCardSimpleInfos().size() > 1) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_ERROR);
}
//混合支付无需校验svc卡余额,但是配送和包装费不计算在svc卡支付
Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getData().getData().getCardSimpleInfos().get(0).getVamount();
Integer svcTotalAmount = amount1+vamount;
//获取实际配送费
Integer deliveryAmount = 0;
Integer svcPayAmount = 0;
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
//Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId);
deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
orderAmount += deliveryAmount;
}
if (svcTotalAmount>0 && svcTotalAmount>orderAmount) {
svcPayAmount = orderAmount;
shoppingCartGoodsResponseVo.setTotalAmount(0L);
boolean check = this.checkSvcComPay(partnerId, storeId);
if (check) {
//混合支付无需校验svc卡余额,但是配送和包装费不计算在svc卡支付
Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getData().getData().getCardSimpleInfos().get(0).getVamount();
Integer svcTotalAmount = amount1+vamount;
//获取实际配送费
Integer deliveryAmount = 0;
Integer svcPayAmount = 0;
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
//Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId);
deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
orderAmount += deliveryAmount;
}
if (svcTotalAmount>0 && svcTotalAmount>orderAmount) {
svcPayAmount = orderAmount;
shoppingCartGoodsResponseVo.setTotalAmount(0L);
}
else if (svcTotalAmount>0 && svcTotalAmount<=orderAmount) {
svcPayAmount = svcTotalAmount;
shoppingCartGoodsResponseVo.setTotalAmount((orderAmount.longValue()-svcPayAmount.longValue()));
}
BigDecimal bigDecimal = new BigDecimal(svcPayAmount);
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setSvcPayAmount(amountStr);
shoppingCartGoodsResponseVo.setSvcDiscountDesc("储值卡支付¥" + amountStr);
}
else if (svcTotalAmount>0 && svcTotalAmount<=orderAmount) {
svcPayAmount = svcTotalAmount;
shoppingCartGoodsResponseVo.setTotalAmount((orderAmount.longValue()-svcPayAmount.longValue()));
else {
//获取实际配送费
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
Integer deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
orderAmount += deliveryAmount;
}
Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getData().getData().getCardSimpleInfos().get(0).getVamount();
if (orderAmount > amount1 + vamount) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_AMOUNT_DEFICIENCY);
}
BigDecimal bigDecimal = new BigDecimal(orderAmount);
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setTotalAmount(0L);
shoppingCartGoodsResponseVo.setSvcDiscountDesc("储值卡支付¥" + amountStr);
}
BigDecimal bigDecimal = new BigDecimal(svcPayAmount);
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setSvcPayAmount(amountStr);
shoppingCartGoodsResponseVo.setSvcDiscountDesc("储值卡支付¥" + amountStr);
}
/**
......@@ -2049,4 +2070,28 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
/**
* 获取混合支付是否开启
* @param partnerId
* @return
*/
private boolean checkSvcComPay(String partnerId,String storeId) {
SvcComPayRequestDto requestDto = new SvcComPayRequestDto();
requestDto.setPartnerId(partnerId);
requestDto.setStoreId(storeId);
SvcComPayResponseDto query = null;
for (int i=0;i<3;i++) {
query = svcComPayClient.query(requestDto);
if (query!=null) break;
}
if (query==null || !ResponseResult.SUCCESS.getCode().equals(query.getCode())) {
return false;
}
if (partnerId.equals(query.getResult().getValue())) {
return true;
}
else {
return false;
}
}
}
package cn.freemud.service.thirdparty;
import cn.freemud.entities.dto.SvcComPayRequestDto;
import cn.freemud.entities.dto.SvcComPayResponseDto;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.service.thirdparty SvcClient
* @Description: TDO 描述....
* @author: 铁牌灵魂工程师
* @date: 2020/11/27
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@FeignClient(name="payment-center-management", url = "${saas.svc.switch.feign.url}")
@RequestMapping(produces = {"application/json;charset=UTF-8"})
public interface SvcComPayClient {
@PostMapping("/paymentmanager/partnerSetting/queryAssociationPaymentFlagPartnerSetting")
SvcComPayResponseDto query(SvcComPayRequestDto svcComPayRequestDto);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment