Commit c3007dba by zhaoxiqing

gsb

parent 5652e58f
...@@ -5,6 +5,7 @@ const CtlBase = require("../ctl.base"); ...@@ -5,6 +5,7 @@ const CtlBase = require("../ctl.base");
class ChannelCtl extends CtlBase { class ChannelCtl extends CtlBase {
constructor() { constructor() {
super(CtlBase.getServiceName(ChannelCtl)); super(CtlBase.getServiceName(ChannelCtl));
this.offlinecompanySve = system.getObject("service.offlinecompanySve")
} }
// 来源 // 来源
...@@ -87,6 +88,12 @@ class ChannelCtl extends CtlBase { ...@@ -87,6 +88,12 @@ class ChannelCtl extends CtlBase {
} }
async merchantSave(queryobj, obj, req) { async merchantSave(queryobj, obj, req) {
try { try {
if(obj.origin_id == 10001){
var offlinecompany = await this.offlinecompanySve.updateCreate(obj);
if(offlinecompany != -1){
obj.origin_merchant_id = offlinecompany.id;
}
}
return await this.service.merchantSave(obj); return await this.service.merchantSave(obj);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
......
...@@ -12,6 +12,7 @@ class esettleofflineCtl extends CtlBase { ...@@ -12,6 +12,7 @@ class esettleofflineCtl extends CtlBase {
this.userSve = system.getObject("service.userSve"); this.userSve = system.getObject("service.userSve");
this.epartnerSve = system.getObject("service.epartnerSve"); this.epartnerSve = system.getObject("service.epartnerSve");
this.ecompanySve = system.getObject("service.ecompanySve"); this.ecompanySve = system.getObject("service.ecompanySve");
this.offlinecompanySve = system.getObject("service.offlinecompanySve")
} }
async save(queryobj, qobj, req) { async save(queryobj, qobj, req) {
...@@ -128,5 +129,15 @@ class esettleofflineCtl extends CtlBase { ...@@ -128,5 +129,15 @@ class esettleofflineCtl extends CtlBase {
return system.getErrResult2("您的网络不稳, 请稍后重试"); return system.getErrResult2("您的网络不稳, 请稍后重试");
} }
} }
async suggest(queryobj, qobj, req) {
var name = this.trim(qobj.name);
if(!name) {
return system.getResult2([])
}
var list = await this.offlinecompanySve.suggest(name);
return system.getResult2(list);
}
} }
module.exports = esettleofflineCtl; module.exports = esettleofflineCtl;
...@@ -4,5 +4,16 @@ class OfflinecompanyDao extends Dao{ ...@@ -4,5 +4,16 @@ class OfflinecompanyDao extends Dao{
constructor(){ constructor(){
super(Dao.getModelName(OfflinecompanyDao)); super(Dao.getModelName(OfflinecompanyDao));
} }
async suggest(name) {
if (!name) {
return [];
}
var sql = "SELECT id, company_name as name FROM `c_offline_company` WHERE company_name LIKE :queryLike AND deleted_at IS NULL ";
sql = sql + " ORDER BY id ASC ";
var list = await this.customQuery(sql, {queryLike: "%" + name + "%"});
return list || [];
}
} }
module.exports=OfflinecompanyDao; module.exports=OfflinecompanyDao;
...@@ -7,10 +7,9 @@ class OfflinecompanyService extends ServiceBase{ ...@@ -7,10 +7,9 @@ class OfflinecompanyService extends ServiceBase{
} }
async updateCreate(params){ async updateCreate(params){
var offlinecompany = await this.dao.findOne({company_name : params.company_name}); params.company_name =params.merchant_name;
var offlinecompany = await this.dao.findOne({company_name : params.merchant_name});
if(offlinecompany){ if(offlinecompany){
// params.id = offlinecompany.id;
// var saveId = await this.dao.update(params);
offlinecompany.contact_man = params.contact_man; offlinecompany.contact_man = params.contact_man;
offlinecompany.contact_mobile = params.contact_mobile; offlinecompany.contact_mobile = params.contact_mobile;
offlinecompany.contact_email = params.contact_email; offlinecompany.contact_email = params.contact_email;
...@@ -19,14 +18,18 @@ class OfflinecompanyService extends ServiceBase{ ...@@ -19,14 +18,18 @@ class OfflinecompanyService extends ServiceBase{
if(updates.id > 0){ if(updates.id > 0){
return updates; return updates;
} }
return system.getErrResult2("修改失败"); return -1;
} }
var saves = await this.dao.create(params); var saves = await this.dao.create(params);
if(saves.id > 0){ if(saves.id > 0){
return saves; return saves;
} }
return system.getErrResult2("保存失败"); return -1;
} }
async suggest(name) {
return await this.dao.suggest(name);
}
} }
module.exports=OfflinecompanyService; module.exports=OfflinecompanyService;
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
getCompanyNames(query) { getCompanyNames(query) {
var self = this; var self = this;
self.nameLoading = true; self.nameLoading = true;
self.$root.postReq("/web/ecompanyCtl/suggest", { self.$root.postReq("/web/esettleofflineCtl/suggest", {
name: query name: query
}).then(function (d) { }).then(function (d) {
self.nameLoading = false; self.nameLoading = false;
......
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