Authored by chenchao

support before version 6.9.3

... ... @@ -40,10 +40,12 @@ public class ShoppingController {
*/
@RequestMapping(params = "method=ufo.order.payment")
public ApiResponse payment(@RequestParam(name = "uid") int uid,
@RequestParam(name = "skup") int skup){
@RequestParam(name = "skup") int skup,
@RequestParam(value = "app_version", required = false)String appVersion){
//AUTO 自动匹配
ShoppingRequest req = ShoppingRequest.builder().uid(uid).skup(skup)
.couponCodes(CouponConstants.AUTO_RECOMMENDED_COUPON_CODES).build();
.couponCodes(CouponConstants.AUTO_RECOMMENDED_COUPON_CODES)
.appVersion(appVersion).build();
logger.info("in ufo.order.payment, req {}", req);
PaymentResponse paymentResponse = buyerOrderService.payment(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(paymentResponse).message("结算成功").build();
... ... @@ -59,7 +61,10 @@ public class ShoppingController {
@RequestParam(name = "skup") int skup,
@RequestParam(name = "coupon_code",required = false) String couponCode) {
ShoppingRequest req = ShoppingRequest.builder().uid(uid).skup(skup).couponCodes(CouponCodeUtils.asList(couponCode)).build();
ShoppingRequest req = ShoppingRequest.builder()
.uid(uid).skup(skup)
.couponCodes(CouponCodeUtils.asList(couponCode))
.build();
logger.info("in ufo.order.selectCoupon, req {}", req);
ShoppingCouponListResp resp = buyerOrderService.selectCoupon(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(resp).message("ok").build();
... ... @@ -74,12 +79,14 @@ public class ShoppingController {
public ApiResponse compute(@RequestParam(name = "uid") int uid,
@RequestParam(name = "skup") int skup,
@RequestParam(name = "coupon_code",required = false) String couponCode,
@RequestParam(name = "addressId", required = false) String addressId) {
@RequestParam(name = "addressId", required = false) String addressId,
@RequestParam(value = "app_version", required = false)String appVersion) {
ShoppingRequest req = ShoppingRequest.builder().uid(uid)
.skup(skup)
.couponCodes(CouponCodeUtils.asList(couponCode))
.addressId(addressId)
.appVersion(appVersion)
.build();
logger.info("in ufo.order.compute, req {}", req);
ComputeResponse resp = buyerOrderService.compute(req);
... ...
... ... @@ -46,4 +46,9 @@ public class ShoppingRequest {
*/
private String inviteCode;
/**
*
*/
private String appVersion;
}
... ...
... ... @@ -134,9 +134,9 @@ public class ShoppingServiceImpl implements IShoppingService {
PaymentResponse response = new PaymentResponse();
response.setPaymentWay(shoppingSupport.getPaymentWay());
response.setDeliveryWay(shoppingSupport.getDeliverWay(chargeResult));
response.setDeliveryWay(shoppingSupport.getDeliverWay(chargeResult, request.getAppVersion()));
response.setGood(shoppingSupport.getGoodsInfo(skupGood));
response.setPromotionFormulaList(shoppingSupport.getPromotionFormula(chargeResult));
response.setPromotionFormulaList(shoppingSupport.getPromotionFormula(chargeResult, request.getAppVersion(), false));
response.setAmount(MathUtils.formatStr(chargeResult.getFinalAmount()));
BigDecimal ompensate = sellerFeeService.computeBuyerCompensate(skup);
... ... @@ -248,7 +248,7 @@ public class ShoppingServiceImpl implements IShoppingService {
ComputeResponse response = new ComputeResponse();
response.setCouponInfo(couponSupport.getCouponInfo(chargeResult));
response.setPromotionFormulaList(shoppingSupport.getPromotionFormula(chargeResult));
response.setPromotionFormulaList(shoppingSupport.getPromotionFormula(chargeResult, request.getAppVersion(), true));
response.setAmount(MathUtils.formatStr(chargeResult.getFinalAmount()));
return response;
... ...
... ... @@ -15,6 +15,7 @@ import com.yohoufo.order.model.response.PromotionFormula;
import com.yohoufo.order.model.response.RecommendedCouponInfo;
import com.yohoufo.order.utils.MathUtils;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
... ... @@ -40,16 +41,32 @@ public class ShoppingSupport {
* 配送方式
* @return
*/
public PaymentResponse.DeliveryWay getDeliverWay(final ChargeResult chargeResult) {
public PaymentResponse.DeliveryWay getDeliverWay(final ChargeResult chargeResult, String appVersion) {
// 快递方式
PaymentResponse.DeliveryWay deliveryWay = new PaymentResponse.DeliveryWay();
deliveryWay.setDeliveryWayId(chargeResult.getDeliveryWay());
deliveryWay.setDeliveryWayCost(OrderConstant.MONEY_SIGN + chargeResult.getShippingAmount());
deliveryWay.setDeliveryWayCost(buildDeliveryWayCost(appVersion, chargeResult.getShippingAmount()));
deliveryWay.setDeliveryWayName(getDeliveryWayStr(chargeResult.getDeliveryWay()));
return deliveryWay;
}
String buildDeliveryWayCost(String appVersion, double shippingAmount){
if (isLowerVersion(appVersion, "6.9.3")){
return "以实际提交订单金额为准";
}else{
String currencyAmount = MathUtils.formatCurrencyStr( shippingAmount );
return currencyAmount;
}
}
boolean isLowerVersion(String appVersion, String comparedVersion){
return StringUtils.isNotBlank(appVersion) && appVersion.compareTo(comparedVersion) < 0;
}
private String getDeliveryWayStr(int deliveryWay) {
return deliveryWay == OrderConstant.DELIVERY_WAY_STORE ? OrderConstant.DELIVERY_WAY_STORE_NAME : OrderConstant.DELIVERY_WAY_SF_NAME;
}
... ... @@ -83,7 +100,7 @@ public class ShoppingSupport {
* @param chargeResult
* @return
*/
public List<PromotionFormula> getPromotionFormula(ChargeResult chargeResult) {
public List<PromotionFormula> getPromotionFormula(ChargeResult chargeResult, String appVersion, boolean showCalDetail) {
List<PromotionFormula> formulas = Lists.newArrayList();
... ... @@ -97,7 +114,13 @@ public class ShoppingSupport {
//运费
PromotionFormula expressFormula = new PromotionFormula();
expressFormula.setPromotion(OrderConstant.DELIVERY_DESC);
expressFormula.setPromotionAmount(OrderConstant.PLUS_SIGN + MathUtils.formatCurrencyStr(chargeResult.getShippingAmount()));
String shipFee = null;
if (showCalDetail){
shipFee = OrderConstant.PLUS_SIGN + MathUtils.formatCurrencyStr(chargeResult.getShippingAmount());
}else{
shipFee = buildDeliveryWayCost(appVersion, chargeResult.getShippingAmount());
}
expressFormula.setPromotionAmount(shipFee);
formulas.add(expressFormula);
... ...