Commit 17f3776f by 王昆

dd

parent 521c2ac1
......@@ -110,9 +110,6 @@ class ActionAPI extends APIBase {
case "merchantTitleAddrPage": //查询 title and addr list
opResult = await this.saasmerchantSve.merchantTitleAddrPage(action_body);
break;
case "updateMerchantTitleAndAddr":
opResult = await this.saasmerchantSve.updateMerchantTitleAndAddr(action_body);
break;
case "queryInvoiceTitleAndAddr": //查询商户title&addr
opResult = await this.saasmerchantSve.queryInvoiceTitleAndAddr(action_body);
break;
......
......@@ -10,7 +10,7 @@ class SaasmerchantaddrDao extends Dao {
*/
async getAllByMerchantId(id){
let sql = `select * from saas_merchant_addr where saas_merchant_id = :saas_merchant_id`;
return await this.customUpdate(sql.join(" "), {saas_merchant_id:id});
return await this.customQuery(sql, {saas_merchant_id:id});
}
......
......@@ -7,7 +7,7 @@ class SaasmerchanttitleDao extends Dao {
async getAllByMerchantId(id){
let sql = `select * from saas_merchant_title where saas_merchant_id = :saas_merchant_id`;
return await this.customUpdate(sql.join(" "), {saas_merchant_id:id});
return await this.customQuery(sql, {saas_merchant_id:id});
}
......
......@@ -179,17 +179,17 @@ class SaasMerchantService extends ServiceBase {
merchant.contact_addr = this.trim(params.contact_addr);
merchant.term = term;
if(term_end) {
if (term_end) {
merchant.term_end = term_end;
}
if(term == 1) {
if (term == 1) {
merchant.term_end = null;
}
merchant.validity = validity;
if(validity_end) {
if (validity_end) {
merchant.validity_end = validity_end;
}
if(validity == 1) {
if (validity == 1) {
merchant.validity_end = null;
}
......@@ -273,17 +273,17 @@ class SaasMerchantService extends ServiceBase {
/**
* 商户抬头列表
* 商户抬头地址列表
* @param {*} params
*/
async merchantTitleAddrPage(params){
async merchantTitleAddrPage(params) {
try {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
let where={};
if(params.merchant_name){
let where = {};
if (params.merchant_name) {
where = {
merchant_name:this.trim(params.merchant_name)
merchant_name: this.trim(params.merchant_name)
};
}
var orderby = [
......@@ -298,167 +298,100 @@ class SaasMerchantService extends ServiceBase {
return system.getResultSuccess(page);
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误`);
return system.getResult(null, `系统错误`);
}
}
/**
* 发票信息管理修改
* @param {*} params
*/
// async updateMerchantTitleAndAddr(params){
// if(!params.id){
// return system.getResult(null,`参数错误 ID不能为空`);
// }
// let _saasmerchant = await this.dao.getById(this.trim(params.id));
// if(!_saasmerchant){
// return system.getResult(null, `系统错误 商户不存在`);
// }
// let _saasmerchanttitleArray = this.saasmerchanttitleDao.getAllByMerchantId(this.trim(params.id));
// if(_saasmerchanttitleArray.length==0){
// return system.getResult(null, `信息不存在,请核对信息ID`);
// }
// let _saasmerchantaddrArray = this.saasmerchantaddrDao.getAllByMerchantId(this.trim(params.id));
// if(!_saasmerchantaddrArray.length==0){
// return system.getResult(null, `信息不存在,请核对信息ID`);
// }
// _saasmerchanttitlePorperty.id = _saasmerchanttitleArray[0].id;
// if(params.merchant_name){
// _saasmerchanttitlePorperty.merchant_name = this.trim(params.merchant_name);
// }
// if(params.merchant_credit_code){
// _saasmerchanttitlePorperty.merchant_credit_code = this.trim(params.merchant_credit_code);
// }
// if(params.merchant_tax_type){
// _saasmerchanttitlePorperty.merchant_tax_type = this.trim(params.merchant_tax_type);
// }
// if(params.merchant_addr){
// _saasmerchanttitlePorperty.merchant_addr = this.trim(params.merchant_addr);
// }
// if(params.merchant_mobile){
// _saasmerchanttitlePorperty.merchant_mobile = this.trim(params.merchant_mobile);
// }
// if(params.merchant_bank){
// _saasmerchanttitlePorperty.merchant_bank = this.trim(params.merchant_bank);
// }
// if(params.merchant_account){
// _saasmerchanttitlePorperty.merchant_account = this.trim(params.merchant_account);
// }
// _saasmerchantaddrPorperty.id = _saasmerchantaddrArray[0].id;
// if(params.mail_addr){
// _saasmerchantaddrPorperty.mail_addr = this.trim(params.mail_addr);
// }
// if(params.mail_mobile){
// _saasmerchantaddrPorperty.mail_mobile = this.trim(params.mail_mobile);
// }
// if(params.mail_to){
// _saasmerchantaddrPorperty.mail_to = this.trim(params.mail_to);
// }
// try {
// await this.db.transaction(async t => {
// await this.saasmerchanttitleDao.update(_saasmerchanttitlePorperty,t);
// await this.saasmerchantaddrDao.update(_saasmerchantaddrPorperty,t);
// });
// return system.getResultSuccess();
// } catch (error) {
// console.log(error);
// return system.getResult(null,`系统错误`);
// }
// }
/**
* 查询发票抬头和地址
* @param {*} params
*/
async queryInvoiceTitleAndAddr(params){
if(!params.id){
return system.getResult(null,`参数错误 ID不能为空`);
async queryInvoiceTitleAndAddr(params) {
if (!params.id) {
return system.getResult(null, `参数错误 ID不能为空`);
}
try {
let _saasmerchant = await this.dao.getById(this.trim(params.id));
if(!_saasmerchant){
if (!_saasmerchant) {
return system.getResult(null, `系统错误 商户不存在`);
}
let saas_merchant_title = await this.saasmerchanttitleDao.getAllByMerchantId(_saasmerchant.id);
let saas_merchant_addr = await this.saasmerchantaddrDao.getAllByMerchantId(_saasmerchant.id);
let res = {saas_merchant_title,saas_merchant_addr};
let res = {
saas_merchant_title,
saas_merchant_addr
};
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误`);
return system.getResult(null, `系统错误`);
}
}
// async updateOrSaveTitleAndAddr(params){
// if(!params.id){
// return system.getResult(null,`参数错误 ID不能为空`);
// }
// try {
// let _saasmerchant = await this.dao.getById(this.trim(params.id));
// if(!_saasmerchant){
// return system.getResult(null, `系统错误 商户不存在`);
// }
// let saas_merchant_title_res = await this.saasmerchanttitleDao.getAllByMerchantId(_saasmerchant.id);
// let saas_merchant_addr_res = await this.saasmerchantaddrDao.getAllByMerchantId(_saasmerchant.id);
// if(params.merchant_name){
// _saasmerchanttitlePorperty.merchant_name = this.trim(params.merchant_name);
// }
// if(params.merchant_credit_code){
// _saasmerchanttitlePorperty.merchant_credit_code = this.trim(params.merchant_credit_code);
// }
// if(params.merchant_tax_type){
// _saasmerchanttitlePorperty.merchant_tax_type = this.trim(params.merchant_tax_type);
// }
// if(params.merchant_addr){
// _saasmerchanttitlePorperty.merchant_addr = this.trim(params.merchant_addr);
// }
// if(params.merchant_mobile){
// _saasmerchanttitlePorperty.merchant_mobile = this.trim(params.merchant_mobile);
// }
// if(params.merchant_bank){
// _saasmerchanttitlePorperty.merchant_bank = this.trim(params.merchant_bank);
// }
// if(params.merchant_account){
// _saasmerchanttitlePorperty.merchant_account = this.trim(params.merchant_account);
// }
// if(params.mail_addr){
// _saasmerchantaddrPorperty.mail_addr = this.trim(params.mail_addr);
// }
// if(params.mail_mobile){
// _saasmerchantaddrPorperty.mail_mobile = this.trim(params.mail_mobile);
// }
// if(params.mail_to){
// _saasmerchantaddrPorperty.mail_to = this.trim(params.mail_to);
// }
// await this.db.transaction(async t => {
// if(saas_merchant_title_res.length==0){
// await this.saasmerchanttitleDao.create(_saasmerchanttitlePorperty,t);
// }else{
// _saasmerchanttitlePorperty.id = saas_merchant_addr_res[0].id;
// await this.saasmerchanttitleDao.update(_saasmerchanttitlePorperty,t);
// }
// if(saas_merchant_addr_res.length==0){
// await this.saasmerchantaddrDao.create(_saasmerchanttitlePorperty,t);
// }else{
// _saasmerchantaddrPorperty.id = saas_merchant_addr_res[0].id;
// await this.saasmerchantaddrDao.update(_saasmerchantaddrPorperty,t);
// }
// });
// return system.getResult(res);
// } catch (error) {
// console.log(error);
// return system.getResult(null,`系统错误`);
// }
// }
async updateOrSaveTitleAndAddr(params) {
if (!params.id) {
return system.getResult(null, `参数错误 ID不能为空`);
}
try {
let _saasmerchant = await this.dao.getById(this.trim(params.id));
if (!_saasmerchant) {
return system.getResult(null, `系统错误 商户不存在`);
}
let saas_merchant_title_res = await this.saasmerchanttitleDao.getAllByMerchantId(_saasmerchant.id);
let saas_merchant_addr_res = await this.saasmerchantaddrDao.getAllByMerchantId(_saasmerchant.id);
let _saasmerchanttitlePorperty = {saas_merchant_id:_saasmerchant.id};
if (params.merchant_name) {
_saasmerchanttitlePorperty.merchant_name = this.trim(params.merchant_name);
}
if (params.merchant_credit_code) {
_saasmerchanttitlePorperty.merchant_credit_code = this.trim(params.merchant_credit_code);
}
if (params.merchant_tax_type) {
_saasmerchanttitlePorperty.merchant_tax_type = this.trim(params.merchant_tax_type);
}
if (params.merchant_addr) {
_saasmerchanttitlePorperty.merchant_addr = this.trim(params.merchant_addr);
}
if (params.merchant_mobile) {
_saasmerchanttitlePorperty.merchant_mobile = this.trim(params.merchant_mobile);
}
if (params.merchant_bank) {
_saasmerchanttitlePorperty.merchant_bank = this.trim(params.merchant_bank);
}
if (params.merchant_account) {
_saasmerchanttitlePorperty.merchant_account = this.trim(params.merchant_account);
}
let _saasmerchantaddrPorperty = {saas_merchant_id:_saasmerchant.id};
if (params.mail_addr) {
_saasmerchantaddrPorperty.mail_addr = this.trim(params.mail_addr);
}
if (params.mail_mobile) {
_saasmerchantaddrPorperty.mail_mobile = this.trim(params.mail_mobile);
}
if (params.mail_to) {
_saasmerchantaddrPorperty.mail_to = this.trim(params.mail_to);
}
let res = await this.db.transaction(async t => {
if (saas_merchant_title_res.length == 0) {
await this.saasmerchanttitleDao.create(_saasmerchanttitlePorperty, t);
} else {
_saasmerchanttitlePorperty.id = saas_merchant_title_res[0].id;
await this.saasmerchanttitleDao.update(_saasmerchanttitlePorperty, t);
}
if (saas_merchant_addr_res.length == 0) {
await this.saasmerchantaddrDao.create(_saasmerchantaddrPorperty, t);
} else {
_saasmerchantaddrPorperty.id = saas_merchant_addr_res[0].id;
await this.saasmerchantaddrDao.update(_saasmerchantaddrPorperty, t);
}
});
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
}
}
module.exports = SaasMerchantService;
module.exports = SaasMerchantService;
\ No newline at end of file
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