fix
parent
289f48ef2d
commit
7dde841e14
|
|
@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author liangyq
|
* @author liangyq
|
||||||
|
|
@ -37,8 +38,11 @@ public class ExpressController extends XktBaseController {
|
||||||
@ApiOperation("下单时物流选择列表 - 含快递费")
|
@ApiOperation("下单时物流选择列表 - 含快递费")
|
||||||
@PostMapping("listExpressFee")
|
@PostMapping("listExpressFee")
|
||||||
public R<List<ExpressFeeVO>> listExpressFee(@Valid @RequestBody ExpressFeeReqVO vo) {
|
public R<List<ExpressFeeVO>> listExpressFee(@Valid @RequestBody ExpressFeeReqVO vo) {
|
||||||
List<ExpressFeeDTO> dtoList = expressService.listExpressFee(vo.getGoodsQuantity(), vo.getProvinceCode(),
|
List<ExpressFeeDTO> dtoList = expressService.listExpressFee(
|
||||||
vo.getCityCode(), vo.getCountyCode());
|
Optional.ofNullable(vo.getGoodsQuantity()).orElse(1),
|
||||||
|
vo.getProvinceCode(),
|
||||||
|
vo.getCityCode(), vo.getCountyCode()
|
||||||
|
);
|
||||||
return success(BeanUtil.copyToList(dtoList, ExpressFeeVO.class));
|
return success(BeanUtil.copyToList(dtoList, ExpressFeeVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@ import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物流信息
|
* 物流信息
|
||||||
*
|
*
|
||||||
|
|
@ -17,19 +14,15 @@ import javax.validation.constraints.NotNull;
|
||||||
@Data
|
@Data
|
||||||
public class ExpressFeeReqVO {
|
public class ExpressFeeReqVO {
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@ApiModelProperty(value = "商品数量")
|
@ApiModelProperty(value = "商品数量")
|
||||||
private Integer goodsQuantity;
|
private Integer goodsQuantity;
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
@ApiModelProperty(value = "省编码")
|
@ApiModelProperty(value = "省编码")
|
||||||
private String provinceCode;
|
private String provinceCode;
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
@ApiModelProperty(value = "市编码")
|
@ApiModelProperty(value = "市编码")
|
||||||
private String cityCode;
|
private String cityCode;
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
@ApiModelProperty(value = "区县编码")
|
@ApiModelProperty(value = "区县编码")
|
||||||
private String countyCode;
|
private String countyCode;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public class StoreOrderAddReqVO {
|
||||||
private Integer payChannel;
|
private Integer payChannel;
|
||||||
|
|
||||||
@NotNull(message = "支付来源不能为空")
|
@NotNull(message = "支付来源不能为空")
|
||||||
@ApiModelProperty(value = "支付来源[1:电脑网站 2:手机网站]")
|
@ApiModelProperty(value = "支付来源[1:电脑网站 2:手机网站 3:APP]")
|
||||||
private Integer payPage;
|
private Integer payPage;
|
||||||
|
|
||||||
@ApiModel(value = "明细")
|
@ApiModel(value = "明细")
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ public enum EPayPage {
|
||||||
|
|
||||||
WEB(1, "电脑网站"),
|
WEB(1, "电脑网站"),
|
||||||
WAP(2, "手机网站"),
|
WAP(2, "手机网站"),
|
||||||
|
APP(3, "APP"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final Integer value;
|
private final Integer value;
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,7 @@ import com.alipay.api.domain.AlipayTradeQueryModel;
|
||||||
import com.alipay.api.domain.AlipayTradeRefundModel;
|
import com.alipay.api.domain.AlipayTradeRefundModel;
|
||||||
import com.alipay.api.domain.Participant;
|
import com.alipay.api.domain.Participant;
|
||||||
import com.alipay.api.request.*;
|
import com.alipay.api.request.*;
|
||||||
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
import com.alipay.api.response.*;
|
||||||
import com.alipay.api.response.AlipayTradeQueryResponse;
|
|
||||||
import com.alipay.api.response.AlipayTradeRefundResponse;
|
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.xkt.domain.StoreOrderDetail;
|
import com.ruoyi.xkt.domain.StoreOrderDetail;
|
||||||
import com.ruoyi.xkt.dto.finance.AlipayReqDTO;
|
import com.ruoyi.xkt.dto.finance.AlipayReqDTO;
|
||||||
|
|
@ -41,7 +39,9 @@ import java.math.BigDecimal;
|
||||||
public class AliPaymentMangerImpl implements PaymentManager {
|
public class AliPaymentMangerImpl implements PaymentManager {
|
||||||
|
|
||||||
private static final String DEFAULT_FORMAT = "json";
|
private static final String DEFAULT_FORMAT = "json";
|
||||||
private static final String PAY_PRODUCT_CODE = "FAST_INSTANT_TRADE_PAY";
|
private static final String PAY_PRODUCT_CODE_WEB = "FAST_INSTANT_TRADE_PAY";
|
||||||
|
private static final String PAY_PRODUCT_CODE_WAP = "QUICK_WAP_WAY";
|
||||||
|
private static final String PAY_PRODUCT_CODE_APP = "QUICK_MSECURITY_PAY";
|
||||||
/**
|
/**
|
||||||
* 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号
|
* 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号
|
||||||
*/
|
*/
|
||||||
|
|
@ -98,36 +98,68 @@ public class AliPaymentMangerImpl implements PaymentManager {
|
||||||
reqDTO.setOutTradeNo(tradeNo);
|
reqDTO.setOutTradeNo(tradeNo);
|
||||||
reqDTO.setTotalAmount(amount.toPlainString());
|
reqDTO.setTotalAmount(amount.toPlainString());
|
||||||
reqDTO.setSubject(subject);
|
reqDTO.setSubject(subject);
|
||||||
reqDTO.setProductCode(PAY_PRODUCT_CODE); //这个是固定的
|
|
||||||
String reqStr = JSON.toJSONString(reqDTO);
|
|
||||||
AlipayClient alipayClient = new DefaultAlipayClient(gatewayUrl, appId, privateKey, DEFAULT_FORMAT, charset,
|
AlipayClient alipayClient = new DefaultAlipayClient(gatewayUrl, appId, privateKey, DEFAULT_FORMAT, charset,
|
||||||
alipayPublicKey, signType);
|
alipayPublicKey, signType);
|
||||||
switch (payPage) {
|
switch (payPage) {
|
||||||
case WEB:
|
case WEB:
|
||||||
|
reqDTO.setProductCode(PAY_PRODUCT_CODE_WEB);
|
||||||
AlipayTradePagePayRequest webReq = new AlipayTradePagePayRequest();
|
AlipayTradePagePayRequest webReq = new AlipayTradePagePayRequest();
|
||||||
webReq.setReturnUrl(returnUrl);
|
webReq.setReturnUrl(returnUrl);
|
||||||
webReq.setNotifyUrl(notifyUrl);
|
webReq.setNotifyUrl(notifyUrl);
|
||||||
webReq.setBizContent(reqStr);
|
webReq.setBizContent(JSON.toJSONString(reqDTO));
|
||||||
try {
|
try {
|
||||||
return alipayClient.pageExecute(webReq).getBody();
|
AlipayTradePagePayResponse webResp = alipayClient.pageExecute(webReq);
|
||||||
|
if (webResp.isSuccess()) {
|
||||||
|
return webResp.getBody();
|
||||||
|
}else {
|
||||||
|
String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(webResp);
|
||||||
|
log.error("支付发起失败: {}", diagnosisUrl);
|
||||||
|
}
|
||||||
} catch (AlipayApiException e) {
|
} catch (AlipayApiException e) {
|
||||||
log.error("支付发起异常", e);
|
log.error("WEB支付发起异常", e);
|
||||||
throw new ServiceException("支付发起失败");
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case WAP:
|
case WAP:
|
||||||
|
reqDTO.setProductCode(PAY_PRODUCT_CODE_WAP);
|
||||||
AlipayTradeWapPayRequest wapReq = new AlipayTradeWapPayRequest();
|
AlipayTradeWapPayRequest wapReq = new AlipayTradeWapPayRequest();
|
||||||
wapReq.setReturnUrl(returnUrl);
|
wapReq.setReturnUrl(returnUrl);
|
||||||
wapReq.setNotifyUrl(notifyUrl);
|
wapReq.setNotifyUrl(notifyUrl);
|
||||||
wapReq.setBizContent(reqStr);
|
wapReq.setBizContent(JSON.toJSONString(reqDTO));
|
||||||
try {
|
try {
|
||||||
return alipayClient.pageExecute(wapReq).getBody();
|
AlipayTradeWapPayResponse wapResp = alipayClient.pageExecute(wapReq);
|
||||||
|
if (wapResp.isSuccess()) {
|
||||||
|
return wapResp.getBody();
|
||||||
|
}else {
|
||||||
|
String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(wapResp);
|
||||||
|
log.error("支付发起失败: {}", diagnosisUrl);
|
||||||
|
}
|
||||||
} catch (AlipayApiException e) {
|
} catch (AlipayApiException e) {
|
||||||
log.error("支付发起异常", e);
|
log.error("WAP支付发起异常", e);
|
||||||
throw new ServiceException("支付发起失败");
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case APP:
|
||||||
|
reqDTO.setProductCode(PAY_PRODUCT_CODE_APP);
|
||||||
|
AlipayTradeAppPayRequest appReq = new AlipayTradeAppPayRequest();
|
||||||
|
appReq.setReturnUrl(returnUrl);
|
||||||
|
appReq.setNotifyUrl(notifyUrl);
|
||||||
|
appReq.setBizContent(JSON.toJSONString(reqDTO));
|
||||||
|
try {
|
||||||
|
AlipayTradeAppPayResponse appResp = alipayClient.sdkExecute(appReq);
|
||||||
|
if (appResp.isSuccess()) {
|
||||||
|
return appResp.getBody();
|
||||||
|
} else {
|
||||||
|
String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(appResp);
|
||||||
|
log.error("支付发起失败: {}", diagnosisUrl);
|
||||||
|
}
|
||||||
|
} catch (AlipayApiException e) {
|
||||||
|
log.error("APP支付发起异常", e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ServiceException("未知的支付来源");
|
throw new ServiceException("未知的支付来源");
|
||||||
}
|
}
|
||||||
|
throw new ServiceException("支付发起失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,11 @@ public class ExpressServiceImpl implements IExpressService {
|
||||||
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED));
|
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED));
|
||||||
return expresses.stream().map(e -> {
|
return expresses.stream().map(e -> {
|
||||||
ExpressFeeDTO dto = BeanUtil.toBean(e, ExpressFeeDTO.class);
|
ExpressFeeDTO dto = BeanUtil.toBean(e, ExpressFeeDTO.class);
|
||||||
|
if (StrUtil.isEmpty(provinceCode)
|
||||||
|
|| StrUtil.isEmpty(cityCode)
|
||||||
|
|| StrUtil.isEmpty(countyCode)) {
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
ExpressFeeConfig feeConfig = getExpressFeeConfig(e.getId(), provinceCode, cityCode, countyCode);
|
ExpressFeeConfig feeConfig = getExpressFeeConfig(e.getId(), provinceCode, cityCode, countyCode);
|
||||||
Assert.notNull(feeConfig, "获取快递费用异常");
|
Assert.notNull(feeConfig, "获取快递费用异常");
|
||||||
BigDecimal fee;
|
BigDecimal fee;
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,13 @@ public class UserAddressServiceImpl implements IUserAddressService {
|
||||||
@Override
|
@Override
|
||||||
public void deleteUserAddress(Long id) {
|
public void deleteUserAddress(Long id) {
|
||||||
Assert.notNull(id);
|
Assert.notNull(id);
|
||||||
|
UserAddress origin = userAddressMapper.selectById(id);
|
||||||
|
if (origin == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
UserAddress userAddress = new UserAddress();
|
UserAddress userAddress = new UserAddress();
|
||||||
userAddress.setId(id);
|
userAddress.setId(id);
|
||||||
|
userAddress.setVersion(origin.getVersion());
|
||||||
userAddress.setDelFlag(Constants.DELETED);
|
userAddress.setDelFlag(Constants.DELETED);
|
||||||
userAddressMapper.updateById(userAddress);
|
userAddressMapper.updateById(userAddress);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue