mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
trade:新增是否自提的配置项
This commit is contained in:
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
|
||||
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -26,6 +27,9 @@ public class TradeConfigController {
|
||||
@Resource
|
||||
private TradeConfigService tradeConfigService;
|
||||
|
||||
@Value("${yudao.tencent-lbs-key}")
|
||||
private String tencentLbsKey;
|
||||
|
||||
@PutMapping("/save")
|
||||
@Operation(summary = "更新交易中心配置")
|
||||
@PreAuthorize("@ss.hasPermission('trade:config:save')")
|
||||
@ -39,7 +43,11 @@ public class TradeConfigController {
|
||||
@PreAuthorize("@ss.hasPermission('trade:config:query')")
|
||||
public CommonResult<TradeConfigRespVO> getConfig() {
|
||||
TradeConfigDO config = tradeConfigService.getTradeConfig();
|
||||
return success(TradeConfigConvert.INSTANCE.convert(config));
|
||||
TradeConfigRespVO configVO = TradeConfigConvert.INSTANCE.convert(config);
|
||||
if (configVO != null) {
|
||||
configVO.setTencentLbsKey(tencentLbsKey);
|
||||
}
|
||||
return success(configVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ public class TradeConfigBaseVO {
|
||||
@PositiveOrZero(message = "全场包邮的最小金额不能是负数")
|
||||
private Integer deliveryExpressFreePrice;
|
||||
|
||||
@Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否开启自提不能为空")
|
||||
private Boolean deliveryPickUpEnabled;
|
||||
|
||||
// ========== 分销相关 ==========
|
||||
|
||||
@Schema(description = "是否启用分佣", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
|
@ -14,4 +14,7 @@ public class TradeConfigRespVO extends TradeConfigBaseVO {
|
||||
@Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
private String tencentLbsKey;
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -30,11 +31,14 @@ public class AppTradeConfigController {
|
||||
@Resource
|
||||
private TradeConfigService tradeConfigService;
|
||||
|
||||
@Value("${yudao.tencent-lbs-key}")
|
||||
private String tencentLbsKey;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得交易配置")
|
||||
public CommonResult<AppTradeConfigRespVO> getTradeConfig() {
|
||||
TradeConfigDO tradeConfig = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO());
|
||||
return success(TradeConfigConvert.INSTANCE.convert02(tradeConfig));
|
||||
TradeConfigDO config = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO());
|
||||
return success(TradeConfigConvert.INSTANCE.convert02(config).setTencentLbsKey(tencentLbsKey));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,12 +3,22 @@ package cn.iocoder.yudao.module.trade.controller.app.config.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 交易配置 Response VO")
|
||||
@Data
|
||||
public class AppTradeConfigRespVO {
|
||||
|
||||
@Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
private String tencentLbsKey;
|
||||
|
||||
// ========== 配送相关 ==========
|
||||
|
||||
@Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否开启自提不能为空")
|
||||
private Boolean deliveryPickUpEnabled;
|
||||
|
||||
// ========== 售后相关 ==========
|
||||
|
||||
@Schema(description = "售后的退款理由", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
@ -1,10 +1,14 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.app.delivery;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO;
|
||||
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
|
||||
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -12,9 +16,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@ -24,51 +27,29 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@Validated
|
||||
public class AppDeliverPickUpStoreController {
|
||||
|
||||
// TODO 待实现[门店自提]:如果 latitude、longitude 非空,计算经纬度,并排序。计算的库,可以使用 hutool 的 DistanceUtil 计算。
|
||||
@Resource
|
||||
private DeliveryPickUpStoreService deliveryPickUpStoreService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得自提门店列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "latitude", description = "精度", example = "110"),
|
||||
@Parameter(name = "longitude", description = "纬度", example = "120")
|
||||
})
|
||||
public CommonResult<List<AppDeliveryPickUpStoreRespVO>> getDeliveryPickUpStoreList(
|
||||
@RequestParam(value = "latitude", required = false) Double latitude,
|
||||
@RequestParam(value = "longitude", required = false) Double longitude) {
|
||||
List<AppDeliveryPickUpStoreRespVO> list = new ArrayList<>();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
AppDeliveryPickUpStoreRespVO store = new AppDeliveryPickUpStoreRespVO();
|
||||
store.setId(random.nextLong());
|
||||
store.setName(RandomUtil.randomString(10));
|
||||
store.setLogo("https://www.iocoder.cn/" + (i + 1) + ".png");
|
||||
store.setPhone("15601691300");
|
||||
store.setAreaId(random.nextInt(100000));
|
||||
store.setAreaName("上海-" + RandomUtil.randomString(10));
|
||||
store.setDetailAddress("普陀区-" + RandomUtil.randomString(10));
|
||||
store.setLatitude(random.nextDouble() * 10);
|
||||
store.setLongitude(random.nextDouble() * 10);
|
||||
store.setDistance(random.nextInt(1000));
|
||||
|
||||
list.add(store);
|
||||
}
|
||||
|
||||
return success(list);
|
||||
List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(
|
||||
CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list, latitude, longitude));
|
||||
}
|
||||
|
||||
// TODO 待实现[门店自提]:
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得自提门店")
|
||||
@Parameter(name = "id", description = "门店编号")
|
||||
public CommonResult<AppDeliveryPickUpStoreRespVO> getOrder(@RequestParam("id") Long id) {
|
||||
AppDeliveryPickUpStoreRespVO store = new AppDeliveryPickUpStoreRespVO();
|
||||
Random random = new Random();
|
||||
store.setId(random.nextLong());
|
||||
store.setName(RandomUtil.randomString(10));
|
||||
store.setLogo("https://www.iocoder.cn/" + (1) + ".png");
|
||||
store.setPhone("15601691300");
|
||||
store.setAreaId(random.nextInt(100000));
|
||||
store.setAreaName("上海-" + RandomUtil.randomString(10));
|
||||
store.setDetailAddress("普陀区-" + RandomUtil.randomString(10));
|
||||
store.setLatitude(random.nextDouble() * 10);
|
||||
store.setLongitude(random.nextDouble() * 10);
|
||||
store.setDistance(random.nextInt(1000));
|
||||
return success(store);
|
||||
DeliveryPickUpStoreDO store = deliveryPickUpStoreService.getDeliveryPickUpStore(id);
|
||||
return success(DeliveryPickUpStoreConvert.INSTANCE.convert03(store));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class AppDeliveryPickUpStoreRespVO {
|
||||
@Schema(description = "经度", requiredMode = Schema.RequiredMode.REQUIRED, example = "6.99")
|
||||
private Double longitude;
|
||||
|
||||
@Schema(description = "距离,单位:米", example = "100") // 只有在用户传递了经纬度时,才进行计算
|
||||
private Integer distance;
|
||||
@Schema(description = "距离,单位:千米", example = "100") // 只有在用户传递了经纬度时,才进行计算
|
||||
private Double distance;
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
package cn.iocoder.yudao.module.trade.convert.delivery;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreRespVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
@ -38,4 +41,18 @@ public interface DeliveryPickUpStoreConvert {
|
||||
return AreaUtils.format(areaId);
|
||||
}
|
||||
|
||||
default List<AppDeliveryPickUpStoreRespVO> convertList(List<DeliveryPickUpStoreDO> list,
|
||||
Double latitude, Double longitude) {
|
||||
List<AppDeliveryPickUpStoreRespVO> voList = CollectionUtils.convertList(list, store -> {
|
||||
AppDeliveryPickUpStoreRespVO storeVO = convert03(store);
|
||||
if (latitude != null && longitude != null) {
|
||||
storeVO.setDistance(NumberUtils.getDistance(latitude, longitude, storeVO.getLatitude(), storeVO.getLongitude()));
|
||||
}
|
||||
return storeVO;
|
||||
});
|
||||
return voList;
|
||||
}
|
||||
@Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName")
|
||||
AppDeliveryPickUpStoreRespVO convert03(DeliveryPickUpStoreDO bean);
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,11 @@ public class TradeConfigDO extends BaseDO {
|
||||
*/
|
||||
private Integer deliveryExpressFreePrice;
|
||||
|
||||
/**
|
||||
* 是否开启自提
|
||||
*/
|
||||
private Boolean deliveryPickUpEnabled;
|
||||
|
||||
// ========== 分销相关 ==========
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user