tplus-pos
Version:
pos module
119 lines (102 loc) • 5.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RunSingleDiscountProcessBlock = undefined;
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _SingleDiscountProcessBlock = require('./SingleDiscountProcessBlock');
var _SingleWholeDiscountProcessBlock = require('./SingleWholeDiscountProcessBlock');
require('../../../../commom/Challenger');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var RunSingleDiscountProcessBlock = exports.RunSingleDiscountProcessBlock = function () {
function RunSingleDiscountProcessBlock() {
(0, _classCallCheck3.default)(this, RunSingleDiscountProcessBlock);
}
(0, _createClass3.default)(RunSingleDiscountProcessBlock, null, [{
key: 'execute',
value: function execute(retailDto, detailDto, isNew) {
var promotionTypeName = '手工改价';
if (detailDto) {
//手工改价后,不执行单品促销
if (detailDto.IsPresent || detailDto.PromotionTypeStr && detailDto.PromotionTypeStr.indexOf(promotionTypeName) >= 0) {
return false;
}
//如果是新请求则需要重新写入原始的会员折扣和会员价格
if (isNew) {
JSON.setCellValue(detailDto, "OrigMemberDiscountRate", detailDto.MemberDiscountRate);
JSON.setCellValue(detailDto, "OrigMemberPrice", detailDto.MemberPrice);
}
var promotiondto = null;
var promotiondtoStr = JSON.getCellValue(detailDto, "promotiondto");
if (promotiondtoStr) {
promotiondto = JSON.parse(promotiondtoStr);
}
if (promotiondto) {
{
var detailList = retailDto.RetailDetails.filter(function (it) {
return it.Idinventory == detailDto.Idinventory && it.Idunit == detailDto.Idunit && !it.IsPresent;
});
if (promotiondto.IsWholeDiscount) {
_SingleWholeDiscountProcessBlock.SingleWholeDiscountProcessBlock.execute(retailDto, detailList, promotiondto);
} else {
_SingleDiscountProcessBlock.SingleDiscountProcessBlock.execute(retailDto, detailList, promotiondto);
}
}
}
} else {
var promotionList = [];
//查询需要执行单品打折的存货ID
retailDto.RetailDetails.forEach(function (item) {
//手工改价后,不执行单品促销
if (item.IsPresent || item.PromotionTypeStr && item.PromotionTypeStr.indexOf(promotionTypeName) >= 0) {
return false;
}
if (isNew) {
JSON.setCellValue(item, "OrigMemberDiscountRate", item.MemberDiscountRate);
JSON.setCellValue(item, "OrigMemberPrice", item.MemberPrice);
}
var promotiondtoStr = JSON.getCellValue(item, "promotiondto");
if (!promotiondtoStr) {
return false;
}
var promotiondto = JSON.parse(promotiondtoStr);
if (!promotiondto) {
return false;
}
var index = promotionList.findIndex(function (it) {
return it.ID == promotiondto.ID;
});
if (index < 0) {
promotionList.push(promotiondto);
}
});
if (promotionList.length > 0) {
promotionList.forEach(function (item) {
var detailList = retailDto.RetailDetails.filter(function (it) {
return JSON.getCellValue(it, "promotiondto") && JSON.parse(JSON.getCellValue(it, "promotiondto")) && JSON.parse(JSON.getCellValue(it, "promotiondto")).ID == item.ID;
});
if (detailList.length > 0) {
if (item.IsWholeDiscount) {
_SingleWholeDiscountProcessBlock.SingleWholeDiscountProcessBlock.execute(retailDto, detailList, item);
} else {
_SingleDiscountProcessBlock.SingleDiscountProcessBlock.execute(retailDto, detailList, item);
}
}
});
}
}
}
}]);
return RunSingleDiscountProcessBlock;
}();
/**
*批量执行单品打折相关处理
*
* @export
* @class RunSingleDiscountProcessBlock
*/
//执行单品打折促销方式
//# sourceMappingURL=RunSingleDiscountProcessBlock.js.map