UNPKG

tplus-pos

Version:

pos module

196 lines (161 loc) 10.5 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConvertToRetailDetailProcessor = undefined; var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _createClass2 = require('babel-runtime/helpers/createClass'); var _createClass3 = _interopRequireDefault(_createClass2); var _UpdateRetailDetailProcessor = require('./UpdateRetailDetailProcessor'); var _Enum = require('../../../commom/Enum'); var _QuantityChangeProcessorBlock = require('../quantity/QuantityChangeProcessorBlock'); var _REAlgorithmAdapter2 = require('../../../commom/REAlgorithmAdapter'); var _REAlgorithmAdapter3 = _interopRequireDefault(_REAlgorithmAdapter2); var _PersonProcessBlock = require('../person/PersonProcessBlock'); require('../../../commom/Challenger'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * 转换成零售明细DTO */ var ConvertToRetailDetailProcessor = exports.ConvertToRetailDetailProcessor = function () { function ConvertToRetailDetailProcessor() { (0, _classCallCheck3.default)(this, ConvertToRetailDetailProcessor); } (0, _createClass3.default)(ConvertToRetailDetailProcessor, null, [{ key: 'execute', value: function execute(retailDto, gifts, promotionDto) { var _this = this; gifts.forEach(function (item) { //整单单品优惠 if (promotionDto.PromotionType == _Enum.PromotionType.DR_PromotionType_04) { _this.discountsToConvert(item, retailDto, promotionDto); } else //赠品 { _this.giftsToConvert(item, retailDto, promotionDto); } }); } //赠品信息转换 }, { key: 'giftsToConvert', value: function giftsToConvert(giftDto, retailDto, promotionDto) { giftDto.IsPresent = true; if (!giftDto.RetailPrice || giftDto.RetailPrice <= 0) { giftDto.RetailPrice = giftDto.TaxPrice; giftDto.MemberPrice = giftDto.TaxPrice; } if (giftDto.TaxPrice && giftDto.TaxPrice > 0) { giftDto.IsPresent = false; } giftDto.TaxAmount = Math.Multiply(giftDto.TaxPrice, giftDto.Quantity); giftDto.RetailAmount = Math.Multiply(giftDto.RetailPrice, giftDto.Quantity); giftDto.DetailDiscountAmount = Math.Minus(giftDto.RetailAmount, giftDto.TaxAmount); // for (let index = 0; index < 10; index++) { // let freeItemName = 'freeitem' + index.toString(); // let giftFreeItemName = 'FreeItem' + index.toString(); // //let giftDtoFreeItemValue=JSON.getCellValue(giftDto,giftFreeItemName); // JSON.setCellValue(giftDto, freeItemName, giftDto[giftFreeItemName]) // } giftDto.IsDel = false; giftDto.IsUseIntegralAndCash = false; giftDto.IsUseStorage = false; giftDto.IsMemberIntegralUsedPromotion = true; JSON.setCellValue(giftDto, "isPromotionPresent", 'true'); var updatedDetail = {}; if (promotionDto.RetailDetails && promotionDto.RetailDetails[0].Idperson) { // 整单导购的场合,明细的导购=把表头的导购 updatedDetail.person = promotionDto.RetailDetails[0].Person; } // 导购相关处理 _PersonProcessBlock.PersonProcessBlock.execute(retailDto, giftDto, updatedDetail); _UpdateRetailDetailProcessor.UpdateRetailDetailProcessor.execute(giftDto, promotionDto, false, retailDto.Code); //数量改变事件 _QuantityChangeProcessorBlock.QuantityChangeProcessorBlock.execute(retailDto, giftDto, giftDto.Quantity, { isNotExecRunSingleDiscountProcessBlock: true }); var _REAlgorithmAdapter = new _REAlgorithmAdapter3.default(retailDto); _REAlgorithmAdapter.DiscountAmountChange(giftDto); retailDto.RetailDetails.push(giftDto); } //单品优惠信息转换 }, { key: 'discountsToConvert', value: function discountsToConvert(discountDto, retailDto, promotionDto) { /* let retaildetail = {} retaildetail.IsPresent = false; //金额相关 retaildetail.Amount = discountDto.Amount; retaildetail.DiscountRate = discountDto.DiscountRate; retaildetail.Price = discountDto.Price; retaildetail.Tax = discountDto.Tax; if (discountDto.Inventory.TaxRate) { retaildetail.TaxRate = Math.Divide(discountDto.Inventory.TaxRate.Name, 100); retaildetail.TaxFlag = true; } else { retaildetail.TaxRate = 0; retaildetail.TaxFlag = false; } retaildetail.TaxPrice = discountDto.TaxPrice; retaildetail.TaxAmount = discountDto.TaxAmount; retaildetail.RetailPrice = discountDto.RetailPrice; retaildetail.MemberPrice = discountDto.MemberPrice; retaildetail.MemberDiscountRate = discountDto.MemberDiscountRate; retaildetail.RetailAmount = discountDto.RetailPrice * discountDto.Quantity; retaildetail.DetailDiscountAmount = discountDto.DetailDiscountAmount; retaildetail.PromotionDetails = []; retaildetail.Idinventory = discountDto.IdInventory; retaildetail.Idunit = discountDto.IdUnit; retaildetail.Unit = discountDto.Unit; retaildetail.baseQuantity = discountDto.Quantity; retaildetail.Quantity = discountDto.Quantity; retaildetail.Inventory = discountDto.Inventory; retaildetail.idbaseUnit = discountDto.Idunit; retaildetail.ProductionDate = discountDto.ProductionDate; retaildetail.ExpiryDate = discountDto.ExpiryDate; retaildetail.InventoryBarCode = discountDto.InventoryBarCode; retaildetail.Batch = discountDto.Batch; retaildetail.FreeItem0 = discountDto.FreeItem0; retaildetail.FreeItem1 = discountDto.FreeItem1; retaildetail.FreeItem2 = discountDto.FreeItem2; retaildetail.FreeItem3 = discountDto.FreeItem3; retaildetail.FreeItem4 = discountDto.FreeItem4; retaildetail.FreeItem5 = discountDto.FreeItem5; retaildetail.FreeItem6 = discountDto.FreeItem6; retaildetail.FreeItem7 = discountDto.FreeItem7; retaildetail.FreeItem8 = discountDto.FreeItem8; retaildetail.FreeItem9 = discountDto.FreeItem9; retaildetail.IsDel = false; */ discountDto.IsPresent = false; discountDto.IsDel = false; // for (let index = 0; index < 10; index++) { // let freeItemName = 'freeitem' + index.toString(); // let discountFreeItemName = 'FreeItem' + index.toString(); // JSON.setCellValue(discountDto, freeItemName, discountDto[discountFreeItemName]) // } var _REAlgorithmAdapter = new _REAlgorithmAdapter3.default(retailDto); switch (promotionDto.CashBackWay) { case _Enum.CashBackWay.DR_CashBackWay_00: //折扣 _REAlgorithmAdapter.DiscountRateChange(discountDto); break; case _Enum.CashBackWay.DR_CashBackWay_01: //返现金 _REAlgorithmAdapter.DiscountAmountChange(discountDto); break; } var updatedDetail = {}; if (promotionDto.RetailDetails && promotionDto.RetailDetails[0].Idperson) { // 整单导购的场合,明细的导购=把表头的导购 updatedDetail.person = promotionDto.RetailDetails[0].Person; } // 导购相关处理 _PersonProcessBlock.PersonProcessBlock.execute(retailDto, discountDto, updatedDetail); _UpdateRetailDetailProcessor.UpdateRetailDetailProcessor.execute(discountDto, promotionDto, false, retailDto.Code); //数量改变事件 _QuantityChangeProcessorBlock.QuantityChangeProcessorBlock.execute(retailDto, discountDto, discountDto.Quantity, { isNotExecRunSingleDiscountProcessBlock: true }); retailDto.RetailDetails.push(discountDto); } }]); return ConvertToRetailDetailProcessor; }(); //# sourceMappingURL=ConvertToRetailDetailProcessor.js.map