Commit acda6956 by 王栋源

wdy

parent 010a8729
......@@ -63,7 +63,8 @@ class APIBase {
"action.info",
"action.error",
"auth.getToken",
"auth.getJdSign"
"auth.getJdSign",
"task.zc2channel"
];
var x = lst.indexOf(fullname);
return x >= 0;
......
var APIBase = require("../../api.base");
var system = require("../../../system");
class BusinessChanceAPI extends APIBase {
constructor() {
super();
this.businesschanceSve = system.getObject("service.dbneed.businesschanceSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
pobj.actionBody["user"] = req.user;
pobj.actionBody["app"] = req.app;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
case "1688"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async opActionProcess(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "subNeed"://提交需求
opResult = await this.needinfoSve.subNeed(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
async zc2channel() {
var rtn=await this.businesschanceSve.zc2channel();
return rtn;
}
}
module.exports = BusinessChanceAPI;
\ No newline at end of file
......@@ -51,6 +51,13 @@ class Dao {
var en = await this.model.destroy({ where: { id: { [this.db.Op.in]: ids } } });
return en;
}
async bulkCreate(ids, t) {
if (t != null && t != 'undefined') {
return await this.model.bulkCreate(ids, { transaction: t });
} else {
return await this.model.bulkCreate(ids);
}
}
async delete(qobj) {
var en = await this.model.findOne({ where: qobj });
if (en != null) {
......
......@@ -12,6 +12,12 @@ class DbFactory {
dbConfig.config);
this.db.Sequelize = Sequelize;
this.db.Op = Sequelize.Op;
this.dbigirl = new Sequelize("zc",
dbConfig.user,
dbConfig.password,
dbConfig.config);
this.dbigirl.Sequelize = Sequelize;
this.dbigirl.Op = Sequelize.Op;
this.initModels();
this.initRelations();
}
......@@ -50,11 +56,11 @@ class DbFactory {
}
return this.db;
}
getConhb() {
getConigirl() {
var that = this;
if (settings.env == "dev") {
}
return this.dbhb;
return this.dbigirl;
}
}
module.exports = DbFactory;
const system=require("../../../system");
const Dao=require("../../dao.base");
class BusinesschanceDao extends Dao{
constructor(){
super(Dao.getModelName(BusinesschanceDao));
}
extraWhere(obj,w){
if(obj.codepath && obj.codepath!=""){
if(obj.codepath.indexOf("calculateprice")>0){
w["user_id"]=obj.uid;
}
}
return w;
}
}
module.exports=BusinesschanceDao;
......@@ -69,6 +69,14 @@ module.exports = {
//凭单类型
"direction_type": { "sr": "收", "zc": "支" },
"push_return_type": { "0": "推送失败", "1": "推送成功" },
"service_evaluation":{"0":"差评","5":"一般","10":"好评"},
"chanceType": {"ip": "商标", "ic": "版权", "pa": "专利", "iso": "海外业务", "common": "增值服务", "icbc": "工商注册",
"zscq": "知识产权", "cwfw": "财务服务", "hyzz": "行业资质", "gqzr": "股权转让", "xzsp": "行政审批"},
"chance_status":{"1":"待服务","2":"跟进中","4":"成功","8":"失败"},
"platform_chance_type":{"common":"普通"},
"channelProfitType": {1: "比例分成", 2: "每单分成"},
"isRecommend": {"0": "否", "1": "是"},
},
}
}
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("businesschance", {
app_id:DataTypes.INTEGER,
publisherId:DataTypes.INTEGER,//发布者id
publisherName:DataTypes.STRING,//发布者姓名
publisherMobile:DataTypes.STRING,//发布者手机号
publisherOnlyCode:DataTypes.STRING(50),//发布者唯一码
publishContent:DataTypes.STRING,//发布内容
followManId:DataTypes.INTEGER,//跟进人id(合伙人)
followManName:DataTypes.STRING,//跟进人姓名(合伙人)
followManMobile:DataTypes.STRING,//跟进人手机号(合伙人)
followManOnlyCode:DataTypes.STRING(50),//跟进者唯一码
followContent:DataTypes.STRING,//跟进内容
chanceEvaluation:{
//评论类型:"0":"差评","5":"一般","10":"好评"
type:DataTypes.ENUM,
defaultValue:"10",
values: Object.keys(uiconfig.config.pdict.service_evaluation),
set:function(val){
this.setDataValue("chanceEvaluation",val);
}
},
followTime:DataTypes.DATE,//跟进时间
chanceTypeName:DataTypes.STRING,
chanceType:{
//商机类型:"ip": "商标", "ic": "版权", "pa": "专利", "common": "增值", "icbc": "工商" “iso":"海外服务”
type:DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.chanceType),
set:function(val){
this.setDataValue("chanceType",val);
this.setDataValue("chanceTypeName",uiconfig.config.pdict.chanceType[val]);
}
},
name:DataTypes.STRING,//暂时没有用
chanceStatusName:DataTypes.STRING,
chanceStatus:{
// 商机:"1":"待服务","2":"跟进中","4":"成功","8":"失败"
type:DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.chance_status),
set:function(val){
this.setDataValue("chanceStatus",val);
this.setDataValue("chanceStatusName",uiconfig.config.pdict.chance_status[val]);
}
},
platformChanceType:{
//平台商机类型:"common":"普通"
type:DataTypes.ENUM,
defaultValue:"common",
values: Object.keys(uiconfig.config.pdict.platform_chance_type),
set:function(val){
this.setDataValue("platformChanceType",val);
}
},
notes:DataTypes.STRING,//备注
//------------------------------------------渠道相关
channelCode:{
//渠道编码:p_channel表中的channelCode
type:DataTypes.STRING(20),
defaultValue:"hhr",
},
serviceItem_code:DataTypes.STRING(20),
serviceItem_name:DataTypes.STRING,
orderNum:DataTypes.STRING(50),//自己订单号,目前与订单表无关
channelUserName:DataTypes.STRING(50),//渠道用户名
channelOrderNum:DataTypes.STRING(50),//渠道方订单号
totalSum:DataTypes.DECIMAL(12,2),//总额
channelProfitRatio:{
type:DataTypes.DECIMAL(12,2),//渠道分成比率(如:总额100,字段值30,则渠道的利润为30/100,剩下的则为平台利润)
defaultValue:0.00,
},
channelProfit:DataTypes.DECIMAL(12,2),//渠道利润
platformProfit:DataTypes.DECIMAL(12,2),//平台利润
disposeNotes:DataTypes.STRING,//处理的备注
profitTypeName:DataTypes.STRING(50),//渠道利润类型名称
profitType:{
//渠道利润类型:1: "比例分成", 2: "每单分成"
type:DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.channelProfitType),
defaultValue: "1",
set:function(val){
this.setDataValue("profitType",val);
this.setDataValue("profitTypeName",uiconfig.config.pdict.channelProfitType[val]);
},
},
isAllocationName:{
// 是否分配名称
type:DataTypes.STRING,
defaultValue:"否",
},
isAllocation:{
//是否分配:"0": "否", "1": "是"
type:DataTypes.ENUM,
defaultValue:"0",
values: Object.keys(uiconfig.config.pdict.isRecommend),
set:function(val){
this.setDataValue("isAllocation",val);
this.setDataValue("isAllocationName",uiconfig.config.pdict.isRecommend[val]);
},
defaultValue:"0",
},
allocationTime:DataTypes.DATE,//分配时间
city:DataTypes.STRING(50), // 城市
province:DataTypes.STRING(50), // 省份
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'h_business_chance',
validate: {
},
indexes:[
]
});
}
const uuidv4 = require('uuid/v4');
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class BusinesschanceService extends ServiceBase {
constructor() {
super("dbneed", ServiceBase.getDaoName(BusinesschanceService));
// this.cacheManager = system.getObject("db.cacheManager");
// this.shopSve = system.getObject("service.shopSve");
// this.servicesitemSve = system.getObject("service.servicesitemSve");
// this.pconfigSve = system.getObject("service.pconfigSve");
// this.channelSve = system.getObject("service.channelSve");
this.connectionigirl = system.getObject("db.common.connection").getConigirl();
}
async findAllChances(obj) {
return this.dao.model.findAll({ where: obj, attributes: ["id", "chanceStatus", "chanceStatusName", "publisherName", "publisherMobile", "created_at", "channelCode", "chanceType", "chanceTypeName"], raw: true, order: [["created_at", "desc"]] });
}
async findchance(obj) {
return this.dao.model.findOne({ where: obj });
}
async findAllChancesByPublisherids(ids) {
var sql = "SELECT * FROM h_business_chance WHERE user_id = " + userId;
console.log(sql);
var payUserIds = await this.dao.customQuery(sql);
return payUserIds;
}
async zc2channel() {
try {
var lastsql = "select id from h_business_chance order by id desc";
var maxid = await this.dao.customQuery(lastsql);
var id = 0
if (maxid && maxid.length > 0) {
id = maxid[0].id
}
var sql = "select * from h_business_chance where id>" + id;
var chanceinfos = await this.connectionigirl.query(sql);
if (chanceinfos) {
console.log(chanceinfos[0]);
console.log(chanceinfos[0].length);
var newchanceinfos = []
for (let i = 0; i < chanceinfos[0].length; i++) {
const chanceinfo = chanceinfos[0][i];
newchanceinfos.push(chanceinfo);
}
console.log(newchanceinfos);
var result = await this.dao.bulkCreate(newchanceinfos);
return { status: 0 };;
}
} catch (error) {
return { status: -1, msg: error };
}
}
}
module.exports = BusinesschanceService;
......@@ -151,6 +151,10 @@ class ServiceBase {
var en = await this.dao.bulkDelete(ids);
return en;
}
async bulkCreate(ids, t) {
var en = await this.dao.bulkCreate(ids, t);
return en;
}
async delete(qobj) {
return this.dao.delete(qobj);
}
......
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