Commit cbd0fac8 by 王栋源

wdy

parents 1f8d0bbc 96ef4a91
......@@ -22,7 +22,7 @@ class APIBase {
async doexec(gname, methodname, pobj, query, req) {
req.requestId = this.getUUID();
try {
// //验证accesskey或验签
//验证accesskey或验签
var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
if (isPassResult.status != 0) {
isPassResult.requestId = "";
......
......@@ -4,7 +4,6 @@ var settings = require("../../../../config/settings");
class OrderAPI extends APIBase {
constructor() {
super();
this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
}
/**
* 接口跳转-POST请求
......@@ -25,8 +24,8 @@ class OrderAPI extends APIBase {
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getCAProductListByTypeCode"://创建订单
opResult = await this.utilsProductSve.findByTypeCode(pobj, pobj.actionBody);
case "addOrder"://创建订单
opResult = await this.addOrder(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
......@@ -34,6 +33,36 @@ class OrderAPI extends APIBase {
}
return opResult;
}
async addOrder(pobj, actionBody) {
if (!actionBody.product_info) {
return system.getResult(null, "产品信息有误,20010");
}
var interface_info = actionBody.product_info.interface_info;
if (!interface_info) {
return system.getResult(null, "产品接口信息有误,20030");
}
if (!interface_info.interface_type) {
return system.getResult(null, "产品接口类型信息有误,20050");
}
if (!interface_info.interface_url) {
return system.getResult(null, "产品接口地址信息有误,20080");
}
var opResult = null;
if (interface_info.interface_type == "bd") {
if (!interface_info.params) {
return system.getResult(null, "产品接口参数信息有误,20110");
}//操作的方法名称
var invokeObj = system.getObject(interface_info.interface_url);
if (!invokeObj[interface_info.params]) {
return system.getResult(null, "产品接口参数方法信息有误,20130");
}
opResult = await invokeObj[interface_info.params].apply(invokeObj, pobj);
}
else if (interface_info.interface_type == "yc") {
}
return opResult;
}
}
module.exports = OrderAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class PolicyAPI extends APIBase {
constructor() {
super();
// this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
this.policyinfoSve = system.getObject("service.dbpolicy.policyinfoSve");
this.policyneedSve = system.getObject("service.dbpolicy.policyneedSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
// if (!pobj.userInfo) {
// return system.getResult(system.noLogin, "user no login!");
// }
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
if(pobj.actionType=='getPolicyNeedList' || pobj.actionType=='submitPolicyNeedNotes' ){
if (!pobj.userInfo) {
return system.getResult(system.noLogin, "user no login!");
}
if (!pobj.appInfo) {
return system.getResult(system.noLogin, "app is null!");
}
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "policyQuery"://政策检索
opResult = await this.policyinfoSve.policyQuery(pobj);
break;
case "submitPolicyNeed"://政策申请提报
// opResult = system.getResult(null, "接口开发中");
opResult = this.policyneedSve.submitPolicyNeed(pobj);
break;
case "getPolicyNeedList"://获取政策申请列表
// opResult = system.getResult(null, "接口开发中");
opResult = this.policyneedSve.getPolicyNeedList(pobj);
break;
case "submitPolicyNeedNotes"://申请信息备注提交
opResult = this.policyneedSve.submitPolicyNeedNotes(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = PolicyAPI;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class PolicyinfoDao extends Dao {
constructor() {
super(Dao.getModelName(PolicyinfoDao));
}
}
module.exports = PolicyinfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class PolicyneedDao extends Dao {
constructor() {
super(Dao.getModelName(PolicyneedDao));
}
}
module.exports = PolicyneedDao;
......@@ -28,7 +28,7 @@ module.exports = {
//订单类型
"order_type": { "zzdd": "自主订单", "dkxd": "代客下单" },
//订单付款状态
"order_pay_status": { "dfk": "待付款", "zfpz": "已上传支付凭证", "yfk": "已付款", "bfyfk": "部分已付款", "ddqx": "订单取消", "tkclz": "退款处理中", "bfytk": "部分已退款", "ytk": "已退款", "zfshbtg": "支付审核不通过" },
"order_status": { 1: "待付款", 2: "已付款", 4: "待服务", 8: "已完成" },
//帐户类型( 支付类型)
"pay_account_type": { "cash": "现金", "bank": "银行", "wx": "微信", "alipay": "支付宝", "other": "其它" },
//订单服务付款状态
......@@ -70,6 +70,8 @@ module.exports = {
"direction_type": { "sr": "收", "zc": "支" },
"push_return_type": { "0": "推送失败", "1": "推送成功" },
"push_chance_type": { "wts": "未推送", "yts": "已推送", "ygj": "已跟进", "ycd": "已成单" },
"policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'扶持措施','ssjm':'税收优惠','rlzy':'人力资源'},
"customer_intention":{"dgj":"待跟进","yyx":"有意向","wyx":"无意向"},
},
}
}
\ No newline at end of file
......@@ -14,15 +14,14 @@ module.exports = (db, DataTypes) => {
payTime :DataTypes.DATE,// 渠道有支付时间则用渠道的支付时间
quantity :DataTypes.INTEGER,// 订单数量(即产品的倍数,默认值为1)
serviceQuantity :DataTypes.INTEGER,// 订单服务数量(即与订单数量相对应)
orderPayStatusName :DataTypes.STRING(50),//
orderPayStatus :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_pay_status),
orderStatusName :DataTypes.STRING(50),//
orderStatus :{
type: DataTypes.INTEGER,
set: function (val) {
this.setDataValue("orderPayStatus", val);
this.setDataValue("orderPayStatusName", uiconfig.config.pdict.order_pay_status[val]);
this.setDataValue("orderStatus", val);
this.setDataValue("orderStatusName", uiconfig.config.pdict.order_status[val]);
}
},// 订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, bfyfk: 部分已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
},// 订单状态dfk: 1: 待付款, 2: 已付款, 4: 待服务, 8: 已完成
totalSum :DataTypes.DECIMAL(12, 2),// 订单总额(产品价格×优惠费率×订单件数)
payTotalSum :DataTypes.DECIMAL(12, 2),// 订单付款总额
refundSum :DataTypes.DECIMAL(12, 2),// 退款金额
......
......@@ -6,7 +6,7 @@ module.exports = (db, DataTypes) => {
uapp_id: DataTypes.INTEGER,//
sourceOrderNo :DataTypes.STRING(64),//来源单号
productType_id :DataTypes.INTEGER,//产品类型Id
productOneType_id :DataTypes.INTEGER,//产品大类Id
pathCode :DataTypes.STRING(512), //产品类型编码路径,如:1/2
itemCode :DataTypes.STRING(64),//产品编码
itemName :DataTypes.STRING(100),//产品名称
channelItemCode :DataTypes.STRING(100),// 渠道产品编码
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("customercontacts", {
app_id :DataTypes.INTEGER, //
customerinfo_id :DataTypes.INTEGER, //
deliveryOrderNo :DataTypes.STRING(64), // 交付订单号
mobile :DataTypes.STRING(20), //
email :DataTypes.STRING(50), //
tel :DataTypes.STRING(20), //
fax :DataTypes.STRING(50), //
name :DataTypes.STRING(1000), // 联系人
code :DataTypes.STRING(100), // 暂时没有用
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_customercontacts',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("customerinfo", {
customerTypeName :DataTypes.STRING(50), //
customerType : {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.customer_type),
set: function (val) {
this.setDataValue("customerType", val);
this.setDataValue("customerTypeName", uiconfig.config.pdict.customer_type[val]);
},
defaultValue: "0",
}, //申请企业类型: ent:企业,person:个人
identityCardPic :DataTypes.STRING(500), // 身份证图片
identityCardPdf :DataTypes.STRING(500), // 身份证pdf
businessLicensePic :DataTypes.STRING(500), // 营业执照图片
businessLicensePdf :DataTypes.STRING(500), // 营业执照pdf
name :DataTypes.STRING(1000), // 公司名称或个人名称
code :DataTypes.STRING(100), // 公司统一社会代码
app_id :DataTypes.INTEGER, //
deliveryOrderNo :DataTypes.STRING(64), // 交付订单号
applyAddr :DataTypes.STRING, // 申请地址
applyArea :DataTypes.STRING(50), // 存储省市编码
province :DataTypes.STRING(50), // 省
city :DataTypes.STRING(50), // 市
identityCardNo :DataTypes.STRING(50), // 身份证号
notes :DataTypes.STRING, // 备注
createuser_id :DataTypes.INTEGER, //
updateuser_id :DataTypes.INTEGER, //
owner_id :DataTypes.INTEGER, // 拥有者
zipCode :DataTypes.STRING(20), //
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_customerinfo',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("order", {
app_id :DataTypes.INTEGER,//
orderNo :DataTypes.STRING(64),// 订单号
channelServiceNo :DataTypes.STRING(64),// 渠道服务单号
channelOrderNo :DataTypes.STRING(1024),// 渠道订单号列表,多个以,隔开
itemCode :DataTypes.STRING(64),//
itemName :DataTypes.STRING(100),//
channelItemCode :DataTypes.STRING(64),// 渠道产品编码
channelItemName :DataTypes.STRING,// 渠道产品名称
payTime :DataTypes.DATE,// 渠道有支付时间则用渠道的支付时间
salesNum :DataTypes.INTEGER,// 项目订单数量(即服务项目的倍数,默认值为1)
salesDiliverNum :DataTypes.INTEGER,// 项目订单交付数量(即与项目订单数量相对应)
minitermNum :DataTypes.INTEGER,// 订单小项数量
minitermDiliverNum :DataTypes.INTEGER,// 订单小项交付数量
orderType :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_type),
},// 订单类型,zzdd: 自主订单,dkxd: 代客下单
orderPayStatusName: DataTypes.STRING(50),//
orderPayStatus :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_pay_status),
set: function (val) {
this.setDataValue("orderPayStatus", val);
this.setDataValue("orderPayStatusName", uiconfig.config.pdict.order_pay_status[val]);
}
},// 订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
totalServiceCharge :DataTypes.DECIMAL(12, 2),// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense :DataTypes.DECIMAL(12, 2),// 官费总额(产品配置的官费*订单件数)
totalDiscounts :DataTypes.DECIMAL(12, 2),// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
totalTaxes :DataTypes.DECIMAL(12, 2),// 税费总额(订单总额-(订单总额/(1+产品费率)))
totalSum :DataTypes.DECIMAL(12, 2),// 订单总额(产品价格×优惠费率×订单件数)
refundSum :DataTypes.DECIMAL(12, 2),// 退款金额
totalProfitSum :DataTypes.DECIMAL(12, 2),// 订单毛利润总额(订单总额-官费总额)
pfProfitSum :DataTypes.DECIMAL(12, 2),// 订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum :DataTypes.DECIMAL(12, 2),// 订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
pfSettleProfit :DataTypes.DECIMAL(12, 2),// 平台结算渠道利润,0否,1是
opNotes :DataTypes.STRING,// 备注
notes :DataTypes.STRING,// 备注
appPayType :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_pay_type),
},// 支付类型:00第三方支付,10平台代收款
createuser_id :DataTypes.INTEGER,//
updateuser_id :DataTypes.INTEGER,//
owner_id :DataTypes.INTEGER,//
creator :DataTypes.STRING(100),//
updator :DataTypes.STRING(100),//
owner :DataTypes.STRING(100),//
ownerMoblie :DataTypes.STRING(20),//
invoiceApplyStatus :DataTypes.STRING(10),// 发票状态:00: 未申请, 10: 已申请,20:已开票
channelUserId :DataTypes.STRING(64), // 渠道用户ID
needNo :DataTypes.STRING(64), // 需求单号
needNoOrderNo :DataTypes.STRING(64), // 需求订单号
sourceType: DataTypes.STRING(10),//来源类型:00订单,10需求需要用户确认方案
picUrl :DataTypes.STRING(500),// 产品图片地址
productType_id :DataTypes.INTEGER, //产品类型Id
productOneType_id :DataTypes.INTEGER, //产品大类Id
serviceItemSnapshot :DataTypes.TEXT, //产品快照
buyerMoblie :DataTypes.STRING(64), // 买家手机号
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_order',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("orderflow", {
sourceOrderNo: DataTypes.STRING(64), // 来源单号
opContent: DataTypes.STRING(1024), // 操作描述
app_id: DataTypes.INTEGER, //
notes: DataTypes.STRING, // 备注
createuser_id: DataTypes.INTEGER, //
isShow: {//是否显示
type: DataTypes.BOOLEAN,
defaultValue: false,
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_orderflow',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("ordertmproduct", {
app_id: DataTypes.INTEGER,//
productType_id: DataTypes.INTEGER,//产品类型Id
productOneType_id: DataTypes.INTEGER,//产品大类Id
itemCode: DataTypes.STRING(64),//产品编码
itemName: DataTypes.STRING(100),//产品名称
tmName: DataTypes.STRING(1000),//商标名称
tmType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.tm_type),
},//p:普通商标,j:集体商标,z:证明商标,t:特殊商标
tmFormTypeName: DataTypes.STRING(50),//
tmFormType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.tm_form_type),
set: function (val) {
this.setDataValue("tmFormType", val);
this.setDataValue("tmFormTypeName", uiconfig.config.pdict.tm_form_type[val]);
}
},//商标类型形式:1:立体,3:字,4:图,5:字图,6:颜色,7:彩色
nclOneCodes: DataTypes.STRING,//尼斯大类列表:格式以,隔开
payStatusName: DataTypes.STRING(50),//
payStatus: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_service_pay_status),
set: function (val) {
this.setDataValue("payStatus", val);
this.setDataValue("payStatusName", uiconfig.config.pdict.order_service_pay_status[val]);
}
},//支付状态:dfk:待付款,yzf:已支付
deliveryStatusName: DataTypes.STRING(50),//
deliveryStatus: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.delivery_status),
set: function (val) {
this.setDataValue("deliveryStatus", val);
this.setDataValue("deliveryStatusName", uiconfig.config.pdict.delivery_status[val]);
}
},//商标交付状态:dsccl:待上传材料,dsh:待审核,ddj:待递交, ydj: 已递交,ywc:已完成
appDataOpType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_data_op_type),
},//应用数据操作类型:00独立,10全委托,20部分委托
sourceOrderNo: DataTypes.STRING(64),//来源单号
deliveryOrderNo: DataTypes.STRING(64),//交付订单号
channelServiceNo: DataTypes.STRING(64),//渠道服务单号
channelOrderNo: DataTypes.STRING(1024),//渠道订单号列表,多个以,隔开
needNo: DataTypes.STRING(64),//需求单号
needNoOrderNo :DataTypes.STRING(64), // 需求订单号
sourceType: DataTypes.STRING(10),//来源类型:00订单,10需求需要用户确认方案
picUrl: DataTypes.STRING(500), //商标图样
colorizedPicUrl: DataTypes.STRING(500),//商标彩色图样
gzwtsUrl: DataTypes.STRING(500), //盖章委托书
sywjUrl: DataTypes.STRING(500), //声音文件
smwjUrl: DataTypes.STRING(500), //说明文件
channelUserId: DataTypes.STRING(64),//渠道用户ID
notes: DataTypes.STRING(255),//备注
createuser_id: DataTypes.INTEGER,//
updateuser_id: DataTypes.INTEGER,//
auditor_id: DataTypes.INTEGER,//
createuser: DataTypes.STRING(100),//
updateuser: DataTypes.STRING(100),//
auditor: DataTypes.STRING(100),//
nclOneCount: DataTypes.INTEGER, // 尼斯大类数量
nclCount: DataTypes.INTEGER, // 尼斯数量
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_order_tm_product',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
var base = require("../../basemodel/voucherbase")(db, DataTypes);
return db.define("receiptvoucher", Object.assign({//收款单:
//基类 code: 收款单号(自动生成)
//基类 creator: 创建者
//基类 updator:/更新者
//基类 auditor: 审核者
//基类 opNotes: 操作备注
//基类 auditStatusName: //审核状态名称
//基类 auditStatus: //审核状态:ENUM=audit_status,"dsh": "待审核", "btg": "不通过", "tg": "通过"
//基类 sourceTypeName: //来源类型名称
//基类 sourceType: //来源类型:ENUM=source_type,"order": "订单","expensevoucher": "费用单","receiptvoucher": "收款单","refundvoucher": "退款单", "trademark": "商标单"
//基类 sourceOrderNo: DataTypes.STRING,//来源单号(如:订单号等)
//基类 channelServiceNo //渠道服务单号
createapp_id: DataTypes.INTEGER,//
payuser_id: DataTypes.INTEGER,//
busPayOrderCode: DataTypes.STRING(100),//业务支付订单号
payOrderNo: DataTypes.STRING, //支付凭证流水单号,如:微信支付凭证单号
receiptTypeName: DataTypes.STRING,
receiptType: {//收款类型,"sk": "收款","csrz": "初始入账" ,"ptdsk": "平台代收款"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.receipt_type),
set: function (val) {
this.setDataValue("receiptType", val);
this.setDataValue("receiptTypeName", uiconfig.config.pdict.receipt_type[val]);
}
},
accountType: {
//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.pay_account_type),
set: function (val) {
this.setDataValue("accountType", val);
this.setDataValue("accountTypeName", uiconfig.config.pdict.pay_account_type[val]);
},
defaultValue: "other",
},
accountTypeName: {//帐户类型名称
type: DataTypes.STRING,
defaultValue: "其它",
},
payDate: DataTypes.DATE,//支付时间
totalSum: DataTypes.DECIMAL(12, 3),//订单总额(平台费用+服务费+官费+发票税费+个人利润+平台利润)
certifyFileUrl: DataTypes.STRING(500), //证明文件Url
notes: DataTypes.STRING,//备注
itemCode: DataTypes.STRING(100),//项目操作码
itemName: DataTypes.STRING(100),//项目名称
buyerOpenId: DataTypes.STRING,//用户在商户appid下的唯一标识或买家在支付宝的用户id
passTradeNo: DataTypes.STRING,//通道的统一订单号
buyerAliLogonId: DataTypes.STRING,//买家支付宝账号
}, base), {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'b_receiptvoucher',
validate: {
}
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("policyinfo", {
uapp_id :DataTypes.INTEGER,//
policyNo :DataTypes.STRING(64),// 政策编号
policyName :DataTypes.STRING(255),// 政策名称
policySource :DataTypes.STRING(255),// 政策出处
policyLinkUrl :DataTypes.STRING(255),// 政策链接
policyProvince :DataTypes.STRING(100),// 所属省份
policyCity :DataTypes.STRING(100),// 所属城市
policyContent :DataTypes.TEXT('long'),// 政策内容
policyDate :DataTypes.DATE,// 政策日期
policyTypeName: DataTypes.STRING(100),//
policyType :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.policy_type),
set: function (val) {
this.setDataValue("policyType", val);
this.setDataValue("policyTypeName", uiconfig.config.pdict.policy_type[val]);
}
},//政策类型 'zh':'综合','fzbt':'房租补贴','jrdk':'金融贷款','zdfc':'重点扶持','ssjm':'税收减免',
opNotes :DataTypes.STRING,// 备注
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_policy_info',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("policyneed", {
uapp_id :DataTypes.INTEGER,//
contacts :DataTypes.STRING(64),// 联系人
company :DataTypes.STRING(255),// 公司名称
industry :DataTypes.STRING(100),// 行业名称
region :DataTypes.STRING(100),// 地区
mobile :DataTypes.STRING(100),// 联系电话
policy_id :DataTypes.INTEGER,// 政策id
policySnapshot :DataTypes.TEXT('long'),// 政策快照
applyDate :DataTypes.DATE,// 申请日期
opNotes :DataTypes.TEXT('long'),// 备注
createUserId :DataTypes.INTEGER,// 创建用户id
popularizeUserId :DataTypes.INTEGER,// 推广人id,即业务员id
popularizeUserCode :DataTypes.STRING(64),// 推广人帐号
customerIntentionName: DataTypes.STRING(100),// 客户意向
customerIntention :{// "customer_intention":{"dgj":"待跟进","yyx":"有意向","wyx":"无意向"},
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.customer_intention),
set: function (val) {
this.setDataValue("customerIntention", val);
this.setDataValue("customerIntentionName", uiconfig.config.pdict.customer_intention[val]);
}
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_policy_need',
validate: {
},
indexes: [
]
});
}
......@@ -5,357 +5,288 @@ const uuidv4 = require('uuid/v4');
class OrderInfoService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(OrderInfoService));
this.appproductDao = system.getObject("db.dbapp.appproductDao");
this.orderProductDao = system.getObject("db.dbcorder.orderproductDao");
this.orderReceiptVoucherDao = system.getObject("db.dbcpay.orderreceiptvoucherDao");
this.orderRefundVoucherDao = system.getObject("db.dbcpay.orderrefundvoucherDao");
this.moneyJourneyDao = system.getObject("db.dbcpay.moneyjourneyDao");
this.pushlogSve = system.getObject("service.common.pushlogSve");
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
/*
* 订单验证
*/
async isOrderVerify(serviceitem,buyProductCount,buyPrice) {
var sveItemRateConfig = serviceitem.rateConfig ? Number(serviceitem.rateConfig) : 0;//产品费率
var fwf = serviceitem.serviceCharge ? Number(serviceitem.serviceCharge) : 0;//服务费
var yhfl = serviceitem.discountsRateConfig ? Number(serviceitem.discountsRateConfig) : 0;//最大优惠费率
var gf = serviceitem.publicExpense ? Number(serviceitem.publicExpense) : 0;//产品官费
var productCount = 1;//产品数量
var gfze = 0;//官费总额
var qdfcbl = serviceitem.channelProfitRate?Number(serviceitem.channelProfitRate) : 0;//渠道利润分成比率
productCount = Number(buyProductCount);//购买产品数量
buyPrice = Number(buyPrice);//购买价格
gfze = gf * Number(productCount);
var fwfze = Number(fwf) * Number(productCount);//服务费总额
var sfze = Number(buyPrice) / (sveItemRateConfig + 100) * sveItemRateConfig; //totalTaxes 税费总额
sfze = sfze.toFixed(2);
sfze = Number(sfze);
var zdyhe = (gfze + fwfze) * yhfl / 100;//最大优惠额
zdyhe = zdyhe.toFixed(2);
zdyhe = Number(zdyhe);
//毛利总额=应付总额-官费总额
var mlze = Number(buyPrice) - gfze;//totalProfitSum 毛利总额
mlze = mlze.toFixed(2);
mlze = Number(mlze);
//优惠金额=服务费+官费总额-应付总额(服务费、官费之和小于等于应付总额时,优惠金额为零)
var yhje = fwfze + gfze - Number(buyPrice);
if (yhje < 0) {
yhje = 0;
}
yhje = yhje.toFixed(2);
yhje = Number(yhje);
if (yhje > zdyhe) {
return { code: -205, msg: "优惠总额有误" };
}
var fcmlze_channel = mlze*qdfcbl ;//订单渠道分成毛利润总额
var fcmlze_platform = mlze-fcmlze_channel ;//订单平台毛利润总额
return {code:1,data:{
totalServiceCharge :fwfze,// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense :gfze,// 官费总额(产品配置的官费*订单件数)
totalTaxes :sfze,// 税费总额(订单总额-(订单总额/(1+产品费率)))
totalSum :buyPrice,// 订单总额(产品价格×优惠费率×订单件数)
totalProfitSum :mlze,// 订单毛利润总额(订单总额-官费总额)
totalDiscounts :yhje,// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
pfProfitSum :fcmlze_platform,// 订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum :fcmlze_channel,// 订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
}};
}
/**
* 创建订单
*/
async createOrder(obj,req){
var self = this;
var app = req.app;
var user = req.user;
if(!app || !app.uAppId){
return system.getResult(null, "渠道信息有误");
}
if(!user){
return system.getResult(null, "用户信息有误");
}
var channelItemCode = obj.itemCode;
if(!channelItemCode){
return system.getResult(null, "未知的产品码");
}
var productItem = await this.appproductDao.findOneByChannelItemCode(channelItemCode, app.id);//通过ChannelItemCode获取产品
// if (!productItem) {
// return system.getResult(null, "未知的产品");
// }
var verifyResult=null;
if (productItem) {
if(productItem.status != 1){
return system.getResult(null, "产品已禁用");
}
}
var channelUser = obj.channelUser;
if(!channelUser || !channelUser.channelUserId){
return system.getResult(null, "渠道用户信息有误");
}
var channelOrder = obj.channelOrder;
if(!channelOrder || !channelOrder.channelServiceNo){
return system.getResult(null, "渠道订单信息有误");
}
if(!channelOrder.quantity){
return system.getResult(null, "渠道订单产品数量不能为空");
}
if(!channelOrder.totalSum){
return system.getResult(null, "渠道订单支付金额不能为空");
}
if (productItem) {
verifyResult = await self.isOrderVerify(productItem,channelOrder.quantity,channelOrder.totalSum);
if (verifyResult && verifyResult.code!=1) {
return system.getResult(null, verifyResult.msg);
}
}
var beforeOrder = await this.dao.model.findOne({
where:{channelServiceNo:channelOrder.channelServiceNo,uapp_id:app.uAppId},
raw:true
});
if(beforeOrder){//订单已存在
return system.getResultFail(2, "订单已存在",beforeOrder.orderNo);
}
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("o");
//创建订单
var orderObj={
uapp_id:app.uAppId,orderNo:orderNo,channelServiceNo:channelOrder.channelServiceNo,
channelUserId:channelUser.channelUserId,channelOrderNo:channelOrder.channelOrderNo,
ownerUserId:channelUser.channelUserId,
quantity:channelOrder.quantity,
needNo:channelOrder.needNo,payTime:channelOrder.payTime,orderPayStatus:channelOrder.payStatus,
totalSum:channelOrder.totalSum,
payTotalSum:channelOrder.payTotalSum,
totalServiceCharge :0,// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense :0,// 官费总额(产品配置的官费*订单件数)
totalTaxes :0,// 税费总额(订单总额-(订单总额/(1+产品费率)))
totalProfitSum :0,// 订单毛利润总额(订单总额-官费总额)
totalDiscounts :0,// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
pfProfitSum :0,// 订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum :0,// 订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
// pfSettleProfit :DataTypes.INTEGER,// 平台结算渠道利润,0否,1是
invoiceApplyStatus :"00",// 发票状态:00: 未申请, 10: 已申请,20:已开票
async isOrderVerify(pobj) {
var actionBody = pobj.actionBody;
var price_list = actionBody.product_info.price_list;
if (!price_list) {
return system.getResult(null, "产品价格列表信息有误,20150");
}
var product_price = price_list.filter(f => f.id == actionBody.id);
if (!product_price || product_price.length == 0) {
return system.getResult(null, "产品价格信息有误,20180");
}
var totalSum = Number(product_price[0].price) * Number(actionBody.quantity);
if (Number(actionBody.totalSum) < totalSum) {
return system.getResult(null, "订单金额有误,20210");
}
pobj.actionBody.product_info.price_item = product_price[0];
return system.getResultSuccess();
}
async createOrder(pobj, orderNo, t) {
var actionBody = pobj.actionBody;
var channelOrder = actionBody.channelOrder;
var price_item = actionBody.product_info.price_item;
var totalServiceCharge = Number(price_item.service_charge || 0) * Number(actionBody.quantity);
var totalPublicExpense = Number(price_item.public_expense || 0) * Number(actionBody.quantity);
var totalProfitSum = Number(actionBody.totalSum) - (Number(price_item.supply_price || 0) * Number(actionBody.quantity));
var pfProfitSum = (100 - Number(price_item.channel_profit_rate)) / 100 * totalProfitSum;
if (pfProfitSum < 0) {
pfProfitSum = 0;
}
var channelProfitSum = Number(totalProfitSum) - Number(pfProfitSum);
var payTime = channelOrder.payTime || new Date();
var params = {
uapp_id: pobj.appInfo.uapp_id,//int(11) //
orderNo: orderNo,//varchar(64) //订单号
channelServiceNo: channelOrder.channelServiceNo || "",//varchar(64) //渠道服务单号
channelOrderNo: channelOrder.channelOrderNo || "",//varchar(1024) //渠道订单号列表,多个以,隔开
channelUserId: pobj.userInfo.channel_userId,//varchar(64) //
ownerUserId: pobj.userInfo.channel_userId,//varchar(20) //
needNo: channelOrder.needNo || "",//varchar(64) //需求单号
needNoOrderNo: channelOrder.needNoOrderNo || "",//varchar(64) //需求订单号
payTime: channelOrder.orderStatus && channelOrder.orderStatus == 1 ? payTime : null,//datetime //
quantity: actionBody.quantity,//int(11) //项目订单数量(即服务项目的倍数,默认值为1)
serviceQuantity: 0,//int(11) //项目订单交付数量(即与项目订单数量相对应)
orderStatus: channelOrder.orderStatus || 1,//int //订单状态: 1: 待付款, 2: 已付款, 4: 待服务, 8: 已完成
totalSum: actionBody.totalSum,//decimal(12,2) //订单总额(产品价格×优惠费率×订单件数)
payTotalSum: actionBody.payTotalSum,//decimal(12,2) //
refundSum: 0,//decimal(12,2) //退款总额
totalServiceCharge: totalServiceCharge,//decimal(12,2) //服务费总额(产品配置的服务费*订单件数)
totalPublicExpense: totalPublicExpense,//decimal(12,2) //官费总额(产品配置的官费*订单件数)
totalProfitSum: totalProfitSum,//decimal(12,2) //订单毛利润总额(产品价格-供货价格))
pfProfitSum: pfProfitSum,//decimal(12,2) //订单平台毛利润总额((100-渠道利润分成比例)/100 * 订单毛利润总额)
channelProfitSum: channelProfitSum,//decimal(12,2) //订单渠道分成毛利润总额(订单毛利润总额-平台毛利润总额)
totalDiscounts: 0,//decimal(12,2) //优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)暂时没有用到
pfSettleProfit: 0,//int(11) //平台结算渠道利润,0否,1是
invoiceApplyStatus: "00",//varchar(10) //发票状态:00: 未申请, 10: 已申请,20:已开票
notes: ,//varchar(255) //
opNotes: ,//varchar(255) //操作备注
};
if(verifyResult && verifyResult.code==1 && verifyResult.data){
var orderCostObj=verifyResult.data;
orderObj.totalServiceCharge=orderCostObj.totalServiceCharge || 0;
orderObj.totalPublicExpense=orderCostObj.totalPublicExpense || 0;
orderObj.totalTaxes=orderCostObj.totalTaxes || 0;
orderObj.totalProfitSum=orderCostObj.totalProfitSum || 0;
orderObj.totalDiscounts=orderCostObj.totalDiscounts || 0;
orderObj.pfProfitSum=orderCostObj.pfProfitSum || 0;
orderObj.channelProfitSum=orderCostObj.channelProfitSum || 0;
}
var order = await self.dao.create(orderObj,t);//创建订单
//var orderProductNo = await self.getBusUid("op");
if(productItem){
var order = await this.dao.create(params, t);//创建订单
var orderProductObj = {
uapp_id:app.uAppId,
sourceOrderNo:order.orderNo, // 来源单号
productType_id :productItem.productType_id,//产品类型Id
productOneType_id :productItem.productOneType_id,//产品大类Id
itemCode :productItem.itemCode,//产品编码
itemName :productItem.itemName,//产品名称
channelItemCode :productItem.channelItemCode,// 渠道产品编码
channelItemName :productItem.channelItemName,// 渠道产品名称
serviceItemCode :productItem.serviceItemCode,// 服务商产品编码
picUrl :productItem.picUrl,// 产品图片地址
proPrice :productItem.proPrice, // 产品价格
quantity :channelOrder.quantity,// 订单数量(即产品的倍数,默认值为1)
opPayType :"00",// 操作付款类型:00: 创建订单, 10: 补单
serviceItemSnapshot :JSON.stringify(productItem), //产品快照
uapp_id: pobj.appInfo.uapp_id,
sourceOrderNo: orderNo, // 来源单号
productType_id: price_item.productType_id,//产品类型Id
pathCode: price_item.path_code,//产品路径
itemCode: price_item.item_code,//产品编码
itemName: price_item.item_name,//产品名称
channelItemCode: price_item.channel_item_code,// 渠道产品编码
channelItemName: price_item.channel_item_name,// 渠道产品名称
serviceItemCode: price_item.service_item_code,// 服务商产品编码
picUrl: price_item.pic_url,// 产品图片地址
proPrice: actionBody.totalSum, // 产品总价格
quantity: actionBody.quantity,// 订单数量(即产品的倍数,默认值为1)
opPayType: "00",// 操作付款类型:00: 创建订单, 10: 补单
serviceItemSnapshot: JSON.stringify(actionBody.product_info), //产品快照
};
var orderProduct = await self.orderProductDao.create(orderProductObj,t);//订单产品
}
if(order.totalSum>0){//支付成功
var moneyObj={
uapp_id:app.uAppId,
sourceOrderNo:order.orderNo, // 来源单号
channelUserId:channelUser.channelUserId,
ownerUserId:channelUser.channelUserId,
var orderProduct = await this.orderProductDao.create(orderProductObj, t);//订单产品
if (channelOrder.orderStatus && channelOrder.orderStatus == 2) {//订单状态: 1: 待付款, 2: 已付款, 4: 待服务, 8: 已完成
var moneyObj = {
uapp_id: pobj.appInfo.uapp_id,
sourceOrderNo: orderNo, // 来源单号
channelUserId: pobj.userInfo.channel_userId,
ownerUserId: pobj.userInfo.channel_userId,
accountType: "other",//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
directionType: "sr",//凭单类型,"sr": "收","zc": "支"
voucherDate: channelOrder.payTime,//凭单时间
recvAmount: channelOrder.totalSum,//收总额
voucherDate: payTime,//凭单时间
recvAmount: channelOrder.payTotalSum,//收总额
sourceType: "orderinfo",//来源类型 "orderinfo": "订单","expensevoucher": "费用单"
auditStatus: "dsh",//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
auditStatus: "tg",//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
};
if(channelOrder.payStatus=='yfk' || channelOrder.payStatus=='bfyfk'){
moneyObj.auditStatus="tg";
}
var moneyJourney = await self.moneyJourneyDao.create(moneyObj,t);
var orderReceiptVoucherObj={
uapp_id:app.uAppId,
sourceOrderNo:order.orderNo, // 来源单号
var moneyJourney = await this.moneyJourneyDao.create(moneyObj, t);
var orderReceiptVoucherObj = {
uapp_id: pobj.appInfo.uapp_id,
sourceOrderNo: orderNo, // 来源单号
accountType: "other",
payDate: channelOrder.payTime,//支付时间
totalSum: channelOrder.totalSum,//订单总额
payDate: payTime,//支付时间
totalSum: channelOrder.payTotalSum,//订单总额
auditStatus: "tg"
// payOrderNo: DataTypes.STRING, //支付凭证流水单号,如:微信支付凭证单号
// buyerOpenId: DataTypes.STRING,//用户在支付商户appid下的唯一标识或买家在支付宝的用户id
// passTradeNo: DataTypes.STRING,//通道的统一订单号
// buyerAliLogonId: DataTypes.STRING,//买家支付宝账号
// certifyFileUrl: order.orderNo, //支付证明文件Url
wxPayOrderCode: order.orderNo,//业务微信支付订单号
aliPayOrderCode:order.orderNo,//业务支付宝支付订单号
busPayOrderCode: order.orderNo,//业务支付订单号
auditStatus:"dsh"
// wxPayOrderCode: order.orderNo,//业务微信支付订单号
// aliPayOrderCode: order.orderNo,//业务支付宝支付订单号
// busPayOrderCode: order.orderNo,//业务支付订单号
};
if(channelOrder.payStatus=='yfk' || channelOrder.payStatus=='bfyfk'){
orderReceiptVoucherObj.auditStatus="tg";
var orderReceiptVoucher = await this.orderReceiptVoucherDao.create(orderReceiptVoucherObj, t);
}
}
/**
* 创建商标订单
* @param {*} pobj
* {
"actionType": "addOrder",
"actionBody": {
"channelItemCode":"zzsbzc",
"id":1,
"quantity":1,
"totalSum":300,
"channelOrder":null,
"deliveryData":null
}
var orderReceiptVoucher = await self.orderReceiptVoucherDao.create(orderReceiptVoucherObj,t);
}
var requestid=self.getUUID();
if(productItem && productItem.deliveryUrl){
obj["orderNo"]=order.orderNo;
self.pushData(requestid,obj,productItem.deliveryUrl,req);
*/
async createTmOrder(pobj) {
var verifyResult = await this.isOrderVerify(pobj);
if (verifyResult.status != 0) {
return verifyResult;
}
var self = this;
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("tm" + pobj.appInfo.uapp_id);
var item = self.createOrder(pobj, orderNo, t);
return system.getResultSuccess({
orderNo:order.orderNo,
channelServiceNo:order.channelServiceNo,
channelParams:obj.channelParams,
requestid:requestid
orderNo: orderNo,
channelServiceNo: pobj.actionBody.channelOrder.channelServiceNo || orderNo,
channelParams: opobj.actionBody.channelOrder.channelParams || ""
});
});
}
/**
* 数据推送
* 创建其他订单
* @param {*} pobj
*/
async pushData(requestid,params,url,req){
var rc = system.getObject("util.execClient");
var obj = params;
var rtn = null;
try {
rtn = await rc.execPushDataPost(obj, url, req.headers["token"], req.headers["request-id"]);
var returnType = "0";
if (rtn.stdout) {
var j = JSON.parse(rtn.stdout);
if (j && j.status == 0) {
returnType = "1";
}
async createOtherOrder(pobj) {
var verifyResult = await this.isOrderVerify(pobj);
if (verifyResult.status != 0) {
return verifyResult;
}
this.pushlogSve.createDb({
appid: req.app.id,
requestId: requestid,
op: url,
content: JSON.stringify(obj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
returnType: returnType,
agent: req.uagent,
opTitle: "数据推送-创建订单",
var self = this;
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("ot" + pobj.appInfo.uapp_id);
var item = self.createOrder(pobj, orderNo, t);
return system.getResultSuccess({
orderNo: orderNo,
channelServiceNo: pobj.actionBody.channelOrder.channelServiceNo || orderNo,
channelParams: opobj.actionBody.channelOrder.channelParams || ""
});
} catch (e) {
this.pushlogSve.createDb({
appid: req.app.id,
requestId: requestid,
op: url,
content: JSON.stringify(obj),
resultInfo: JSON.stringify(e.stack),
clientIp: req.clientIp,
returnType: '0',
agent: req.uagent,
opTitle: "数据推送-创建订单",
});
}
}
async findAndCountAll(obj,req) {
var app = req.app;
if(!app || !app.uAppId){
return system.getResult(null, "渠道信息有误");
}
obj["search"]["uapp_id"]=app.uAppId;
const result = await this.dao.findAndCountAll(obj);
return system.getResultSuccess(result);
}
async getOrderDetailByOrderNo(obj,req){
var orderNo = obj.orderNo;
if(!orderNo){
return system.getResult(null, "订单编号不能为空");
}
var app = req.app;
if(!app || !app.uAppId){
return system.getResult(null, "渠道信息有误");
}
var order = await this.dao.model.findOne({
where:{orderNo:orderNo,uapp_id:app.uAppId},
attributes:["orderNo","channelServiceNo","channelOrderNo","channelUserId","ownerUserId","needNo",
"payTime","quantity","serviceQuantity","orderPayStatus","orderPayStatusName","totalSum","payTotalSum",
"refundSum","created_at","opNotes","notes"
],
raw:true
});
if(order && order.orderNo){
var orderproducts = await this.orderProductDao.model.findAll({
where:{sourceOrderNo:order.orderNo},
attributes:["sourceOrderNo","itemCode","itemName","channelItemCode","channelItemName",
"serviceItemCode","picUrl","proPrice","quantity","opPayType","serviceItemSnapshot",
"created_at"
],
raw:true
});
order["orderproducts"]=orderproducts;
var receptvouchers = await this.orderReceiptVoucherDao.model.findAll({
where:{sourceOrderNo:order.orderNo},
attributes:[
"sourceOrderNo","accountType","accountTypeName","payDate","totalSum","payOrderNo","buyerOpenId",
"passTradeNo","buyerAliLogonId","certifyFileUrl","wxPayOrderCode","aliPayOrderCode","busPayOrderCode",
"auditStatusName","auditStatus"
],
raw:true
});
order["receptvouchers"]=receptvouchers;
var refundvouchers = await this.orderRefundVoucherDao.model.findAll({
where:{sourceOrderNo:order.orderNo},
attributes:[
"busPayOrderCode",
"sourceOrderNo","accountType","accountTypeName","payDate","totalSum","payOrderNo","buyerOpenId",
"passTradeNo","certifyFileUrl","auditStatusName","auditStatus"
],
raw:true
});
order["refundvouchers"]=refundvouchers;
}
return system.getResultSuccess(order);
async createChannelSource(pobj) {//创建渠道来源订单
var orderNo = await self.getBusUid("oc" + pobj.appInfo.uapp_id);
// var beforeOrder = await this.dao.model.findOne({
// where: { channelServiceNo: channelOrder.channelServiceNo, uapp_id: app.uAppId },
// raw: true
// });
// if (beforeOrder) {//订单已存在
// return system.getResultFail(2, "订单已存在", beforeOrder.orderNo);
// }
}
/**
* 数据推送
*/
// async pushData(requestid, params, url, req) {
// var rc = system.getObject("util.execClient");
// var obj = params;
// var rtn = null;
// try {
// rtn = await rc.execPushDataPost(obj, url, req.headers["token"], req.headers["request-id"]);
// var returnType = "0";
// if (rtn.stdout) {
// var j = JSON.parse(rtn.stdout);
// if (j && j.status == 0) {
// returnType = "1";
// }
// }
// this.pushlogSve.createDb({
// appid: req.app.id,
// requestId: requestid,
// op: url,
// content: JSON.stringify(obj),
// resultInfo: JSON.stringify(rtn),
// clientIp: req.clientIp,
// returnType: returnType,
// agent: req.uagent,
// opTitle: "数据推送-创建订单",
// });
// } catch (e) {
// this.pushlogSve.createDb({
// appid: req.app.id,
// requestId: requestid,
// op: url,
// content: JSON.stringify(obj),
// resultInfo: JSON.stringify(e.stack),
// clientIp: req.clientIp,
// returnType: '0',
// agent: req.uagent,
// opTitle: "数据推送-创建订单",
// });
// }
// }
// async findAndCountAll(obj, req) {
// var app = req.app;
// if (!app || !app.uAppId) {
// return system.getResult(null, "渠道信息有误");
// }
// obj["search"]["uapp_id"] = app.uAppId;
// const result = await this.dao.findAndCountAll(obj);
// return system.getResultSuccess(result);
// }
// async getOrderDetailByOrderNo(obj, req) {
// var orderNo = obj.orderNo;
// if (!orderNo) {
// return system.getResult(null, "订单编号不能为空");
// }
// var app = req.app;
// if (!app || !app.uAppId) {
// return system.getResult(null, "渠道信息有误");
// }
// var order = await this.dao.model.findOne({
// where: { orderNo: orderNo, uapp_id: app.uAppId },
// attributes: ["orderNo", "channelServiceNo", "channelOrderNo", "channelUserId", "ownerUserId", "needNo",
// "payTime", "quantity", "serviceQuantity", "orderPayStatus", "orderPayStatusName", "totalSum", "payTotalSum",
// "refundSum", "created_at", "opNotes", "notes"
// ],
// raw: true
// });
// if (order && order.orderNo) {
// var orderproducts = await this.orderProductDao.model.findAll({
// where: { sourceOrderNo: order.orderNo },
// attributes: ["sourceOrderNo", "itemCode", "itemName", "channelItemCode", "channelItemName",
// "serviceItemCode", "picUrl", "proPrice", "quantity", "opPayType", "serviceItemSnapshot",
// "created_at"
// ],
// raw: true
// });
// order["orderproducts"] = orderproducts;
// var receptvouchers = await this.orderReceiptVoucherDao.model.findAll({
// where: { sourceOrderNo: order.orderNo },
// attributes: [
// "sourceOrderNo", "accountType", "accountTypeName", "payDate", "totalSum", "payOrderNo", "buyerOpenId",
// "passTradeNo", "buyerAliLogonId", "certifyFileUrl", "wxPayOrderCode", "aliPayOrderCode", "busPayOrderCode",
// "auditStatusName", "auditStatus"
// ],
// raw: true
// });
// order["receptvouchers"] = receptvouchers;
// var refundvouchers = await this.orderRefundVoucherDao.model.findAll({
// where: { sourceOrderNo: order.orderNo },
// attributes: [
// "busPayOrderCode",
// "sourceOrderNo", "accountType", "accountTypeName", "payDate", "totalSum", "payOrderNo", "buyerOpenId",
// "passTradeNo", "certifyFileUrl", "auditStatusName", "auditStatus"
// ],
// raw: true
// });
// order["refundvouchers"] = refundvouchers;
// }
// return system.getResultSuccess(order);
// }
}
module.exports = OrderInfoService;
\ No newline at end of file
// var task = new OrderInfoService();
// var obj={
// "itemCode": "1406046",
// "channelParams": {},
// "channelUser": {
// "channelUserId": "z120315554031547444",
// "channelUserName": "testUser",
// "channelUserMoblie": "15010929368",
// "nickname": "",
// "orgName": "",
// "orgPath": ""
// },
// "channelOrder": {
// "channelServiceNo": "z1203155540315474427",
// "channelOrderNo": "z12031,z1203d12",
// "needNo": "z1203155540315474427",
// "quantity": 1,
// "totalSum":699,
// "payTotalSum":699,
// "payStatus": "yfk",
// "payTime": "2019-09-11 10:23:21"
// }
// };
// var req={
// app:{ id: 2,uAppId:123},
// user:{ id: 6, app_id: 2, nickname: "测试用户",channelUserId:"testUserId01" }
// };
// task.createOrder(obj,req).then(d=>{
// console.log("d");
// console.log(d);
// })
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var xl = require('xlsx');
var fs = require('fs');
class PolicyinfoService extends ServiceBase {
constructor() {
super("dbpolicy", ServiceBase.getDaoName(PolicyinfoService));
}
//政策检索
async policyQuery(pobj){
var obj = pobj.actionBody;
var app = pobj.appInfo;
var paramObj={uapp_id:app.uapp_id};
var attributes =["id","policyType","policyTypeName","policyDate","policyContent","policyCity","policyProvince",
"policyLinkUrl","policySource","policyName","policyNo"];
if(obj){
if(obj.policyProvince){
paramObj["policyProvince"]=obj.policyProvince;
if(obj.policyCity){
paramObj["policyCity"]=obj.policyCity;
}
}
if(obj.policyName){
paramObj["policyName"]={ [this.db.Op.like]: "%" + obj.policyName + "%" };
}
console.log(paramObj);
}
var result = {};
//"policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'扶持措施','ssjm':'税收优惠','rlzy':'人力资源'},
result["rlzy"]=await this.findByParams("rlzy",paramObj,attributes);
result["fzbt"]=await this.findByParams("fzbt",paramObj,attributes);
result["jrdk"]=await this.findByParams("jrdk",paramObj,attributes);
result["zdfc"]=await this.findByParams("zdfc",paramObj,attributes);
result["ssjm"]=await this.findByParams("ssjm",paramObj,attributes);
return system.getResultSuccess(result);
}
async findByParams(type,paramObj,attributes){
paramObj.policyType=type;
return await this.dao.model.findAll({
where:paramObj,raw:true,attributes:attributes
});
}
async addPolicyByExcel(){
var workbook = xl.readFile("policy.xlsx")
const sheetNames = workbook.SheetNames; // 返回 ['sheet1', 'sheet2']
const worksheet = workbook.Sheets[sheetNames[0]];
var dataa =xl.utils.sheet_to_json(worksheet);
var arr = [];
var that=this;
await this.db.transaction(async function (t) {
for(var i=0;i<dataa.length;i++){
var data = dataa[i];
var pobj = {
uapp_id:26,policyNo:data['政策编号'],policyName:data['政策名称'],
policySource:data['政策出处'],policyLinkUrl:data['政策链接'],
policyProvince:data['所属省份'],policyCity:data['所属城市'],
policyTypeName:data['政策类型']};
if(data['政策类型']){
var policy_type ={'租金减免':'fzbt','金融贷款':'jrdk','扶持措施':'zdfc','税收优惠':'ssjm','人力资源':'rlzy'};
var typename = data['政策类型'];
if(policy_type[typename]){
pobj["policyType"]=policy_type[typename];
}
}
if(pobj.policyNo){
var a = await that.dao.create(pobj,t);
arr.push(a);
}
}
})
console.log(arr.length,"###################################");
}
}
module.exports = PolicyinfoService;
// var task = new PolicyinfoService();
// task.addPolicyByExcel().then(d=>{
// console.log("----------end-------------------------");
// })
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
class PolicyneedService extends ServiceBase {
constructor() {
super("dbpolicy", ServiceBase.getDaoName(PolicyneedService));
this.policyinfoDao = system.getObject("db.dbpolicy.policyinfoDao");
}
//提交政策需求
async submitPolicyNeed(pobj){
var user = pobj.userInfo;
var app = pobj.appInfo;
var obj = pobj.actionBody;
var paramObj={uapp_id:app.uapp_id};
if(!obj.contacts){
return system.getResult(null, "联系人不能为空");
}
if(!obj.mobile){
return system.getResult(null, "联系电话不能为空");
}
if(obj.policy_id){
var policyinfo = await this.policyinfoDao.model.findOne({
where:{id:obj.policy_id},raw:true
});
if(policyinfo && policyinfo.id){
paramObj["policySnapshot"] = JSON.stringify(policyinfo);
paramObj["policy_id"] = obj.policy_id;
// paramObj["policyName"] = policyinfo.policyName;
}
}
paramObj["contacts"] = obj.contacts;
paramObj["mobile"] = obj.mobile;
paramObj["company"] = obj.company;
paramObj["industry"] = obj.industry;
paramObj["region"] = obj.region;
paramObj["applyDate"] = new Date();
if(obj.popularizeUserCode){
paramObj["popularizeUserCode"] = obj.popularizeUserCode;
}
var policyNeed = await this.dao.create(paramObj);
return system.getResultSuccess();
}
//需求列表
async getPolicyNeedList(pobj){
var user = pobj.userInfo;
var app = pobj.appInfo;
var obj = pobj.actionBody || {};
if(!user || !user.channel_userid){
return system.getResult(null, "未知用户");
}
var pageSize = Number(obj.pageSize || 20);
var pageIndex = Number(obj.pageIndex || 1);
var from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
if (pageSize > 50) {
pageSize = 50;
}
var sql ="select * from "+
"(select id,uapp_id,contacts,customerIntention,customerIntentionName,company,industry,region,mobile,policy_id,applyDate,opNotes,popularizeUserCode "+
"from b_policy_need where uapp_id="+app.uapp_id+" and popularizeUserCode='"+user.channel_userid+"') as need "+
"LEFT JOIN "+
"(select id, policyNo,policyName,policyType,policyTypeName,policySource,policyLinkUrl,"+
"policyDate,policyProvince,policyCity,policyContent from b_policy_info) as policy "+
"on need.policy_id=policy.id where 1=1 ";
// var sql = "SELECT * from b_policy_need where popularizeUserCode='"+user.channel_userid+"' and uapp_id="+app.uapp_id;
if(obj.policyName){
sql=sql+" and policyName like '%"+obj.policyName+"%'";
}
if(obj.policyProvince){
sql=sql+" and policyProvince ='"+obj.policyProvince+"'";
if(obj.policyCity){
sql=sql+" and policyCity ='"+obj.policyCity+"'";
}
}
if(obj.policyType){
sql=sql+" and policyType = '"+obj.policyType+"'";
}
if(obj.customerIntention){
sql=sql+" and customerIntention = '"+obj.customerIntention+"'";
}
sql=sql+" order by need.id desc LIMIT " + pageSize + " OFFSET " + from + "";
console.log(sql);
var sqlCount = "SELECT count(1) as dataCount FROM b_policy_need where " +
" popularizeUserCode='"+user.channel_userid+"' and uapp_id="+app.uapp_id;
var tmpResult = await this.customQuery(sql,{});
var tmpResultCount = await this.customQuery(sqlCount,{});
// if (!tmpResult || tmpResult.length == 0) {
// return system.getResultSuccess(null, "暂无数据");
// }
var result = system.getResultSuccess(tmpResult);
result.dataCount = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return result;
}
//需求备注提交
async submitPolicyNeedNotes(pobj){
var user = pobj.userInfo;
var app = pobj.appInfo;
var obj = pobj.actionBody || {};
if(!user || !user.channel_userid){
return system.getResult(null, "未知用户");
}
if(!obj.needId){
return system.getResult(null, "需求id不能为空");
}
if(!obj.customerIntention){
return system.getResult(null, "客户意向不能为空");
}
if(!obj.intentionContent){
return system.getResult(null, "意向内容不能为空");
}
var policyneed = await this.dao.model.findOne({
where:{id:obj.needId,uapp_id:app.uapp_id},
raw:true
});
if(!policyneed || !policyneed.id){
return system.getResult(null, "未知政策需求");
}
if(policyneed.popularizeUserCode != user.channel_userid){
return system.getResult(null, "非法操作,只能修改本人数据");
}
var paramObj={id:obj.needId,customerIntention:obj.customerIntention};
var noteparam={customerIntention:obj.customerIntention,intentionContent:obj.intentionContent,submitDate:new Date()};
if(policyneed.opNotes){
var notes = JSON.parse(policyneed.opNotes);
var noteList = notes.data;
noteList.push(noteparam);
paramObj["opNotes"] = JSON.stringify({data:noteList});
}else{
paramObj["opNotes"] = JSON.stringify({data:[noteparam]});
}
var newPolicyNeed = await this.dao.update(paramObj);
return system.getResultSuccess();
}
}
module.exports = PolicyneedService;
......@@ -3,7 +3,7 @@ var settings={
host: "43.247.184.32",
port: 8967,
password: "Gongsibao2018",
db:8,
db:9,
},
database:{
dbname : "center_order",
......
......@@ -4,11 +4,11 @@ var ENVINPUT = {
DB_PORT: process.env.DB_PORT,
DB_USER: process.env.DB_USER,
DB_PWD: process.env.DB_PWD,
DB_NAME: process.env.CENTER_CHANNEL_DB_NAME,
DB_NAME: process.env.CENTER_ORDER_DB_NAME,
REDIS_HOST: process.env.REDIS_HOST,
REDIS_PORT: process.env.REDIS_PORT,
REDIS_PWD: process.env.REDIS_PWD,
REDIS_DB: process.env.CENTER_CHANNEL_REDIS_DB,
REDIS_DB: process.env.CENTER_ORDER_REDIS_DB,
APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev"
};
var settings = {
......@@ -16,7 +16,7 @@ var settings = {
appKey: "201911061250",
secret: "f99d413b767f09b5dff0b3610366cc46",
salt: "%iatpD1gcxz7iF#B",
cacheprefix: "centerChannel",
cacheprefix: "centerOrder",
usertimeout: 3600,//单位秒
basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 4011,
......
示例:----------------------------------开始--------------------------------------------------------------------
示例:----------------------------------开始--------------------------------------------------------------------
......@@ -11,3 +11,48 @@ ALTER TABLE b_order ADD COLUMN needNoOrderNo VARCHAR(64) DEFAULT NULL COMMENT '
ALTER TABLE b_order_tm_product ADD COLUMN needNoOrderNo VARCHAR(64) DEFAULT NULL COMMENT '需求订单号';
ALTER TABLE b_order_tm_product modify COLUMN deliveryStatus ENUM('dqrfa','fabtg','dfwsfw','dsccl','dsh','ddj','ydj','ywc') DEFAULT 'dfwsfw';
2020-02-10 zhuangbing
DROP TABLE IF EXISTS `b_policy_info`;
CREATE TABLE `b_policy_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uapp_id` int(11) NULL DEFAULT NULL,
`policyNo` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策编号',
`policyName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策名称',
`policyType` enum('rlzy','fzbt','jrdk','zdfc','ssjm') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'zh' COMMENT '政策类型 \'rlzy\':\'人力资源\',\'fzbt\':\'房租补贴\',\'jrdk\':\'金融贷款\',\'zdfc\':\'重点扶持\',\'ssjm\':\'税收减免\'',
`policyTypeName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策类型名称',
`policySource` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策出处',
`policyLinkUrl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策链接',
`policyDate` datetime(0) NULL DEFAULT NULL COMMENT '政策日期',
`policyProvince` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属省份',
`policyCity` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属城市',
`policyContent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '政策内容',
`opNotes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作备注',
`created_at` datetime(0) NOT NULL,
`updated_at` datetime(0) NULL DEFAULT NULL,
`deleted_at` datetime(0) NULL DEFAULT NULL,
`version` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `b_policy_need`;
CREATE TABLE `b_policy_need` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uapp_id` int(11) NULL DEFAULT NULL,
`contacts` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人',
`company` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '公司名称',
`industry` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '行业名称',
`region` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地区',
`mobile` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系电话',
`policy_id` int(11) NULL DEFAULT NULL COMMENT '政策id',
`policySnapshot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '政策快照',
`applyDate` datetime(0) NULL DEFAULT NULL COMMENT '申请日期',
`opNotes` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作备注',
`created_at` datetime(0) NOT NULL,
`updated_at` datetime(0) NULL DEFAULT NULL,
`deleted_at` datetime(0) NULL DEFAULT NULL,
`version` int(11) NOT NULL DEFAULT 0,
`createUserId` int(11) NULL DEFAULT NULL COMMENT '创建用户id',
`popularizeUserId` int(11) NULL DEFAULT NULL COMMENT '推广人id,即业务员id',
`popularizeUserCode` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '推广人帐号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
\ 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