用户地址修改
This commit is contained in:
parent
5b6cf0240b
commit
c7018bbb6b
@ -12,9 +12,10 @@ public class StateCode {
|
||||
public static final int DELIVERY_TYPE_EMS = 2; //EMS(邮政)
|
||||
public static final int DELIVERY_TYPE_MAIL = 3; //平邮
|
||||
public static final int DELIVERY_TYPE_AIR_FREIGHT = 4; //货运(空运、水运、铁路运输、公路运输)
|
||||
public static final int DELIVERY_TYPE_SELF_PICK_UP = 5; //自提(运费 0 元)
|
||||
public static final int DELIVERY_TYPE_EXP = 10; //配送
|
||||
public static final int DELIVERY_TYPE_IN_STORE_SERVICE = 15; //配送
|
||||
public static final int DELIVERY_TYPE_SELF_PICK_UP = 5; // 自提(运费 0 元)
|
||||
public static final int DELIVERY_TYPE_EXP = 10; // 普通快递
|
||||
public static final int DELIVERY_TYPE_IN_STORE_SERVICE = 15; // 店铺配送
|
||||
public static final int DELIVERY_TYPE_SAME_CITY= 16;//同城配送,一般是顺丰同城,达达,蜂鸟
|
||||
|
||||
public static final int DELIVERY_TIME_NO_LIMIT = 1; //不限送货时间:周一至周日
|
||||
public static final int DELIVERY_TIME_WORKING_DAY = 2; //工作日送货:周一至周五
|
||||
|
||||
@ -41,7 +41,7 @@ public class ShopOrderData implements Serializable {
|
||||
@ApiModelProperty(value = "延迟时间,默认为0 - 收货确认")
|
||||
private Integer order_delay_time;
|
||||
|
||||
@ApiModelProperty(value = "配送方式(ENUM):5-自提; 10-快递;")
|
||||
@ApiModelProperty(value = "配送方式(ENUM):5-自提;10-快递;16-同城配送;")
|
||||
private Integer delivery_type_id;
|
||||
|
||||
@ApiModelProperty(value = "配送时间:要求,不限、周一~周五、周末等等")
|
||||
|
||||
@ -114,7 +114,7 @@ public class ShopOrderInfo implements Serializable {
|
||||
@ApiModelProperty(value = "门店编号")
|
||||
private Integer chain_id;
|
||||
|
||||
@ApiModelProperty(value = "配送方式(ENUM):5-自提; 10-快递;")
|
||||
@ApiModelProperty(value = "配送方式(ENUM):5-自提;10-快递;16-同城配送;\n;")
|
||||
private Integer delivery_type_id;
|
||||
|
||||
@ApiModelProperty(value = "线下订单(BOOL):0-线上;1-线下")
|
||||
|
||||
@ -93,5 +93,11 @@ public class ShopUserDeliveryAddress implements Serializable {
|
||||
@ApiModelProperty(value = "是否默认")
|
||||
private Integer ud_is_default;
|
||||
|
||||
@ApiModelProperty(value = "收货人性别:1-男;2-女;")
|
||||
private Integer ud_gender;
|
||||
|
||||
@ApiModelProperty(value = "标签:1:-家;2-公司;3-学校;9-其他;")
|
||||
private Integer ud_label;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.suisung.mall.common.utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -129,4 +130,22 @@ public class CommonUtil {
|
||||
.distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Double 四舍五入,不保留小数点
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
public static Double DoubleRoundHalfUp(Double d) {
|
||||
return DecimalRoundHalfUp(new BigDecimal(d)).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Decimal 四舍五入,不保留小数点
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
public static BigDecimal DecimalRoundHalfUp(BigDecimal d) {
|
||||
return d.setScale(0, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ public class UserOrderController extends BaseControllerImpl {
|
||||
@ApiImplicitParam(name = "activity_id", value = "活动id", paramType = "query", required = false, dataType = "int"),
|
||||
@ApiImplicitParam(name = "quantity", value = "数量", paramType = "query", required = false, dataType = "int"),
|
||||
@ApiImplicitParam(name = "channel_type", value = "货品类型", paramType = "query", required = false, dataType = "int"),
|
||||
@ApiImplicitParam(name = "delivery_type_id", value = "配送方式(ENUM):5-自提; 10-快递;", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = "delivery_type_id", value = "配送方式(ENUM):5-自提;10-快递;16-同城配送;", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = "checkout_row", value = "", paramType = "body", required = false, dataType = "checkout_row"),
|
||||
@ApiImplicitParam(name = "user_invoice_id", value = "发票编号", paramType = "query", required = false, dataType = "int"),
|
||||
@ApiImplicitParam(name = "cart_id", value = "商品信息(23477|1 : itemId|数量)", paramType = "query", required = true, dataType = "String"),
|
||||
|
||||
@ -2,7 +2,11 @@ package com.suisung.mall.shop.store.controller.admin;
|
||||
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.store.ShopStorePrinter;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreSameCityTransportBase;
|
||||
import com.suisung.mall.common.utils.CommonUtil;
|
||||
import com.suisung.mall.shop.store.mapper.ShopStorePrinterMapper;
|
||||
import com.suisung.mall.shop.store.service.ShopStorePrinterService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreSameCityTransportBaseService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -11,14 +15,29 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Api(tags = "门店打票机打印业务")
|
||||
@RestController
|
||||
@RequestMapping("/admin/shop/store/printer")
|
||||
public class ShopStorePrinterController {
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private ShopStorePrinterService shopStorePrinterService;
|
||||
|
||||
@Resource
|
||||
private ShopStoreSameCityTransportBaseService shopStoreSameCityTransportBaseService;
|
||||
|
||||
|
||||
@ApiOperation(value = "内部测试案例", notes = "内部测试案例")
|
||||
@RequestMapping(value = "/testcase", method = {RequestMethod.GET})
|
||||
public CommonResult TestCase() {
|
||||
Object data = shopStoreSameCityTransportBaseService.computeSameCityTransportFee(2L, BigDecimal.valueOf(110.085), BigDecimal.valueOf(23.37), 20000, BigDecimal.valueOf(102), BigDecimal.valueOf(96), BigDecimal.valueOf(94));
|
||||
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "测试打印模版消息", notes = "测试打印模版消息")
|
||||
@RequestMapping(value = "/print/order", method = {RequestMethod.POST})
|
||||
public boolean printOrder(@RequestParam(name = "orderId" , required = true) String orderId) {
|
||||
|
||||
@ -12,6 +12,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mchange.lang.DoubleUtils;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
@ -19,6 +20,7 @@ import com.suisung.mall.common.modules.store.ShopStoreBase;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreSameCityTransport;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreSameCityTransportBase;
|
||||
import com.suisung.mall.common.pojo.dto.ShopStoreSameCityTransportBaseDTO;
|
||||
import com.suisung.mall.common.utils.CommonUtil;
|
||||
import com.suisung.mall.common.utils.PositionUtil;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.chain.controller.admin.ShopChainUserController;
|
||||
@ -86,6 +88,9 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
}
|
||||
|
||||
Integer userId = user.getId();
|
||||
Long storeId = Convert.toLong(user.getStore_id());
|
||||
|
||||
shopStoreSameCityTransportBaseDTO.getTransportBase().setStore_id(storeId);
|
||||
|
||||
if (shopStoreSameCityTransportBaseDTO == null || shopStoreSameCityTransportBaseDTO.getTransportBase() == null) {
|
||||
return CommonResult.failed("参数有误");
|
||||
@ -267,21 +272,44 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
|
||||
// 通过高德或百度地图api,计算两点的距离,如果服务不可用或无法计算,使用内部算法计算距离(单位米)
|
||||
Double distanceD = PositionUtil.getDistance4(transportBase.getStore_longitude().doubleValue(), transportBase.getStore_latitude().doubleValue(), orderLongitude.doubleValue(), orderLatitude.doubleValue());
|
||||
// 实际配送距离,单位米
|
||||
Integer distance = distanceD.intValue();
|
||||
|
||||
// ### 基础配送费计算
|
||||
BigDecimal deliveryBaseFee = transportBase.getDelivery_base_fee();
|
||||
// 每增加一个距离累加运费
|
||||
if (transportBase.getDistance_increase_km() != null && transportBase.getDistance_increase_fee() != null && transportBase.getDistance_base() != null && distance > transportBase.getDistance_base() * 1000) {
|
||||
Integer distanceM = transportBase.getDistance_base() * 1000;// 千米转米
|
||||
// 实际配送距离超出基础距离,单位km
|
||||
BigDecimal diffDistanceM = CommonUtil.DecimalRoundHalfUp(BigDecimal.valueOf(distance - transportBase.getDistance_base() * 1000).divide(BigDecimal.valueOf(1000)));
|
||||
// 累加的次数
|
||||
Integer times = 0;
|
||||
if(diffDistanceM.intValue()>transportBase.getDistance_increase_km()){
|
||||
times = diffDistanceM.intValue() / transportBase.getDistance_increase_km();
|
||||
// 求余,如果有余数,增加一次倍数
|
||||
if(diffDistanceM.intValue() % transportBase.getDistance_increase_km()>0){
|
||||
times+=1;
|
||||
}
|
||||
}
|
||||
|
||||
deliveryBaseFee.add(transportBase.getDelivery_base_fee().multiply(BigDecimal.valueOf(distance - distanceM)));
|
||||
// 超过基础运费距离后,累加上运费
|
||||
deliveryBaseFee = deliveryBaseFee.add(transportBase.getDistance_increase_fee().multiply(BigDecimal.valueOf(times)));
|
||||
}
|
||||
|
||||
// 每增加一个重量累加运费(重量暂时忽略,配置的时候设置0)
|
||||
if (transportBase.getWeight_increase_kg() != null && transportBase.getWeight_increase_fee() != null && transportBase.getWeight_base() != null && weightGram > transportBase.getWeight_base() * 1000) {
|
||||
Integer weightG = transportBase.getWeight_base() * 1000; // kg 转 g
|
||||
deliveryBaseFee.add(transportBase.getWeight_increase_fee().multiply(BigDecimal.valueOf(weightGram - weightG)));
|
||||
// 实际配送重量超出基础重量,单位kg
|
||||
BigDecimal diffWeightKg = CommonUtil.DecimalRoundHalfUp(BigDecimal.valueOf(weightGram - transportBase.getWeight_base() * 1000).divide(BigDecimal.valueOf(1000)));
|
||||
// 累加的次数
|
||||
Integer times = 0;
|
||||
if(diffWeightKg.intValue()>transportBase.getWeight_increase_kg()){
|
||||
times = diffWeightKg.intValue() / transportBase.getWeight_increase_kg();
|
||||
// 求余,如果有余数,增加一次倍数
|
||||
if(diffWeightKg.intValue() % transportBase.getWeight_increase_kg()>0){
|
||||
times+=1;
|
||||
}
|
||||
}
|
||||
|
||||
deliveryBaseFee = deliveryBaseFee.add(transportBase.getWeight_increase_fee().multiply(BigDecimal.valueOf(times)));
|
||||
}
|
||||
// #### 基础配送费计算完毕
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ package com.suisung.mall.shop.store.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreSameCityTransport;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
@ -98,7 +99,7 @@ public class ShopStoreSameCityTransportServiceImpl extends BaseServiceImpl<ShopS
|
||||
}
|
||||
} else {
|
||||
// 修改
|
||||
if (updateById(transport)) {
|
||||
if (updateShopStoreSameCityTransport(transport)) {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
@ -107,5 +108,28 @@ public class ShopStoreSameCityTransportServiceImpl extends BaseServiceImpl<ShopS
|
||||
return count;
|
||||
}
|
||||
|
||||
public Boolean updateShopStoreSameCityTransport(ShopStoreSameCityTransport transport) {
|
||||
if (transport == null || transport.getTransport_id() == null || transport.getTransport_id() <= 0 || transport.getTransport_base_id() == null || transport.getTransport_base_id() <= 0) {
|
||||
logger.error("缺少Transport_id 或 Transport_base_id 必要参数!");
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateWrapper<ShopStoreSameCityTransport> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("transport_id", transport.getTransport_id());
|
||||
updateWrapper.eq("transport_base_id", transport.getTransport_base_id());
|
||||
|
||||
ShopStoreSameCityTransport updateTransport = new ShopStoreSameCityTransport();
|
||||
updateTransport.setArea_type(transport.getArea_type());
|
||||
updateTransport.setMax_delivery_radius(transport.getMax_delivery_radius());
|
||||
updateTransport.setMin_delivery_amount_type(transport.getDelivery_discount_type());
|
||||
updateTransport.setMin_delivery_amount(transport.getMin_delivery_amount());
|
||||
updateTransport.setDelivery_discount_type(transport.getDelivery_discount_type());
|
||||
updateTransport.setMin_delivery_discount_amount(transport.getMin_delivery_discount_amount());
|
||||
updateTransport.setDelivery_discount(transport.getDelivery_discount());
|
||||
updateTransport.setStatus(transport.getStatus());
|
||||
|
||||
return update(updateTransport, updateWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -100,10 +100,10 @@ public class UserCartController {
|
||||
return shopUserCartService.addBatch(cart_id, activity_id);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "结算 确认订单- - 收货地址 支付方式 配送方式 配送时间 发票 , 可选优惠券,礼品卡等等从 虚拟商品不经过购物车", notes = "结算")
|
||||
@ApiOperation(value = "结算,确认订单-收货地址、支付方式、配送方式、配送时间、发票,可选优惠券,礼品卡等等从虚拟商品不经过购物车", notes = "结算")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "cart_id", value = "商品信息(23477|1 : itemId|数量)", paramType = "query", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "delivery_type_id", value = "配送方式(ENUM):5-自提; 10-快递;", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = "delivery_type_id", value = "配送方式(ENUM):5-自提;10-快递;16-同城配送;", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = "buyer_user_id", value = "买家编号", paramType = "query", required = false, dataType = "int"),
|
||||
@ApiImplicitParam(name = "chain_id", value = "门店编号", paramType = "query", required = false, dataType = "int"),
|
||||
@ApiImplicitParam(name = "pfgb_id", value = "pfgb_id", paramType = "query", required = false, dataType = "int"),
|
||||
|
||||
@ -32,5 +32,15 @@ public interface ShopUserDeliveryAddressService extends IBaseService<ShopUserDel
|
||||
|
||||
Map getList(QueryWrapper<ShopUserDeliveryAddress> queryWrapper, Integer pageNum, Integer pageSize);
|
||||
|
||||
Boolean setDefaultAddress(Integer ud_id, Integer user_id);
|
||||
Boolean updateDefaultAddress(Integer ud_id, Integer user_id);
|
||||
|
||||
/**
|
||||
* 将用户地址的标签设置成无值,除ud_id的记录除外
|
||||
*
|
||||
* @param udId
|
||||
* @param userId
|
||||
* @param updLabel
|
||||
* @return
|
||||
*/
|
||||
Boolean updateAddressLabel(Integer udId, Integer userId, Integer updLabel);
|
||||
}
|
||||
|
||||
@ -75,102 +75,70 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||
@Service
|
||||
public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper, ShopUserCart> implements ShopUserCartService {
|
||||
|
||||
private final static Integer CART_TYPE_BUY = 1; //购买
|
||||
private final static Integer CART_TYPE_POINT = 2; //赠品
|
||||
private final static Integer CART_TYPE_GIFT = 3; //积分兑换
|
||||
@Autowired
|
||||
private ShopProductItemService shopProductItemService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreBaseService shopStoreBaseService;
|
||||
|
||||
@Autowired
|
||||
private ShopChainBaseService shopChainBaseService;
|
||||
|
||||
@Autowired
|
||||
private ShopChainItemService shopChainItemService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductBaseService shopProductBaseService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreTransportTypeService transportTypeService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreActivityBaseService shopStoreActivityBaseService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseConfigService accountBaseConfigService;
|
||||
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreProductCategoryService productCategoryService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductIndexService productIndexService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreConfigService shopStoreConfigService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreTransportAmountService transportAmountService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductPricingPolicyWholesaleService policyWholesaleService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductPricingPolicyLevelService pricingPolicyLevelService;
|
||||
|
||||
@Autowired
|
||||
private InvoicingCustomerLevelService customerLevelService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductValidPeriodService shopProductValidPeriodService;
|
||||
|
||||
@Autowired
|
||||
private ShopUserDeliveryAddressService deliveryAddressService;
|
||||
|
||||
@Autowired
|
||||
private ShopUserVoucherService shopUserVoucherService;
|
||||
|
||||
@Autowired
|
||||
private PayService payService;
|
||||
|
||||
@Autowired
|
||||
private ShopOrderBaseService shopOrderBaseService;
|
||||
|
||||
@Autowired
|
||||
private InvoicingCustomerBaseService invoicingCustomerBaseService;
|
||||
|
||||
@Autowired
|
||||
private ShopBaseStateCodeService shopBaseStateCodeService;
|
||||
|
||||
@Autowired
|
||||
private ShopUserCartService shopUserCartService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreActivityCodeService shopStoreActivityCodeService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreActivityItemService shopStoreActivityItemService;
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductInfoService shopProductInfoService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductIndexService shopProductIndexService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductImageService shopProductImageService;
|
||||
|
||||
private final static Integer CART_TYPE_BUY = 1; //购买
|
||||
|
||||
private final static Integer CART_TYPE_POINT = 2; //赠品
|
||||
|
||||
private final static Integer CART_TYPE_GIFT = 3; //积分兑换
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Map getLists(Integer store_id, Integer chain_id, Integer page, Integer rows) {
|
||||
@ -606,9 +574,10 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
|
||||
int[] item_row = StrUtil.splitToInt(item, "|");
|
||||
if (item_row[1] <= 0) {
|
||||
throw new ApiException(I18nUtil._("购买数量最低为 1 哦~"));
|
||||
throw new ApiException(I18nUtil._("至少购买1个有效商品!"));
|
||||
}
|
||||
|
||||
// 购买的商品记录
|
||||
ShopProductItem product_item_row = shopProductItemService.get(item_row[0]);
|
||||
Long _product_id = product_item_row.getProduct_id();
|
||||
ShopProductBase product_row = shopProductBaseService.get(_product_id);
|
||||
@ -714,7 +683,6 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
// 判断是否教育课程类
|
||||
// getEduOrderInfo()
|
||||
Integer kind_id = (Integer) _item.get("kind_id");
|
||||
|
||||
if (ObjectUtil.equal(kind_id, StateCode.PRODUCT_KIND_EDU)) {
|
||||
Map orderDetail = shopOrderBaseService.getEduOrderDetail(user_id, product_id);
|
||||
if (CollUtil.isNotEmpty(orderDetail)) {
|
||||
@ -736,7 +704,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
}
|
||||
|
||||
// 传入用户ID则获取其地址信息
|
||||
// 默认选中地址
|
||||
// 选中默认地址
|
||||
List<Map> address_row = new ArrayList();
|
||||
Map delivery_address_row = new HashMap();
|
||||
|
||||
@ -756,9 +724,8 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
}
|
||||
}
|
||||
|
||||
// 地址
|
||||
// 收货人收货地址
|
||||
deliveryAddressService.fixAddressData(address_row);
|
||||
|
||||
if (CollUtil.isNotEmpty(address_row)) {
|
||||
Optional<Map> defaultOpl = address_row.stream().filter(s -> Convert.toBool(s.get("ud_is_default"), false)).findFirst();
|
||||
if (defaultOpl.isPresent()) {
|
||||
@ -770,14 +737,17 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
|
||||
Integer district_id = Convert.toInt(delivery_address_row.get("ud_city_id"));
|
||||
if (CollUtil.isNotEmpty(delivery_address_row) && CheckUtil.isNotEmpty(district_id)) {
|
||||
// todo 邮费情况
|
||||
// 计算邮费情况
|
||||
if (Convert.toBool(is_delivery)) {
|
||||
calTransportFreight(data, district_id); // 配送检测
|
||||
// 配送检测和计算
|
||||
calTransportFreight(data, district_id);
|
||||
data.put("has_stock", data.get("can_delivery")); // 是否有货
|
||||
} else {
|
||||
data.put("can_delivery", true); // 是否可以派送
|
||||
data.put("has_stock", true); // 是否有货
|
||||
}
|
||||
|
||||
// 是否有货
|
||||
boolean has_stock = (boolean) data.get("has_stock");
|
||||
data.put("show_oos", !has_stock);
|
||||
}
|
||||
@ -1277,18 +1247,21 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
boolean single_item = cart_rows.size() == 1;
|
||||
boolean single_activity = false;
|
||||
|
||||
// 配送方式(ENUM):5-自提;10-快递;16-同城配送;
|
||||
List<Integer> allowTransportIds = new ArrayList<Integer>() {{
|
||||
add(5);
|
||||
add(10);
|
||||
add(16);
|
||||
}}; //允许的配送方式
|
||||
|
||||
// 关键金额数据,对方竟然没有备注清楚!!!
|
||||
BigDecimal orderSelProductAmount = BigDecimal.ZERO; //商品订单原价
|
||||
BigDecimal orderSelFreightAmount = BigDecimal.ZERO;
|
||||
BigDecimal orderSelMoneyAmount = BigDecimal.ZERO;
|
||||
BigDecimal orderDiscountAmount = BigDecimal.ZERO;
|
||||
BigDecimal orderSelPointsAmount = BigDecimal.ZERO;
|
||||
BigDecimal orderSelSpAmount = BigDecimal.ZERO;
|
||||
BigDecimal order_rebate_amount = BigDecimal.ZERO;
|
||||
BigDecimal orderSelFreightAmount = BigDecimal.ZERO;//商品订单原价
|
||||
BigDecimal orderSelMoneyAmount = BigDecimal.ZERO;//商品订单原价
|
||||
BigDecimal orderDiscountAmount = BigDecimal.ZERO;//商品订单折扣优惠金额
|
||||
BigDecimal orderSelPointsAmount = BigDecimal.ZERO;//商品订单积分抵扣金额
|
||||
BigDecimal orderSelSpAmount = BigDecimal.ZERO;//商品订单原价
|
||||
BigDecimal orderRebateAmount = BigDecimal.ZERO;//商品订单返利金额
|
||||
|
||||
data_rows.put("orderSelMoneyAmount", 10.00f);
|
||||
data_rows.put("items", new ArrayList());
|
||||
@ -1586,7 +1559,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
|
||||
for (Map item_row : items) {
|
||||
// 快速修正订单价格
|
||||
if (fixOrderVo != null && fixOrderVo.isFix_price() == true) {
|
||||
if (fixOrderVo != null && fixOrderVo.isFix_price()) {
|
||||
item_row.put("item_unit_price", fixOrderVo.getItem_unit_price());
|
||||
item_row.put("item_sale_price", fixOrderVo.getItem_unit_price());
|
||||
item_row.put("item_unit_points", BigDecimal.ZERO);
|
||||
@ -1768,11 +1741,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
List<Map> tmp_pulse_multples = (List<Map>) s.get("pulse_multple");
|
||||
if (CollUtil.isNotEmpty(tmp_pulse_multples)) {
|
||||
Integer act_id = (Integer) tmp_pulse_multples.get(0).get("activity_id");
|
||||
if (act_id.equals(tmp_activity_id)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return act_id.equals(tmp_activity_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1812,11 +1781,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
pulse_multple.put("max_multple_rate", max_multple_rate); //折扣比率
|
||||
|
||||
//处理参与活动商品折扣价格
|
||||
if (max_multple_quantity.compareTo(BigDecimal.ZERO) > 0) {
|
||||
give_enable = true;
|
||||
} else {
|
||||
give_enable = false;
|
||||
}
|
||||
give_enable = max_multple_quantity.compareTo(BigDecimal.ZERO) > 0;
|
||||
|
||||
pulse_multple.put("give_enable", give_enable);
|
||||
}
|
||||
@ -2020,11 +1985,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
if (CollUtil.isNotEmpty(tmp_reduction_again)) {
|
||||
Integer act_id = (Integer) tmp_reduction_again.get(0).get("activity_id");
|
||||
|
||||
if (act_id.equals(tmp_activity_id)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return act_id.equals(tmp_activity_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2123,11 +2084,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
if (CollUtil.isNotEmpty(tmp_manhui)) {
|
||||
Integer act_id = (Integer) tmp_manhui.get(0).get("activity_id");
|
||||
|
||||
if (act_id.equals(tmp_activity_id)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return act_id.equals(tmp_activity_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2156,7 +2113,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
ShopStoreActivityBase tmp = shopStoreActivityBaseService.get(Convert.toInt(item.get("max_num")));
|
||||
|
||||
if (tmp != null) {
|
||||
com.alibaba.fastjson.JSONObject activity_rule = com.alibaba.fastjson.JSONObject.parseObject((String) tmp.getActivity_rule());
|
||||
com.alibaba.fastjson.JSONObject activity_rule = com.alibaba.fastjson.JSONObject.parseObject(tmp.getActivity_rule());
|
||||
|
||||
//不复用活动结构,无give_id==优惠券编号, 则不满足条件。
|
||||
manhui_row.put("give_id", tmp.getActivity_id());
|
||||
@ -2231,13 +2188,14 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
|
||||
store_row.put("activity_discount_amount", order_activity_discount_amount);
|
||||
|
||||
// 关键订单金额数据
|
||||
orderSelProductAmount = orderSelProductAmount.add(store_origin_total);
|
||||
orderSelFreightAmount = orderSelFreightAmount.add(Convert.toBigDecimal(store_row.get("freight")));
|
||||
orderSelMoneyAmount = orderSelMoneyAmount.add(Convert.toBigDecimal(store_row.get("order_money_select_items")));
|
||||
orderDiscountAmount = orderDiscountAmount.add(Convert.toBigDecimal(store_row.get("order_discount_amount")));
|
||||
orderSelPointsAmount = orderSelPointsAmount.add(store_points_total);
|
||||
orderSelSpAmount = orderSelSpAmount.add(store_sp_total);
|
||||
order_rebate_amount = order_rebate_amount.add(Convert.toBigDecimal(store_row.get("store_rebate")));
|
||||
orderRebateAmount = orderRebateAmount.add(Convert.toBigDecimal(store_row.get("store_rebate")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2249,7 +2207,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
data_rows.put("orderDiscountAmount", orderDiscountAmount);
|
||||
data_rows.put("orderSelPointsAmount", orderSelPointsAmount);
|
||||
data_rows.put("orderSelSpAmount", orderSelSpAmount);
|
||||
data_rows.put("order_rebate_amount", order_rebate_amount);
|
||||
data_rows.put("order_rebate_amount", orderRebateAmount);
|
||||
|
||||
if (CollUtil.isNotEmpty(store_rows)) {
|
||||
data_rows.put("items", store_rows);
|
||||
@ -2496,13 +2454,15 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
* 1、单品在一个订单中,运费规则计算
|
||||
* 2、配送区域问题
|
||||
*
|
||||
* @param cart_data 最总数据
|
||||
* @param cart_data 最终数据
|
||||
* @param district_id 配送地区
|
||||
*/
|
||||
@Override
|
||||
public void calTransportFreight(Map cart_data, Integer district_id) {
|
||||
|
||||
// 配送不到这个区域商品id
|
||||
List transport_type_none_ids = new ArrayList();
|
||||
// 配送不到这个区域商品记录
|
||||
List delivery_item_none_row = new ArrayList();
|
||||
|
||||
cart_data.put("transport_type_none_ids", transport_type_none_ids);
|
||||
@ -2542,10 +2502,10 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
|
||||
// 按照店铺订单计算运费
|
||||
Integer store_id = Convert.toInt(store_row.get("store_id"));
|
||||
|
||||
//是否启用店铺订单免运费
|
||||
boolean ifEnabledFreeFreight = shopStoreConfigService.ifEnabledFreeFreight(store_id);
|
||||
|
||||
if (ifEnabledFreeFreight) {
|
||||
|
||||
BigDecimal order_money_select_items = Convert.toBigDecimal(store_row.get("order_money_select_items"), BigDecimal.ZERO);
|
||||
Map data = transportAmountService.calFreight(store_id, district_id, order_money_select_items, post_free_max);
|
||||
|
||||
@ -2750,7 +2710,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
item_row.put("num", item_row.get("cart_quantity"));
|
||||
|
||||
Integer kind_id = (Integer) item_row.get("kind_id");
|
||||
Boolean is_on_sale = ObjectUtil.equal(kind_id, StateCode.PRODUCT_KIND_EDU) ? true : shopProductBaseService.ifOnSale(item_row);
|
||||
Boolean is_on_sale = ObjectUtil.equal(kind_id, StateCode.PRODUCT_KIND_EDU) || shopProductBaseService.ifOnSale(item_row);
|
||||
|
||||
item_row.put("is_on_sale", is_on_sale);
|
||||
item_row.put("cart_select", is_on_sale ? item_row.get("cart_select") : 0);
|
||||
|
||||
@ -74,6 +74,7 @@ public class ShopUserDeliveryAddressServiceImpl extends BaseServiceImpl<ShopUser
|
||||
|
||||
QueryWrapper<ShopUserDeliveryAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", user_id);
|
||||
queryWrapper.orderByAsc("ud_is_default").orderByAsc("ud_label").orderByDesc("ud_id");
|
||||
Page<ShopUserDeliveryAddress> addressPage = lists(queryWrapper, page, rows);
|
||||
|
||||
Map data = toMobileResult(addressPage);
|
||||
@ -172,7 +173,13 @@ public class ShopUserDeliveryAddressServiceImpl extends BaseServiceImpl<ShopUser
|
||||
deliveryAddress.setUser_id(user_id);
|
||||
|
||||
if (ud_is_default != null && ud_is_default != 0) {
|
||||
setDefaultAddress(ud_id, user_id);
|
||||
// 默认地址只能一个,其他都设置非默认
|
||||
updateDefaultAddress(ud_id, user_id);
|
||||
}
|
||||
|
||||
if(deliveryAddress.getUd_label()!=null&& deliveryAddress.getUd_label().equals(0)){
|
||||
// 标签对用户来说是唯一的,设置了某个标签,其他之前的地址标签要置空
|
||||
updateAddressLabel(ud_id,user_id,deliveryAddress.getUd_label());
|
||||
}
|
||||
|
||||
if (!saveOrUpdate(deliveryAddress)) {
|
||||
@ -227,14 +234,14 @@ public class ShopUserDeliveryAddressServiceImpl extends BaseServiceImpl<ShopUser
|
||||
}
|
||||
|
||||
/**
|
||||
* 将除了改ud_id意外的设置成 非默认
|
||||
* 将ud_id的地址记录设置成默认的,其他的非默认
|
||||
* 修改成功为true,失败为false
|
||||
*
|
||||
* @param ud_id
|
||||
* @param user_id
|
||||
*/
|
||||
@Override
|
||||
public Boolean setDefaultAddress(Integer ud_id, Integer user_id) {
|
||||
public Boolean updateDefaultAddress(Integer ud_id, Integer user_id) {
|
||||
|
||||
QueryWrapper<ShopUserDeliveryAddress> addressQueryWrapper = new QueryWrapper<>();
|
||||
addressQueryWrapper.eq("user_id", user_id).ne("ud_id", ud_id);
|
||||
@ -245,4 +252,22 @@ public class ShopUserDeliveryAddressServiceImpl extends BaseServiceImpl<ShopUser
|
||||
return edit(deliveryAddress, addressQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将用户地址的标签设置成无值,除ud_id的记录除外
|
||||
* @param udId
|
||||
* @param userId
|
||||
* @param updLabel
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateAddressLabel(Integer udId, Integer userId, Integer updLabel) {
|
||||
QueryWrapper<ShopUserDeliveryAddress> addressQueryWrapper = new QueryWrapper<>();
|
||||
addressQueryWrapper.eq("user_id", userId).eq("label", updLabel).ne("ud_id", udId);
|
||||
|
||||
ShopUserDeliveryAddress deliveryAddress = new ShopUserDeliveryAddress();
|
||||
deliveryAddress.setUd_label(0);
|
||||
|
||||
return edit(deliveryAddress, addressQueryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<sql id="Base_Column_List">
|
||||
ud_id, user_id, ud_name, ud_intl, ud_mobile, ud_telephone, ud_contacter, ud_im, ud_province_id, ud_province,
|
||||
ud_city_id, ud_city, ud_county_id, ud_county, ud_address, ud_postalcode, ud_tag_name, ud_longitude, ud_latitude,
|
||||
ud_time, ud_is_default
|
||||
ud_time, ud_is_default, ud_gender, ud_label
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user