src/main/java/cc/mrbird/febs/common/enumerates/DataDictionaryEnum.java
@@ -6,6 +6,11 @@ @Getter public enum DataDictionaryEnum { //会员每日可用订单数 BUY_TIMES("ORDER_BUY", "BUY_TIMES"), //商品补贴比例 SUBSIDY_PERCENT("GOODS_SUBSIDY", "SUBSIDY_PERCENT"), //积分池设置{"everydayRatio":10,"dividEquallyRatio":1}每日订单的百分之几,增加到积分池;每日平分百分比 SCORE_POOR_RADIO("SCORE_POOR", "SCORE_POOR_RADIO"), src/main/java/cc/mrbird/febs/common/enumerates/StarRatingEnum.java
New file @@ -0,0 +1,51 @@ package cc.mrbird.febs.common.enumerates; import lombok.Getter; import java.math.BigDecimal; @Getter public enum StarRatingEnum { /** * 定级规则 * 大于最小值,小于等于最大值 */ NORMAL("普通",0,30), ONE_STAR("一星",30,50), TWO_STAR("二星",50,100), THREE_STAR("三星",100,200); private String name; private Integer minValue; private Integer maxValue; StarRatingEnum(String name,Integer minValue, Integer maxValue) { this.name = name; this.minValue = minValue; this.maxValue = maxValue; } /** * 根据商品原价获取对应的商品星级 * @param price * @return */ public String belongStarRating(String price){ String name = StarRatingEnum.NORMAL.name; BigDecimal priceBig = new BigDecimal(price).setScale(BigDecimal.ROUND_DOWN,2); for (StarRatingEnum starRatingEnum : StarRatingEnum.values()) { BigDecimal minValue = new BigDecimal(starRatingEnum.minValue).setScale(BigDecimal.ROUND_DOWN, 2); BigDecimal maxValue = new BigDecimal(starRatingEnum.maxValue).setScale(BigDecimal.ROUND_DOWN, 2); if(priceBig.compareTo(minValue) > 0 && priceBig.compareTo(maxValue) <= 0){ name = starRatingEnum.name; } } return name; } public static void main(String[] args) { String s = StarRatingEnum.NORMAL.belongStarRating(String.valueOf(100)); System.out.println(s); } } src/main/java/cc/mrbird/febs/common/utils/MallUtils.java
@@ -33,6 +33,15 @@ return dd+getRandomNum(5); } public static String getLogisticsNum(String prefix) { SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); String dd=df.format(new Date()); if (StrUtil.isNotBlank(prefix)) { return prefix+getRandomNum(2); } return dd+getRandomNum(2); } public static String getOrderNum() { return getOrderNum(null); } src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java
@@ -114,5 +114,9 @@ private Integer hasCarriage; private BigDecimal carriage; //补贴金额 private BigDecimal subsidyAmount; //星级等级 private String starRating; } src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
@@ -2,6 +2,8 @@ import cc.mrbird.febs.common.entity.FebsResponse; import cc.mrbird.febs.common.entity.QueryRequest; import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; import cc.mrbird.febs.common.enumerates.StarRatingEnum; import cc.mrbird.febs.mall.conversion.MallGoodsConversion; import cc.mrbird.febs.mall.dto.*; import cc.mrbird.febs.mall.entity.*; @@ -38,6 +40,7 @@ private final MallGoodsStyleMapper mallGoodsStyleMapper; private final MallGoodsImagesMapper mallGoodsImagesMapper; private final MallShoppingCartMapper mallShoppingCartMapper; private final DataDictionaryCustomMapper dataDictionaryCustomMapper; @Override public IPage<AdminMallGoodsVo> getCategoryListInPage(MallGoods mallGoods, QueryRequest request) { @@ -109,7 +112,16 @@ //新增商品 MallGoods mallGoods = MallGoodsConversion.INSTANCE.dtoToEntity(addMallGoodsDto); mallGoods.setIsSale(MallGoods.ISSALE_STATUS_DISABLED); //根据商品原价获取商品星级 String originalPrice = mallGoods.getOriginalPrice(); String starRating = StarRatingEnum.NORMAL.belongStarRating(originalPrice); mallGoods.setStarRating(starRating); //根据商品原价获取商品补贴金额 DataDictionaryCustom subsidyPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SUBSIDY_PERCENT.getType() , DataDictionaryEnum.SUBSIDY_PERCENT.getCode()); BigDecimal subsidyPercent = new BigDecimal(subsidyPercentDic.getValue()).multiply(new BigDecimal(0.01)).setScale(BigDecimal.ROUND_DOWN,2); BigDecimal subsidyAmount = subsidyPercent.multiply(new BigDecimal(originalPrice)).setScale(BigDecimal.ROUND_DOWN, 2); mallGoods.setSubsidyAmount(subsidyAmount); if (mallGoods.getHasCarriage() == 2) { mallGoods.setCarriage(BigDecimal.ZERO); } @@ -344,6 +356,16 @@ if (mallGoods.getHasCarriage() == 2) { mallGoods.setCarriage(BigDecimal.ZERO); } //根据商品原价获取商品星级 String originalPrice = mallGoods.getOriginalPrice(); String starRating = StarRatingEnum.NORMAL.belongStarRating(originalPrice); mallGoods.setStarRating(starRating); //根据商品原价获取商品补贴金额 DataDictionaryCustom subsidyPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SUBSIDY_PERCENT.getType() , DataDictionaryEnum.SUBSIDY_PERCENT.getCode()); BigDecimal subsidyPercent = new BigDecimal(subsidyPercentDic.getValue()).multiply(new BigDecimal(0.01)).setScale(BigDecimal.ROUND_DOWN,2); BigDecimal subsidyAmount = subsidyPercent.multiply(new BigDecimal(originalPrice)).setScale(BigDecimal.ROUND_DOWN, 2); mallGoods.setSubsidyAmount(subsidyAmount); mallGoodsMapper.updateById(mallGoods); src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -83,10 +83,10 @@ public Long createOrder(AddOrderDto addOrderDto) { MallMember member = LoginUserUtil.getLoginUser(); MallAddressInfo address = mallAddressInfoMapper.selectAddressInfoByMemberIdAndId(member.getId(), addOrderDto.getAddressId()); if (address == null) { throw new FebsException("地址不存在"); } // MallAddressInfo address = mallAddressInfoMapper.selectAddressInfoByMemberIdAndId(member.getId(), addOrderDto.getAddressId()); // if (address == null) { // throw new FebsException("地址不存在"); // } String orderNo = MallUtils.getOrderNum(); MallOrderInfo orderInfo = new MallOrderInfo(); @@ -94,11 +94,11 @@ orderInfo.setOrderTime(new Date()); orderInfo.setMemberId(member.getId()); orderInfo.setStatus(OrderStatusEnum.WAIT_PAY.getValue()); orderInfo.setName(address.getName()); orderInfo.setAddress(address.getArea() + address.getAddress()); orderInfo.setPhone(address.getPhone()); orderInfo.setLatitude(address.getLatitude()); orderInfo.setLongitude(address.getLongitude()); // orderInfo.setName(address.getName()); // orderInfo.setAddress(address.getArea() + address.getAddress()); // orderInfo.setPhone(address.getPhone()); // orderInfo.setLatitude(address.getLatitude()); // orderInfo.setLongitude(address.getLongitude()); orderInfo.setRemark(addOrderDto.getRemark()); orderInfo.setOrderType(addOrderDto.getOrderType()); @@ -106,21 +106,21 @@ throw new FebsException("参数错误"); } int deliverType = ObjectUtil.isEmpty(addOrderDto.getDeliverType()) ? 1 : addOrderDto.getDeliverType(); if(2 == deliverType){ if(ObjectUtil.isEmpty(addOrderDto.getShopId())){ throw new FebsException("请选择门店"); } Long shopId = addOrderDto.getShopId(); MallShopApply mallShopApply = mallShopApplyMapper.selectById(shopId); if(ObjectUtil.isEmpty(mallShopApply)){ throw new FebsException("请选择门店"); } if(MallShopApply.APPLY_AGREE != mallShopApply.getStatus()){ throw new FebsException("请选择门店"); } orderInfo.setShopId(shopId); } // int deliverType = ObjectUtil.isEmpty(addOrderDto.getDeliverType()) ? 1 : addOrderDto.getDeliverType(); // if(2 == deliverType){ // if(ObjectUtil.isEmpty(addOrderDto.getShopId())){ // throw new FebsException("请选择门店"); // } // Long shopId = addOrderDto.getShopId(); // MallShopApply mallShopApply = mallShopApplyMapper.selectById(shopId); // if(ObjectUtil.isEmpty(mallShopApply)){ // throw new FebsException("请选择门店"); // } // if(MallShopApply.APPLY_AGREE != mallShopApply.getStatus()){ // throw new FebsException("请选择门店"); // } // orderInfo.setShopId(shopId); // } this.baseMapper.insert(orderInfo); BigDecimal total = BigDecimal.ZERO; @@ -204,13 +204,13 @@ } orderInfo.setAmount(total); if(2 == deliverType){ orderInfo.setDeliverType(2); orderInfo.setCarriage(BigDecimal.ZERO); }else{ orderInfo.setDeliverType(1); orderInfo.setCarriage(carriage); } // if(2 == deliverType){ // orderInfo.setDeliverType(2); // orderInfo.setCarriage(BigDecimal.ZERO); // }else{ // orderInfo.setDeliverType(1); // orderInfo.setCarriage(carriage); // } this.baseMapper.updateById(orderInfo); agentProducer.sendOrderCancelDelayMsg(orderInfo.getId(), 15 * 60 * 1000L); @@ -322,50 +322,55 @@ orderInfo.setPayOrderNo(orderInfo.getOrderNo()); orderInfo.setPayMethod("余额支付"); orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); // orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); //订单支付成功后,订单直接变成待收货 orderInfo.setStatus(OrderStatusEnum.WAIT_FINISH.getValue()); //生成物流编号 String logisticsNo = MallUtils.getLogisticsNum(StrUtil.subSuf(payResultStr, payResultStr.length() - 2)); orderInfo.setPayTradeNo(logisticsNo); orderInfo.setPayTime(new Date()); orderInfo.setPayResult("1"); boolean hasTc = false; // boolean hasTc = false; // 静态倍数 List<MallOrderItem> orderItems = this.baseMapper.getMallOrderItemByOrderId(orderInfo.getId()); if (CollUtil.isNotEmpty(orderItems)) { for (MallOrderItem orderItem : orderItems) { MallGoods mallGoods = mallGoodsMapper.selectById(orderItem.getGoodsId()); BigDecimal score = BigDecimal.ZERO; MallGoodsSku sku = mallGoodsSkuMapper.selectById(orderItem.getSkuId()); if (mallGoods.getIsNormal() == 2) { hasTc = true; score = sku.getPresentPrice().multiply(mallGoods.getStaticMulti()).multiply(new BigDecimal(orderItem.getCnt())); // BigDecimal staticMulti = mallGoods.getStaticMulti() == null ? BigDecimal.ZERO : mallGoods.getStaticMulti(); // score = sku.getPresentPrice().multiply(staticMulti); // 普通商品也及时结算,不再10天结算 } else { score = sku.getPresentPrice(); } if (score.compareTo(BigDecimal.ZERO) > 0) { memberWalletService.add(score, member.getId(), "score"); mallMoneyFlowService.addMoneyFlow(member.getId(), score, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); // 添加业绩 mallAchieveService.add(orderItem.getId()); } } } // List<MallOrderItem> orderItems = this.baseMapper.getMallOrderItemByOrderId(orderInfo.getId()); // if (CollUtil.isNotEmpty(orderItems)) { // for (MallOrderItem orderItem : orderItems) { // MallGoods mallGoods = mallGoodsMapper.selectById(orderItem.getGoodsId()); // BigDecimal score = BigDecimal.ZERO; // MallGoodsSku sku = mallGoodsSkuMapper.selectById(orderItem.getSkuId()); // if (mallGoods.getIsNormal() == 2) { // hasTc = true; // score = sku.getPresentPrice().multiply(mallGoods.getStaticMulti()).multiply(new BigDecimal(orderItem.getCnt())); //// BigDecimal staticMulti = mallGoods.getStaticMulti() == null ? BigDecimal.ZERO : mallGoods.getStaticMulti(); //// score = sku.getPresentPrice().multiply(staticMulti); // // 普通商品也及时结算,不再10天结算 // } else { // score = sku.getPresentPrice(); // } // // if (score.compareTo(BigDecimal.ZERO) > 0) { // memberWalletService.add(score, member.getId(), "score"); // mallMoneyFlowService.addMoneyFlow(member.getId(), score, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); // // // 添加业绩 // mallAchieveService.add(orderItem.getId()); // } // } // } // 购买套餐后,升级为普通会员 if (hasTc) { MallMember mallMember = memberMapper.selectById(member.getId()); if (AgentLevelEnum.ZERO_LEVEL.name().equals(mallMember.getLevel())) { mallMember.setLevel(AgentLevelEnum.FIRST_LEVEL.name()); memberMapper.updateById(mallMember); } } // if (hasTc) { // MallMember mallMember = memberMapper.selectById(member.getId()); // if (AgentLevelEnum.ZERO_LEVEL.name().equals(mallMember.getLevel())) { // mallMember.setLevel(AgentLevelEnum.FIRST_LEVEL.name()); // memberMapper.updateById(mallMember); // } // } mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue()); agentProducer.sendAutoLevelUpMsg(member.getId()); agentProducer.sendOrderReturn(orderInfo.getId()); // agentProducer.sendAutoLevelUpMsg(member.getId()); // agentProducer.sendOrderReturn(orderInfo.getId()); break; case "4": if (orderInfo.getOrderType() != 2) { src/main/java/cc/mrbird/febs/mall/vo/AdminMallGoodsVo.java
@@ -44,4 +44,8 @@ private BigDecimal score; private int isNormal; //补贴金额 private BigDecimal subsidyAmount; //星级等级 private String starRating; } src/main/resources/application-dev.yml
@@ -19,20 +19,21 @@ password: 123456 driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://120.27.238.55:3306/db_amz?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 # username: db_mall # password: mall!@#123 # driver-class-name: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://47.111.90.145:3306/db_mall?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 # username: db_mall_coin # password: db_mall_coin123!@# # driver-class-name: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://154.91.195.148:3306/db_mall_coin?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 redis: # Redis数据库索引(默认为 0) database: 3 database: 10 # Redis服务器地址 host: 120.27.238.55 host: 127.0.0.1 # Redis服务器连接端口 port: 6379 # Redis 密码 password: xcong123 password: dapp!@#123 lettuce: pool: # 连接池中的最小空闲连接 @@ -46,10 +47,10 @@ # 连接超时时间(毫秒) timeout: 5000 rabbitmq: host: 120.27.238.55 host: 127.0.0.1 port: 5672 username: ct_rabbit password: 123456 username: xc_rabbit password: xuncong123 publisher-confirm-type: correlated pay: src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html
@@ -14,6 +14,8 @@ <div class="layui-tab-content"> <div class="layui-tab-item layui-show"> <blockquote class="layui-elem-quote blue-border">基本信息设置</blockquote> <div class="layui-form-mid layui-word-aux">商品新增后,会自动计算补贴金额,按商品原价的5%计算</div> <div class="layui-form-mid layui-word-aux">商品新增后,会自动计算星级等级,按商品原价设置</div> <div class="layui-row layui-col-space10 layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">商品名称:</label> src/main/resources/templates/febs/views/modules/goods/goodsList.html
@@ -231,10 +231,12 @@ {field: 'categaryName', title: '分类', minWidth: 140,align:'left'}, {field: 'isSale', title: '是否上架', templet: '#upOrDownSwitch', minWidth: 100,align:'center'}, {field: 'isHot', title: '是否主推', templet: '#isHotSwitch', minWidth: 100,align:'center'}, {templet:"#goodsTypeFormat", title: '商品类型', minWidth: 140,align:'left'}, {templet:"#isSkuFormat", title: '是否多规格', minWidth: 100,align:'left'}, {field: 'presentPrice', title: '现价', minWidth: 100,align:'left'}, // {templet:"#goodsTypeFormat", title: '商品类型', minWidth: 140,align:'left'}, // {templet:"#isSkuFormat", title: '是否多规格', minWidth: 100,align:'left'}, // {field: 'presentPrice', title: '现价', minWidth: 100,align:'left'}, {field: 'originalPrice', title: '原价', minWidth: 100,align:'left'}, {field: 'subsidyAmount', title: '补贴金额', minWidth: 100,align:'left'}, {field: 'starRating', title: '星级', minWidth: 100,align:'left'}, {field: 'stock', title: '商品库存', minWidth: 100,align:'left'}, {field: 'skuVolume', title: '商品销量', minWidth: 100,align:'left'}, {title: '操作',