Commit 166207a7 by 王昆

Merge branch 'bpo-channel' of gitlab.gongsibao.com:jiangyong/zhichan into bpo-channel

parents 9f172da1 3b49459b
......@@ -71,13 +71,16 @@ class ActionAPI extends APIBase {
case "merchantSave":
opResult = await this.channelmerchantSve.save(action_body);
break;
case "merchantSaves":
opResult = await this.channelmerchantSve.merchantSaves(action_body);
break;
case "merchantPage":
opResult = await this.channelmerchantSve.page(action_body);
break;
case "getPushMerchantIds" :
opResult = await this.channelmerchantSve.getPushMerchantIds(action_body);
break;
//渠道绑定
case "bindPlatform":
opResult = await this.platformchannelService.bindPlatform(action_body);
......
......@@ -53,6 +53,37 @@ class ChannelmerchantService extends ServiceBase {
}
async merchantSaves(params) {
let mcht;
if(params.id) {
mcht = await this.dao.findById(params.id);
} else {
mcht = {};
}
let origin = await this.originDao.findById(params.origin_id);
if(!origin) {
return system.getResult(null, "商户来源不存在");
}
mcht.origin_merchant_name = this.trim(params.origin_merchant_name);
mcht.merchant_name = this.trim(params.merchant_name);
mcht.contact_man = this.trim(params.contact_man);
mcht.contact_mobile = this.trim(params.contact_mobile);
mcht.contact_email = this.trim(params.contact_email);
mcht.contact_addr = this.trim(params.contact_addr);
if(mcht.id) {
await mcht.save();
} else {
mcht.channel_id = Number(params.channel_id);
mcht.origin_id = 10000;
mcht.origin_merchant_id = params.origin_merchant_id;
mcht = await this.dao.create(mcht);
}
return system.getResultSuccess(mcht);
}
async page(params) {
let currentPage = Number(params.currentPage || 1);
let pageSize = Number(params.pageSize || 10);
......@@ -71,6 +102,12 @@ class ChannelmerchantService extends ServiceBase {
[this.db.Op.like]: "%" + params.merchant_name + "%"
};
}
if(params.types == 1){
where.origin_merchant_id = "";
where.origin_merchant_name = "";
}
let orderby = [
["id", 'desc']
];
......@@ -80,11 +117,32 @@ class ChannelmerchantService extends ServiceBase {
for (var row of page.rows) {
this.handleDate(row, ["created_at"], null, -8);
}
if(!params.types && params.types == 0 ){
await this.setpage(page)
}
await this.setChannelInfo(page.rows);
}
return system.getResultSuccess(page);
}
async setpage(page){
var rows = page.rows;
if (!rows || rows.length == 0) {
return;
}
var row = [];
for (var i=0;i<rows.length; i++){
if(rows[i].origin_merchant_id != "" ){
row.push(rows[i]);
}
}
page.rows = row;
page.count = row.length;
}
async setChannelInfo(rows) {
if (!rows || rows.length == 0) {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment