Commit 93bdb4a6 by 孙亚楠

添加创富小程序需要的接口

parent 68a71290
const system=require("../../system");
const Dao=require("../dao.base");
class BmmerchantbusinessscopeDao extends Dao{
constructor(){
super(Dao.getModelName(BmmerchantbusinessscopeDao));
}
}
module.exports=BmmerchantbusinessscopeDao;
module.exports = (db, DataTypes) => {
return db.define("bmmerchantbusinessscope", {
id: { type:DataTypes.BIGINT(20), autoIncrement:true, primaryKey : true, unique : true},
name: { type: DataTypes.STRING(100), comment:'商户名称'},
merchantId: { type: DataTypes.BIGINT(32), field:'merchant_id', comment:'商户ID' }
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'bm_merchant_businessscope',
validate: {}
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("bmuser", { return db.define("bmuser", {
openId: DataTypes.STRING(100), openId: DataTypes.STRING(100),
merchantId: { type:DataTypes.STRING(32), field: 'merchant_id', comment:'商户ID'},
mobile: DataTypes.STRING(30), mobile: DataTypes.STRING(30),
passwd: DataTypes.STRING(64), passwd: DataTypes.STRING(64),
nickname: DataTypes.STRING(64), nickname: DataTypes.STRING(64),
......
const system=require("../../system");
const ServiceBase=require("../sve.base");
class BmmerchantbusinessscopeService extends ServiceBase{
constructor(){
super(ServiceBase.getDaoName(BmmerchantbusinessscopeService));
}
}
module.exports=BmmerchantbusinessscopeService;
...@@ -10,10 +10,6 @@ class AppletBase { ...@@ -10,10 +10,6 @@ class AppletBase {
this.cacheManager = system.getObject("db.cacheManager"); this.cacheManager = system.getObject("db.cacheManager");
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
this.rc = system.getObject("util.execClient"); this.rc = system.getObject("util.execClient");
// this.wxConfig = {
// appid: "wx3fa4626b74d1e944",
// secret: "238cdac5b7d3102a367e2eafc0eaa5da"
// };
if(!config) { if(!config) {
throw new Error("请传入小程序appid和secret配置"); throw new Error("请传入小程序appid和secret配置");
} }
...@@ -35,8 +31,14 @@ class AppletBase { ...@@ -35,8 +31,14 @@ class AppletBase {
return null; return null;
} }
} }
async getUserInfo(openid) { async getUserInfo(openid,merchantId) {
return this.cacheManager["AppletUserinfoCache"].get(openid); let key ;
if(merchantId){
key= merchantId+"_"+openid;
}else{
key = openid;
}
return this.cacheManager["AppletUserinfoCache"].get(key);
} }
async decryptData(obj) { async decryptData(obj) {
......
...@@ -2,19 +2,22 @@ var system = require("../../system") ...@@ -2,19 +2,22 @@ var system = require("../../system")
const http = require("http") const http = require("http")
const querystring = require('querystring'); const querystring = require('querystring');
var settings = require("../../../config/settings"); var settings = require("../../../config/settings");
const AppletBase = require("../chuangfu.applet.base"); const AppletBase = require("../applet.base");
const logCtl = system.getObject("web.oplogCtl"); const logCtl = system.getObject("web.oplogCtl");
const fs = require("fs"); const fs = require("fs");
const moment = require("moment"); const moment = require("moment");
class xggApplet extends AppletBase { class ChuangfuApplet extends AppletBase {
constructor() { constructor() {
super(); super({
appid: "wx427b4e988444908f",
secret: "3d092eb22c3451618a9c0656b1861ac6"
});
this.bmuserSve = system.getObject("service.bmuserSve"); this.bmuserSve = system.getObject("service.bmuserSve");
this.bmuserbizSve = system.getObject("service.bmuserbizSve"); this.bmuserbizSve = system.getObject("service.bmuserbizSve");
this.bmmerchantSve = system.getObject("service.bmmerchantSve"); this.bmmerchantSve = system.getObject("service.bmmerchantSve");
this.bmorderSve = system.getObject("service.bmorderSve"); this.bmorderSve = system.getObject("service.bmorderSve");
this.bmmerchantbusinessscopeSve = system.getObject("service.bmmerchantbusinessscopeSve");
this.dictUtils = system.getObject("util.dictUtils"); this.dictUtils = system.getObject("util.dictUtils");
this.uploadCtl=system.getObject("web.uploadCtl"); this.uploadCtl=system.getObject("web.uploadCtl");
...@@ -25,7 +28,7 @@ class xggApplet extends AppletBase { ...@@ -25,7 +28,7 @@ class xggApplet extends AppletBase {
// 设置登录缓存 // 设置登录缓存
async setLoginUser(id) { async setLoginUser(id) {
var user = await this.bmuserSve.findById(id); var user = await this.bmuserSve.findById(id);
await this.cacheManager["BMUserCache"].set(user.openId, JSON.stringify(user)); await this.cacheManager["BMUserCache"].set(this.merchantId+"_"+user.openId, JSON.stringify(user));
return user; return user;
} }
...@@ -51,10 +54,11 @@ class xggApplet extends AppletBase { ...@@ -51,10 +54,11 @@ class xggApplet extends AppletBase {
// TODO 找文档,看失效时间 // TODO 找文档,看失效时间
this.redisClient.set("session_key_" + decryptData.openId, wxSession.session_key); this.redisClient.set("session_key_" + decryptData.openId, wxSession.session_key);
console.log("wx ------------------------------------ login"); console.log("wx ------------------------------------ login");
user = await this.bmuserSve.findOne({openId: decryptData.openId}); user = await this.bmuserSve.findOne({openId: decryptData.openId,merchantId:this.merchantId});
if (!user) { if (!user) {
user = { user = {
openId: decryptData.openId, openId: decryptData.openId,
merchantId:this.merchantId,
mobile: "", mobile: "",
passwd: "", passwd: "",
nickname: decryptData.nickName, nickname: decryptData.nickName,
...@@ -66,7 +70,7 @@ class xggApplet extends AppletBase { ...@@ -66,7 +70,7 @@ class xggApplet extends AppletBase {
//创建用户信息 //创建用户信息
user = await this.bmuserSve.create(user); user = await this.bmuserSve.create(user);
} }
this.cacheManager["BMUserCache"].set(decryptData.openId, JSON.stringify(user)); this.cacheManager["BMUserCache"].set(this.merchantId+"_"+decryptData.openId, JSON.stringify(user));
} }
return { return {
code: 1, code: 1,
...@@ -233,6 +237,7 @@ class xggApplet extends AppletBase { ...@@ -233,6 +237,7 @@ class xggApplet extends AppletBase {
bank: obj.bank, bank: obj.bank,
bankno: obj.bankno, bankno: obj.bankno,
bankMobile: obj.bankMobile || "", bankMobile: obj.bankMobile || "",
businessScope:obj.businessScope || ""
}; };
rs.code = 1; rs.code = 1;
...@@ -253,6 +258,7 @@ class xggApplet extends AppletBase { ...@@ -253,6 +258,7 @@ class xggApplet extends AppletBase {
pageSize: pobj.pageSize || 10, pageSize: pobj.pageSize || 10,
currentPage: pobj.currentPage || 1, currentPage: pobj.currentPage || 1,
userId: loginUser.id, userId: loginUser.id,
merchantId:this.merchantId
} }
var page = await this.bmorderSve.pageByCondition(params); var page = await this.bmorderSve.pageByCondition(params);
...@@ -274,8 +280,6 @@ class xggApplet extends AppletBase { ...@@ -274,8 +280,6 @@ class xggApplet extends AppletBase {
stack : e.stack stack : e.stack
}; };
} }
console.log(decryptData);
} }
async idcardValid(gobj, pobj, req, loginUser){ async idcardValid(gobj, pobj, req, loginUser){
...@@ -309,5 +313,32 @@ class xggApplet extends AppletBase { ...@@ -309,5 +313,32 @@ class xggApplet extends AppletBase {
return {code: 500}; return {code: 500};
} }
} }
/**
* 经营范围
* @param {*} gobj
* @param {*} pobj
* @param {*} req
* @param {*} loginUser
*/
async businessscopes(gobj, pobj, req, loginUser){
try {
let where ={};
if(loginUser){
where.merchantId = loginUser.merchantId;
}else{
where.merchantId = this.merchantId;
}
let res = await this.bmmerchantbusinessscopeSve.dao.model.findAll({where:where});
for (let item of res) {
item.dataValues.type = false;
}
return res;
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误 错误信息 ${error}`);
}
}
} }
module.exports = xggApplet; module.exports = ChuangfuApplet;
\ No newline at end of file \ No newline at end of file
...@@ -7,10 +7,10 @@ var settings={ ...@@ -7,10 +7,10 @@ var settings={
}, },
database:{ database:{
dbname : "xgg", dbname : "xgg",
user : "root", user : "write",
password : "root", password : "write",
config : { config : {
host: '192.168.18.110', host: '192.168.18.237',
dialect: 'mysql', dialect: 'mysql',
operatorsAliases: false, operatorsAliases: false,
pool: { pool: {
......
...@@ -67,6 +67,10 @@ module.exports = function (app) { ...@@ -67,6 +67,10 @@ module.exports = function (app) {
params.push(req); params.push(req);
var key = req.body.key; var key = req.body.key;
if (key) { if (key) {
//如果是 创富 merchantId=3 key = merchant_openId
if(classPath=="chuangfuApplet"){
key = "3_"+key;
}
params.push(JSON.parse(await cacheManager["BMUserCache"].get(key))); params.push(JSON.parse(await cacheManager["BMUserCache"].get(key)));
} }
var p = null; var p = null;
......
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