记得上下班打卡 | git大法好,push需谨慎

Commit dfde97a2 authored by 胡佳晨's avatar 胡佳晨

order 下单接口修改

根据adcode 获取快递价格接口修改
parent b01285ef
......@@ -26,15 +26,10 @@ public class PayOrderParam {
@NotNull(message = "数量不能为空")
@Min(value = 1,message = "数量不能小于0")
private Integer number;
// @ApiModelProperty(value = "是否学生票")
// @NotNull(message = "必传")
// private Integer isStudent;
@ApiModelProperty(value = "是否电子票")
private Integer isElectronic;
@ApiModelProperty(value = "是否快递票")
private Integer isExpress;
@ApiModelProperty(value = "收货地址id")
private String addressId;
@ApiModelProperty(value = "入场人id数组")
......@@ -42,13 +37,9 @@ public class PayOrderParam {
@ApiModelProperty(value = "代理id")
@NotNull(message = "代理ID不能为空")
private String agentId;
@ApiModelProperty(value = "快递类型 1寄付 2到付")
@ApiModelProperty(value = "快递类型[0无类型|1寄付|2到付|3包邮]")
@NotNull(message = "快递方式不能为空")
@Max(value = 2, message = "快递方式无效")
@Min(value = 1, message = "快递方式无效")
private Integer expressType;
@ApiModelProperty(value = "支付类型")
@NotNull(message = "支付类型不能为空")
private String payType;
......@@ -61,11 +52,14 @@ public class PayOrderParam {
private String showUrl;
@ApiModelProperty(value = "returnUrl")
private String returnUrl;
@ApiModelProperty(value = "优惠券类型")
private Integer voucherType;
@ApiModelProperty(value = "优惠券码")
private String voucherCode;
@ApiModelProperty(value = "会员提前券码")
private String advanceCode;
@ApiModelProperty(value = "收货地址adCode")
private String adCode;
@ApiModelProperty(value = "快递方式productCode")
private String productCode;
}
package com.liquidnet.service.kylin.controller;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.dao.KylinFreightChargeDao;
import io.swagger.annotations.Api;
......@@ -18,21 +18,19 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class KylinGetShunFengPriceController {
@Autowired
private RedisDataSourceUtil redisDataSourceUtil;
@Autowired
private RedisUtil redisUtil;
@GetMapping("getPrice")
@ApiOperation("运费查询")
public String getFreightCharge(String adcode,String expressType){
public ResponseDto<String> getFreightCharge(String adcode, String productCode) {
Object obj =redisUtil.get(KylinRedisConst.RETURN_ADDRESS_CODE+adcode+KylinRedisConst.EXPRESS_TYPE+expressType);
if (obj != null){
KylinFreightChargeDao k= (KylinFreightChargeDao)obj;
return k.getPrice();
}else {
return null;
Object obj = redisUtil.get(KylinRedisConst.RETURN_ADDRESS_CODE + adcode + KylinRedisConst.EXPRESS_TYPE + productCode);
if (obj != null) {
KylinFreightChargeDao k = (KylinFreightChargeDao) obj;
return ResponseDto.success(k.getPrice());
} else {
return ResponseDto.failure();
}
}
......
......@@ -146,6 +146,12 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
if (!checkAgent(payOrderParam.getAgentId(), ticketData)) {
return ResponseDto.failure(ErrorMapping.get("20008"));//无权购买
}
//校验快递相关参数
if (payOrderParam.getIsExpress() == 1) {
if (payOrderParam.getAdCode() == null || payOrderParam.getProductCode() == null) {
return ResponseDto.failure(ErrorMapping.get("20004"));//参数错误
}
}
String time1 = DateUtil.format(DateUtil.Formatter.yyyyMMddHHmmss.parse(ticketData.getUseStart()), DateUtil.Formatter.MM_dd_zh);
String time2 = DateUtil.format(DateUtil.Formatter.yyyyMMddHHmmss.parse(ticketData.getUseEnd()), DateUtil.Formatter.MM_dd_zh);
......@@ -395,6 +401,13 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
orderTickets.setPrice(ticketData.getPrice());
orderTickets.setPriceMember(ticketData.getMemberPrice());
BigDecimal priceExpress = BigDecimal.ZERO;
if (payOrderParam.getIsExpress() == 1) {
String productCode = payOrderParam.getProductCode();
String adCode = payOrderParam.getAdCode();
priceExpress = orderUtils.getExpressPrice(adCode, productCode);
}
if (payOrderParam.getVoucherType() != null) {
orderTickets.setCouponType(payOrderParam.getVoucherType().equals(3) ? "exchange" : "no");
} else {
......@@ -428,7 +441,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
}
if (payOrderParam.getVoucherCode() != null) {
HashMap<String, Object> hashMap = orderUtils.useCoupon(payOrderParam.getVoucherCode(), content, orderTickets.getPriceTotal(), payOrderParam.getPerformanceId(), payOrderParam.getTimeId(), payOrderParam.getTicketId());
HashMap<String, Object> hashMap = orderUtils.useCoupon(payOrderParam.getVoucherCode(), content, orderTickets.getPriceTotal().subtract(priceExpress), payOrderParam.getPerformanceId(), payOrderParam.getTimeId(), payOrderParam.getTicketId());
BigDecimal priceVoucher = (BigDecimal) hashMap.get("voucher");
Integer typeVoucher = (Integer) hashMap.get("type");
if (typeVoucher.equals(-1)) {
......@@ -455,7 +468,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
BigDecimal finalPrice = orderTickets.getPriceTotal().subtract(orderTickets.getPriceVoucher());
orderTickets.setPriceActual(finalPrice.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO : finalPrice);
orderTickets.setPriceExpress(payOrderParam.getIsExpress() == 1 ? ticketData.getPriceExpress() : BigDecimal.valueOf(0));
orderTickets.setPriceExpress(priceExpress);
orderTickets.setPriceRefund(BigDecimal.valueOf(0.0));
orderTickets.setRefundNumber(0);
orderTickets.setPayType(payOrderParam.getPayType());
......
......@@ -37,6 +37,8 @@ public class OrderUtils {
private String candyUrl;
@Value("${liquidnet.service.stone.url}")
private String stoneUrl;
@Value("${liquidnet.service.kylin.url}")
private String kylinUrl;
public String judgeOrderLimit(
int type,
......@@ -138,13 +140,13 @@ public class OrderUtils {
return surplusGeneral;
}
public void doTask(String uid,String title,BigDecimal price) {
public void doTask(String uid, String title, BigDecimal price) {
try {
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Accept", "application/json;charset=UTF-8");
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("score", price.intValue()+"");
params.add("content", "购买演出:"+title);
params.add("score", price.intValue() + "");
params.add("content", "购买演出:" + title);
params.add("uid", uid);
String resultData = HttpUtil.post(stoneUrl + "/user/logs/in2111", params, header);
} catch (Exception e) {
......@@ -153,7 +155,7 @@ public class OrderUtils {
}
}
public AdamRscPolymer01Vo adamAddressEnterMember(String uid,String enterIds,String addressId) {
public AdamRscPolymer01Vo adamAddressEnterMember(String uid, String enterIds, String addressId) {
try {
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Accept", "application/json;charset=UTF-8");
......@@ -267,8 +269,8 @@ public class OrderUtils {
hashMap.put("type", type);
hashMap.put("voucher", voucher.setScale(2, BigDecimal.ROUND_HALF_UP));
return hashMap;
}catch (Exception e){
log.error("用券ERROR:{}",e);
} catch (Exception e) {
log.error("用券ERROR:{}", e);
hashMap.put("type", -1);
hashMap.put("voucher", -1);
return hashMap;
......@@ -294,8 +296,22 @@ public class OrderUtils {
params.add(param);
String jsonString = JSON.toJSONString(params);
String returnData = HttpUtil.postRaw(candyUrl + "/candy-coupon/useBack", jsonString, header);
}catch (Exception e){
log.error("回退券ERROR:{}",e);
} catch (Exception e) {
log.error("回退券ERROR:{}", e);
}
}
public BigDecimal getExpressPrice(String adCode, String productCode) {
try {
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Accept", "application/json;charset=UTF-8");
String resultData = HttpUtil.get(kylinUrl + "/getShunFengPrice/getPrice?adcode=" + adCode + "&productCode=" + productCode, null, header);
ResponseDto<String> innerReturnVo = JsonUtils.fromJson(resultData, new TypeReference<ResponseDto<String>>() {
});
return BigDecimal.valueOf(Integer.parseInt(innerReturnVo.getData()));
} catch (Exception e) {
log.error("获取快递费失败:{}", e);
return BigDecimal.valueOf(23);
}
}
......
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