当前位置: 首页 > news >正文

贵阳建站公司网店如何做推广

贵阳建站公司,网店如何做推广,百度推广竞价技巧,农家乐网站模板一、计算逻辑的类结构图 在这张图里#xff0c;顶层接口 RuleTemplate 定义了 calculate 方法#xff0c;抽象模板类 AbstractRuleTemplate 将通用的模板计算逻辑在 calculate 方法中实现#xff0c;同时它还定义了一个抽象方法 calculateNewPrice 作为子类的扩展点。各个具…一、计算逻辑的类结构图 在这张图里顶层接口 RuleTemplate 定义了 calculate 方法抽象模板类 AbstractRuleTemplate 将通用的模板计算逻辑在 calculate 方法中实现同时它还定义了一个抽象方法 calculateNewPrice 作为子类的扩展点。各个具体的优惠计算类通过继承 AbstractRuleTemplate并实现 calculateNewPrice 来编写自己的优惠计算方式。 二、代码实现 1、RuleTemplate.java public interface RuleTemplate {// 计算优惠券ShoppingCart calculate(ShoppingCart settlement); } 2、AbstractRuleTemplate.java public ShoppingCart calculate(ShoppingCart order) {// 获取订单总价Long orderTotalAmount getTotalPrice(order.getProducts());// 获取以shopId为维度的总价统计MapLong, Long sumAmount getTotalPriceGroupByShop(order.getProducts());CouponTemplateInfo template order.getCouponInfos().get(0).getTemplate();// 最低消费限制Long threshold template.getRule().getDiscount().getThreshold();// 优惠金额或者打折比例Long quota template.getRule().getDiscount().getQuota();// 如果优惠券未指定shopId则shopTotalAmountorderTotalAmount// 如果指定了shopId则shopTotalAmount对应门店下商品总价Long shopId template.getShopId();Long shopTotalAmount (shopId null) ? orderTotalAmount : sumAmount.get(shopId);// 如果不符合优惠券使用标准, 则直接按原价走不使用优惠券if (shopTotalAmount null || shopTotalAmount threshold) {log.debug(Totals of amount not meet);order.setCost(orderTotalAmount);order.setCouponInfos(Collections.emptyList());return order;}// 子类中实现calculateNewPrice计算新的价格Long newCost calculateNewPrice(orderTotalAmount, shopTotalAmount, quota);if (newCost minCost()) {newCost minCost();}order.setCost(newCost);log.debug(original price{}, new price{}, orderTotalAmount, newCost);return order; } 3、子类 MoneyOffTemplate.java Slf4j Component public class MoneyOffTemplate extends AbstractRuleTemplate implements RuleTemplate {Overrideprotected Long calculateNewPrice(Long totalAmount, Long shopAmount, Long quota) {// benefitAmount是扣减的价格// 如果当前门店的商品总价quota那么最多只能扣减shopAmount的钱数Long benefitAmount shopAmount quota ? shopAmount : quota;return totalAmount - benefitAmount;} } 4、工厂类 CouponTemplateFactory.java Component Slf4j public class CouponTemplateFactory {Autowiredprivate MoneyOffTemplate moneyOffTemplate;Autowiredprivate DiscountTemplate discountTemplate;Autowiredprivate RandomReductionTemplate randomReductionTemplate;Autowiredprivate LonelyNightTemplate lonelyNightTemplate;Autowiredprivate DummyTemplate dummyTemplate;Autowiredprivate AntiPauTemplate antiPauTemplate;public RuleTemplate getTemplate(ShoppingCart order) {// 不使用优惠券if (CollectionUtils.isEmpty(order.getCouponInfos())) {// dummy模板直接返回原价不进行优惠计算return dummyTemplate;}// 获取优惠券的类别// 目前每个订单只支持单张优惠券CouponTemplateInfo template order.getCouponInfos().get(0).getTemplate();CouponType category CouponType.convert(template.getType());switch (category) {// 订单满减券case MONEY_OFF:return moneyOffTemplate;// 随机立减券case RANDOM_DISCOUNT:return randomReductionTemplate;// 午夜下单优惠翻倍case LONELY_NIGHT_MONEY_OFF:return lonelyNightTemplate;// 打折券case DISCOUNT:return discountTemplate;case ANTI_PUA:return antiPauTemplate;// 未知类型的券模板default:return dummyTemplate;}}} 5、使用 CouponCalculationServiceImpl.java Autowiredprivate CouponTemplateFactory couponProcessorFactory;// 优惠券结算// 这里通过Factory类决定使用哪个底层Rule底层规则对上层透明Overridepublic ShoppingCart calculateOrderPrice(RequestBody ShoppingCart cart) {log.info(calculate order price: {}, JSON.toJSONString(cart));RuleTemplate ruleTemplate couponProcessorFactory.getTemplate(cart);return ruleTemplate.calculate(cart);}
http://www.hkea.cn/news/14262458/

相关文章:

  • 深圳做积分商城网站公司wordpress文件扫描
  • 做门窗安装用哪些网站找生意做网站推广一年多少钱
  • 深圳专业做网站建网站wordpress 迁移到hexo
  • 创建一个网站嘉兴有能做网站优化
  • 电子商务网站建设规划教案维修保养网站开发
  • 湛江网站排名做网站有关机械的图片
  • 网站开发去哪里找程序员全媒体网站的建设
  • 庆元县建设局网站沈阳网站建设管理
  • 建一个电商网站多少钱网站建设与运营 就业
  • 求个没封的网站2022网站的格式分类
  • 招聘做微信公众号网站维护浙江大学微纳加工平台
  • 做网站必须要dreamever北京微网站开发
  • 企业门户网站在信息系统架构中属于哪个层次做电商网站赚钱吗
  • 企业网站 数据库设计wordpress 广告源码
  • 兖州建设公司网站郑州网站建设居易国际
  • 中山网站排名信息爆炸的时代做网站
  • 怎么做子网站做网站快还是开发app快
  • 免费的网站代码昆明seo优化
  • 网站建设与管理模拟试卷缙云 网站建设
  • 网站被黑 百度跳转朋友做的网站图片不显示不出来
  • 自助建站管理平台霸州建设局网站
  • 我的世界怎么做购买点卷网站asp的网站空间
  • 做网站的公司 成都总推荐榜总点击榜总排行榜
  • 怎么做可以访问网站绵阳网站建设 科雨网络
  • 中企动力网站案例站长工具推荐网站
  • 如何写网站建设方案书折800网站模板
  • 那个网站可以做攻略网站可以做信息抓取吗
  • 网站建设过程心得体会网络科技公司是传销吗
  • 做的比较好的游戏网站2024新装修风格客厅这样装
  • wordpress做网站网上商店的优势和缺陷