|
@@ -35,7 +35,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async getAuditorStagePay(pid, sid, times, order) {
|
|
|
const pidSql = pid instanceof Array ? ' And SP.`pid` in (' + pid.join(',') + ')' : 'And SP.`pid` = ' + pid;
|
|
|
- const sql = 'SELECT SP.*, P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
+ const sql = 'SELECT SP.*, P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
' FROM ?? As SP, ?? As P ' +
|
|
|
' WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? AND SP.`pid` = P.`id` AND P.`valid`' + pidSql +
|
|
|
' ORDER BY P.`order`';
|
|
@@ -57,7 +57,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async getAuditorStageData(sid, times, order) {
|
|
|
const sql = 'SELECT SP.*,' +
|
|
|
- ' P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
+ ' P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
' FROM ?? As SP, ?? As P ' +
|
|
|
' WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? AND SP.`pid` = P.`id` AND P.`valid`' +
|
|
|
' ORDER BY P.`order`';
|
|
@@ -88,7 +88,7 @@ module.exports = app => {
|
|
|
for (const p of pays) {
|
|
|
stagePays.push({
|
|
|
tid: p.tid, sid: stage.id, pid: p.id,
|
|
|
- stimes: stage.times, sorder: 0, expr: p.expr,
|
|
|
+ stimes: stage.times, sorder: 0, expr: p.expr, name: p.name,
|
|
|
});
|
|
|
}
|
|
|
// 获取截止上期数据
|
|
@@ -100,6 +100,7 @@ module.exports = app => {
|
|
|
const prePays = await this.getStageLastestPays(preStage.id);
|
|
|
for (const pp of prePays) {
|
|
|
const sp = this._.find(stagePays, {pid: pp.pid});
|
|
|
+ sp.name = pp.name;
|
|
|
sp.expr = pp.expr;
|
|
|
sp.pre_tp= pp.end_tp;
|
|
|
sp.pause = pp.pause;
|
|
@@ -135,7 +136,7 @@ module.exports = app => {
|
|
|
* @returns {Promise<*>}
|
|
|
*/
|
|
|
async getStageLastestPays(sid) {
|
|
|
- const sql = 'SELECT SP.*, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
+ const sql = 'SELECT SP.*, P.`order`, P.uid, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
' FROM ' + this.tableName + ' As SP' +
|
|
|
' INNER JOIN ' + this.ctx.service.pay.tableName + ' As P ON SP.pid = P.id' +
|
|
|
' INNER JOIN ( ' +
|
|
@@ -184,6 +185,7 @@ module.exports = app => {
|
|
|
for (const data of datas) {
|
|
|
const stagePay = await this.getStagePay(this.ctx.stage, data.pid);
|
|
|
const updateData = { id: stagePay.id };
|
|
|
+ if (data.name !== undefined) { updateData.name = data.name }
|
|
|
if (data.expr !== undefined) { updateData.expr = data.expr }
|
|
|
if (data.tp !== undefined) { updateData.tp = data.tp }
|
|
|
if (data.pause !== undefined) { updateData.pause = data.pause }
|
|
@@ -192,14 +194,14 @@ module.exports = app => {
|
|
|
throw '保存数据失败';
|
|
|
}
|
|
|
// 缓存至pay
|
|
|
- if (data.expr !== undefined) {
|
|
|
- const pr = await transaction.update(this.ctx.service.pay.tableName, {
|
|
|
- id: data.pid, expr: data.expr
|
|
|
- });
|
|
|
- if (pr.affectedRows !== 1) {
|
|
|
- throw '保存数据失败';
|
|
|
- }
|
|
|
- }
|
|
|
+ // if (data.expr !== undefined) {
|
|
|
+ // const pr = await transaction.update(this.ctx.service.pay.tableName, {
|
|
|
+ // id: data.pid, expr: data.expr
|
|
|
+ // });
|
|
|
+ // if (pr.affectedRows !== 1) {
|
|
|
+ // throw '保存数据失败';
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
await transaction.commit();
|
|
|
} catch(err) {
|
|
@@ -243,8 +245,8 @@ module.exports = app => {
|
|
|
if (!stage || !transaction || !times || order === undefined) {
|
|
|
throw '数据错误';
|
|
|
}
|
|
|
- const sql = 'INSERT INTO ?? (`tid`, `sid`, `pid`, `stimes`, `sorder`, `tp`, `expr`, `pause`, `attachment`, `pre_tp`) ' +
|
|
|
- ' SELECT SP.`tid`, SP.`sid`, SP.`pid`, ?, ?, SP.`tp`, SP.`expr`, SP.`pause`, SP.`attachment`, SP.`pre_tp` ' +
|
|
|
+ const sql = 'INSERT INTO ?? (`tid`, `sid`, `pid`, `stimes`, `sorder`, `name`, `tp`, `expr`, `pause`, `attachment`, `pre_tp`) ' +
|
|
|
+ ' SELECT SP.`tid`, SP.`sid`, SP.`pid`, ?, ?, SP.name, SP.`tp`, SP.`expr`, SP.`pause`, SP.`attachment`, SP.`pre_tp` ' +
|
|
|
' FROM ?? As SP, ?? As P ' +
|
|
|
' WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? And SP.`pid` = P.`id` And P.`valid`';
|
|
|
const sqlParam = [this.tableName, times, order, this.tableName, this.ctx.service.pay.tableName,
|