tplus-pos
Version:
pos module
94 lines (80 loc) • 3.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PreWholeFullSingleProcessBlock = 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");
var _Format2 = require("../../../../commom/Format");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
*设置整单单品优惠促销价格
*
* @export
* @class PreWholeFullSingleProcessBlock
*/
var PreWholeFullSingleProcessBlock = exports.PreWholeFullSingleProcessBlock = function () {
function PreWholeFullSingleProcessBlock() {
(0, _classCallCheck3.default)(this, PreWholeFullSingleProcessBlock);
}
(0, _createClass3.default)(PreWholeFullSingleProcessBlock, null, [{
key: "execute",
value: function execute(promotionDto, discountDtos) {
var _this = this;
discountDtos.forEach(function (item) {
var PromotionDiscount = _this.getPromotionDiscounts(promotionDto, item);
switch (promotionDto.CashBackWay) {
case _Enum.CashBackWay.DR_CashBackWay_00:
//折扣
var _Format = new _Format2.Format();
item.DiscountRate = PromotionDiscount.DiscountRate;
item.TaxPrice = _Format.FormatPrice(Math.Multiply(item.RetailPrice, item.DiscountRate));
break;
case _Enum.CashBackWay.DR_CashBackWay_01:
//返现金
item.DetailDiscountAmount = Math.Multiply(PromotionDiscount.DiscountAmount, item.Quantity);
item.TaxPrice = Math.Minus(item.RetailPrice, PromotionDiscount.DiscountAmount);
break;
}
});
}
/**
* 获取当前列的key
*
* @param {*} detail
* @returns
* @memberof MergeDetailsProcessBlock
*/
}, {
key: "getPromotionDiscounts",
value: function getPromotionDiscounts(promotionDto, discountDto) {
var PromotionDiscount = {};
switch (promotionDto.PromotionObject) {
case _Enum.PromotionObject.DR_PromotionObject_00:
//商品对象
PromotionDiscount = promotionDto.PromotionDiscounts.find(function (it) {
return it.Idinventory == discountDto.Idinventory && it.Idunit == discountDto.Idunit;
});
break;
case _Enum.PromotionObject.DR_PromotionObject_01:
//商品分类
PromotionDiscount = promotionDto.PromotionDiscounts.find(function (it) {
return discountDto.Inventory.InventoryClass.InId.indexOf(it.Inid) == 0;
});
break;
case _Enum.PromotionObject.DR_PromotionObject_02:
//商品品牌
PromotionDiscount = promotionDto.PromotionDiscounts.find(function (it) {
return discountDto.Inventory.ProductInfo.Id == it.CorpBrand.Id;
});
break;
}
return PromotionDiscount;
}
}]);
return PreWholeFullSingleProcessBlock;
}();
//# sourceMappingURL=PreWholeFullSingleProcessBlock.js.map