UNPKG

tplus-pos

Version:

pos module

130 lines (114 loc) 4.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CalcMultQuantityControlProcessor = undefined; var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _createClass2 = require("babel-runtime/helpers/createClass"); var _createClass3 = _interopRequireDefault(_createClass2); var _Enum = require("../../../../commom/Enum"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var CalcMultQuantityControlProcessor = exports.CalcMultQuantityControlProcessor = function () { function CalcMultQuantityControlProcessor() { (0, _classCallCheck3.default)(this, CalcMultQuantityControlProcessor); } (0, _createClass3.default)(CalcMultQuantityControlProcessor, null, [{ key: "execute", value: function execute(promotionDto) { var mult = 0; //计算成倍返现金额 (控制组合数量的情况) switch (promotionDto.PromotionObject) { case _Enum.PromotionObject.DR_PromotionObject_00: //存货 mult = this.getMultForInventory(promotionDto); break; case _Enum.PromotionObject.DR_PromotionObject_01: //分类 mult = this.getMultForClass(promotionDto); break; case _Enum.PromotionObject.DR_PromotionObject_02: //品牌 mult = this.getMultForCorpBrand(promotionDto); break; } return mult; } //获取存货类型的返现倍数 }, { key: "getMultForInventory", value: function getMultForInventory(promotionDto) { var InventoryList = []; var minMult = 0; promotionDto.RetailDetails.forEach(function (item) { var key = item.Idinventory + "_" + item.Idunit; var info = InventoryList.find(function (it) { return it.Key == key; }); if (info) { info.Quantity = info.Quantity + item.Quantity; } else { info = {}; info.Key = key; info.Quantity = item.Quantity; InventoryList.push(info); } }); promotionDto.Details.forEach(function (item) { var key = item.Idinventory + "_" + item.Idunit; var info = InventoryList.find(function (it) { return it.Key == key; }); if (info) { var mult = parseInt(Math.Divide(info.Quantity, item.TrussQuantity)); if (minMult == 0 || mult <= minMult) { minMult = mult; } } }); return minMult; } //获取促销对象为分类的倍数 }, { key: "getMultForClass", value: function getMultForClass(promotionDto) { var minMult = 0; promotionDto.Details.forEach(function (item) { var totalQuantity = 0; promotionDto.RetailDetails.filter(function (it) { return it.Inventory.InventoryClass.InId.indexOf(item.Inid) == 0; }).forEach(function (detail) { totalQuantity = totalQuantity + detail.Quantity; }); var mult = parseInt(Math.Divide(totalQuantity, item.TrussQuantity)); if (minMult == 0 || mult <= minMult) { minMult = mult; } }); return minMult; } //获取促销对象为品牌的倍数 }, { key: "getMultForCorpBrand", value: function getMultForCorpBrand(promotionDto) { var minMult = 0; promotionDto.Details.forEach(function (item) { var totalQuantity = 0; promotionDto.RetailDetails.filter(function (it) { return it.Inventory.ProductInfo.Id == item.CorpBrand.Id; }).forEach(function (detail) { totalQuantity = totalQuantity + detail.Quantity; }); var mult = parseInt(Math.Divide(totalQuantity, item.TrussQuantity)); if (minMult == 0 || mult <= minMult) { minMult = mult; } }); return minMult; } }]); return CalcMultQuantityControlProcessor; }(); /** * 计算控制组合数量的倍数 */ //# sourceMappingURL=CalcMultQuantityControlProcessor.js.map