|
@@ -39,6 +39,30 @@ class PayCalculate {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ calculateTpExpr(pay, first, addRela) {
|
|
|
|
+ let formula = pay.expr;
|
|
|
|
+ for (const b of this.bases) {
|
|
|
|
+ if ((b.code === 'bqwc') && (first && pay.sprice)) {
|
|
|
|
+ formula = formula.replace(b.reg, this.ctx.helper.sub(addRela.gather_tp, pay.sprice));
|
|
|
|
+ } else {
|
|
|
|
+ formula = formula.replace(b.reg, b.value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const percent = formula.match(this.percentReg);
|
|
|
|
+ if (percent) {
|
|
|
|
+ for (const p of percent) {
|
|
|
|
+ const v = math.eval(p.replace('%', '/100'));
|
|
|
|
+ formula = formula.replace(p, v);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ const value = math.eval(formula);
|
|
|
|
+ return value;
|
|
|
|
+ } catch(err) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
calculateExpr(expr) {
|
|
calculateExpr(expr) {
|
|
let formula = expr;
|
|
let formula = expr;
|
|
for (const b of this.bases) {
|
|
for (const b of this.bases) {
|
|
@@ -135,8 +159,9 @@ class PayCalculate {
|
|
for (const p of pays) {
|
|
for (const p of pays) {
|
|
if (p.ptype === payType.normal || p.ptype === payType.wc) {
|
|
if (p.ptype === payType.normal || p.ptype === payType.wc) {
|
|
if (p.expr && p.expr !== '') {
|
|
if (p.expr && p.expr !== '') {
|
|
- const value = this.ctx.helper.round(this.calculateExpr(p.expr), this.decimal);
|
|
|
|
if (!p.pause && (!p.sprice || addRela.gather_tp > p.sprice)) {
|
|
if (!p.pause && (!p.sprice || addRela.gather_tp > p.sprice)) {
|
|
|
|
+ const first = !(p.pre_tp && !this.ctx.helper.checkZero(p.pre_tp));
|
|
|
|
+ const value = this.ctx.helper.round(this.calculateTpExpr(p, first, addRela), this.decimal);
|
|
if (p.rprice) {
|
|
if (p.rprice) {
|
|
if (this.checkDeadline(p)) {
|
|
if (this.checkDeadline(p)) {
|
|
p.tp = this.ctx.helper.sub(p.rprice, p.pre_total_price);
|
|
p.tp = this.ctx.helper.sub(p.rprice, p.pre_total_price);
|