Commit 9de35f61 by 王勇飞

gyq

parents bd702f5d 38501ea3
# Default ignored files
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/zhichan.iml" filepath="$PROJECT_DIR$/zhichan.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
{
"lockfileVersion": 1
}
...@@ -9,6 +9,7 @@ const appconfig = system.getSysConfig(); ...@@ -9,6 +9,7 @@ const appconfig = system.getSysConfig();
class DeliverybillCtl extends CtlBase { class DeliverybillCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(DeliverybillCtl)); super("bizchance", CtlBase.getServiceName(DeliverybillCtl));
this.logService = system.getObject("service.bizchance.statuslogSve");
} }
/** /**
...@@ -140,10 +141,87 @@ class DeliverybillCtl extends CtlBase { ...@@ -140,10 +141,87 @@ class DeliverybillCtl extends CtlBase {
} }
} }
<<<<<<< HEAD
=======
// 创建服务实例
async insertInfo(pobj, qobj, req) {
// 检验各项必传参数
if (pobj.requestId && pobj.requestId != 'undefined' &&
pobj.bizId && pobj.bizId != 'undefined' &&
pobj.contactsPhone && pobj.contactsPhone != 'undefined' &&
pobj.userId && pobj.userId != 'undefined' &&
pobj.orderId && pobj.orderId != 'undefined' &&
pobj.areaType && pobj.areaType != 'undefined' &&
pobj.area && pobj.area != 'undefined' &&
pobj.topOrgCode && pobj.topOrgCode != 'undefined' &&
pobj.taxpayerType && pobj.taxpayerType != 'undefined' &&
pobj.product_code && pobj.product_code != 'undefined' &&
pobj.product_name && pobj.product_name != 'undefined' &&
pobj.service_address && pobj.service_address != 'undefined' &&
pobj.delivery_status && pobj.delivery_status != 'undefined' &&
pobj.facilitator_id && pobj.facilitator_id != 'undefined') {
try {
var buInfo = await this.service.insertInfo(pobj);
return system.getResult(buInfo);
} catch (error) {
return system.getResultError(error);
}
} else {
return system.getResultError("参数错误!");
}
}
async updateServer(pobj, qobj, req) {
try {
if (!pobj.requestId || pobj.requestId == 'undefined') {
throw new Error("requestId 不能为空");
}
if (!pobj.bizId || pobj.bizId == 'undefined') {
throw new Error("bizId 不能为空");
}
if (!pobj.orderId || pobj.orderId == 'undefined') {
throw new Error("orderId 不能为空");
}
if (!pobj.topOrgCode || pobj.topOrgCode == 'undefined') {
throw new Error("topOrgCode 不能为空");
}
if (!pobj.companyName || pobj.companyName == 'undefined') {
throw new Error("companyName 不能为空");
}
if (!pobj.contactName || pobj.contactName == 'undefined') {
throw new Error("contactName 不能为空");
}
if (!pobj.companyBizType || pobj.companyBizType == 'undefined') {
throw new Error("companyBizType 不能为空");
}
if (!pobj.uscc || pobj.uscc == 'undefined') {
throw new Error("uscc 不能为空");
}
const rs = await this.service.updateServer(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
//根据bizId查询deliverybill表中的所有信息
async getInfo(pobj,qobj,req){
try{
if(!pobj.bizId){
throw new Error("bizId 不能为空");
}
const rs=await this.service.getInfo(pobj);
//console.log("got message");
return system.getResult(rs);
}catch(err){
return system.getResult(null,err.message)
}
}
>>>>>>> 38501ea3c477ef6b2eb192139a5984b9f32df1c6
} }
module.exports = DeliverybillCtl; module.exports = DeliverybillCtl;
// var task = new DeliverybillCtl(); // var task = new DeliverybillCtl();
<<<<<<< HEAD
// var obj={ // var obj={
// "deliverId":"1111111" // "deliverId":"1111111"
// } // }
...@@ -163,3 +241,34 @@ module.exports = DeliverybillCtl; ...@@ -163,3 +241,34 @@ module.exports = DeliverybillCtl;
var d = await task.deliverInfo(obj,{},{}) var d = await task.deliverInfo(obj,{},{})
console.log("dddddd---------" + JSON.stringify(d)); console.log("dddddd---------" + JSON.stringify(d));
})() })()
=======
// var obj = {
// "orderId": "241284456620422",
// "source_number": "tx",
// "demand_code": "demand_code",
// "sku_code": "sku_code",
// "solutionBizId": "scheme_number",
// "product_code": "bookkeeping",
// "product_name": "代账服务",
// "service_address": "110100",
// "delivery_status": "success",
// "facilitator_id": "10",
// "facilitator_name": "公司宝",
// "source_name": "tencentCloud",
// "requestId": "282da0a74432-738f-4bed-b48d-d51aa433",
// "bizId": "1292748623",
// "contactsPhone": "18510669321",
// "userId": "10973452443103156",
// "areaType": "city",
// "area": "100010",
// "topOrgCode": "rong_yi_suan",
// "taxpayerType": "generalTaxpayer",
// "companyName": "汉唐信通",
// "contactName": "王麻子",
// "companyBizType": "1",
// "uscc": "企业社会统一信用代码"
// };
// task.updateServer(obj, {}, {}).then(d => {
// console.log(JSON.stringify(d));
// })
>>>>>>> 38501ea3c477ef6b2eb192139a5984b9f32df1c6
...@@ -5,6 +5,7 @@ const appconfig = system.getSysConfig(); ...@@ -5,6 +5,7 @@ const appconfig = system.getSysConfig();
class OperationrecordCtl extends CtlBase { class OperationrecordCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(OperationrecordCtl)); super("bizchance", CtlBase.getServiceName(OperationrecordCtl));
this.bizoptSve = system.getObject("service.bizchance.bizoptSve");
} }
/** /**
...@@ -34,18 +35,34 @@ class OperationrecordCtl extends CtlBase { ...@@ -34,18 +35,34 @@ class OperationrecordCtl extends CtlBase {
* @param {*} mobj * @param {*} mobj
* { * {
demand_code: "",//需求编号 demand_code: "",//需求编号
operator: { id: "", name: "" },//操作人
operation_type: "",//操作类型 operation_type: "",//操作类型
operation_details: {}//操作详细记录 operation_details: {}//操作详细记录
} }
*/ */
async insertInfo(mobj, qobj, req) { async insertInfo(mobj, qobj, req) {
console.log("用户信息: ", mobj.userid, mobj.username);
let pobj = mobj.d; let pobj = mobj.d;
//取请求头中的userid和name
pobj.operator = {
id: mobj.userid ? mobj.userid : "",
name: mobj.username ? mobj.username : ""
}
try { try {
if (!pobj.demand_code) { if (!pobj.demand_code) {
return system.getResultError("fitaxschemeCtl/insertInfo 缺少需求编号!"); return system.getResultError("fitaxschemeCtl/insertInfo 缺少需求编号!");
} }
if (pobj.operation_type == "followUp") {
if (pobj.operation_details.intention) {
let obj = { demand_code: pobj.demand_code }
if (pobj.operation_details.intention == "方案") {
//状态修改为 '待确认方案'
obj.business_status = "beforeSubmission";
} else {
//状态修改为'跟进中'
obj.business_status = "followingUp";
}
let bizoptRes = await this.bizoptSve.updateStatusByDemandCode(obj);
}
}
let insertRes = await this.service.insertInfo(pobj); let insertRes = await this.service.insertInfo(pobj);
return system.getResult("添加记录信息成功!"); return system.getResult("添加记录信息成功!");
} catch (error) { } catch (error) {
......
...@@ -13,10 +13,24 @@ class BizoptDao extends Dao { ...@@ -13,10 +13,24 @@ class BizoptDao extends Dao {
} else { } else {
//需要添加公司查询条件 //需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id) qw["facilitator_id"] = Number(qobj.company_id)
// 为空说明是管理员,不需设置组织结构过滤 /**
// if (qobj.opath && qobj.opath != "") { * 数据权限过滤
// qw["salesman_opcode"] = { [this.db.Op.like]: `%${qobj.opath}%` } * 1. 管理员 (opath 为空)、 销售主管(isPrincipal = true) 、 销售 (isPrincipal = false && opath不为空)
// } */
if (!qobj.opath) { // 管理员 不做处理
} else if (qobj.isPrincipal) { // 销售主管 查询为空和自己组织结构下的
qw["$or"] = [
{
salesman_opcode: {
$eq: null
}
}, {
salesman_opcode: { $like: `%${qobj.opath}%` }
}
]
} else { // 销售 查询自己的
qw["salesman_opcode"] = { $like: `%${qobj.opath}%` }
}
//不是来自平台前端查询 //不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) { if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) {
console.log("bizpath-------------" + qobj.bizpath); console.log("bizpath-------------" + qobj.bizpath);
...@@ -29,12 +43,7 @@ class BizoptDao extends Dao { ...@@ -29,12 +43,7 @@ class BizoptDao extends Dao {
[this.db.Op.eq]: "received" [this.db.Op.eq]: "received"
}; };
} }
if (qobj.bizpath.indexOf("demandfollow") > 0) {//从需求跟进列表过来的 if (qobj.bizpath.indexOf("demandfollow") > 0 || qobj.bizpath.indexOf("distributionManagement") > 0) {//从需求跟进列表或分配记录列表过来的
qw["business_status"] = {
[this.db.Op.in]: ["beforeFollowUp", "followingUp", "beforeSubmission"]
};
}
if (qobj.bizpath.indexOf("distributionManagement") > 0) {//从分配记录列表过来的
qw["business_status"] = { qw["business_status"] = {
[this.db.Op.ne]: "received" [this.db.Op.ne]: "received"
}; };
...@@ -57,8 +66,7 @@ class BizoptDao extends Dao { ...@@ -57,8 +66,7 @@ class BizoptDao extends Dao {
var setobj = { "business_status": qobj.business_status }; var setobj = { "business_status": qobj.business_status };
if (qobj.close_reason && qobj.close_reason != 'undefined') { if (qobj.close_reason && qobj.close_reason != 'undefined') {
setobj["close_reason"] = qobj.close_reason; setobj["close_reason"] = qobj.close_reason;
} } else {
else {
setobj["close_reason"] = ""; setobj["close_reason"] = "";
} }
var whereobj = { "demand_code": qobj.demand_code }; var whereobj = { "demand_code": qobj.demand_code };
...@@ -95,47 +103,35 @@ class BizoptDao extends Dao { ...@@ -95,47 +103,35 @@ class BizoptDao extends Dao {
var obj = { var obj = {
"demand_code": qobj.businessMode, "demand_code": qobj.businessMode,
"business_type": qobj.businessType, "business_type": qobj.businessType,
"business_status": qobj.currentStatus, "business_status": qobj.bussinessStatus,
"business_info": {} "business_info": {},
"source_number": qobj.sourceNumber,
"service_address": qobj.serviceAddress,
"facilitator_id": qobj.favilitatorID,
"facilitator_name": qobj.favilitatorName,
"source_name": qobj.sourceName,
}; };
if (qobj.channelSource && qobj.channelSource != 'undefined') { //business_info START
obj.source_name = qobj.channelSource; if (qobj.topOrgCode && qobj.topOrgCode != 'undefined') {
} obj.business_info.topOrgCode = qobj.topOrgCode
if (qobj.sourceNumber && qobj.sourceNumber != 'undefined') {
obj.source_number = qobj.sourceNumber;
}
if (qobj.serviceCode && qobj.serviceCode != 'undefined') {
obj.service_address = qobj.serviceCode;
} }
if (qobj.memoInfo && qobj.memoInfo != 'undefined') { if (qobj.intentionBizId && qobj.intentionBizId != 'undefined') {
obj.business_info.memoInfo = qobj.memoInfo; obj.business_info.intentionBizId = qobj.intentionBizId;
} }
if (qobj.statusReason && qobj.statusReason != 'undefined') { if (qobj.contactsPhone && qobj.contactsPhone != 'undefined') {
obj.close_reason = qobj.statusReason; obj.business_info.contactsPhone = qobj.contactsPhone; //已经加密
} }
if (qobj.contactsName && qobj.contactsName != 'undefined') { if (qobj.contactsName && qobj.contactsName != 'undefined') {
obj.business_info.contactsName = qobj.contactsName; obj.business_info.contactsName = qobj.contactsName;
} }
if (qobj.contactsPhone && qobj.contactsPhone != 'undefined') {
obj.business_info.contactsPhone = qobj.contactsPhone;//已经加密
}
if (qobj.serviceName && qobj.serviceName != 'undefined') { if (qobj.serviceName && qobj.serviceName != 'undefined') {
obj.business_info.serviceName = qobj.serviceName; obj.business_info.serviceName = qobj.serviceName;
} }
if (qobj.businessName && qobj.businessName != 'undefined') {
obj.business_info.businessName = qobj.businessName; //bussiness_info END
} //other
if (qobj.UserName && qobj.UserName != 'undefined') { if (qobj.closeReason && qobj.closeReason != 'undefined') {
obj.business_info.userName = qobj.UserNames; obj.close_reason = qobj.closeReason;
}
if (qobj.companyName && qobj.companyName != 'undefined') {
obj.business_info.companyName = qobj.companyName;
}
if (qobj.servicerCode && qobj.servicerCode != 'undefined') {
obj.facilitator_id = qobj.servicerCode;
}
if (qobj.servicerName && qobj.servicerName != 'undefined') {
obj.facilitator_name = qobj.servicerName;
} }
if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined') { if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined') {
obj.salesman_opcode = qobj.salesmanOpcode; obj.salesman_opcode = qobj.salesmanOpcode;
...@@ -143,15 +139,23 @@ class BizoptDao extends Dao { ...@@ -143,15 +139,23 @@ class BizoptDao extends Dao {
if (qobj.salesmanId && qobj.salesmanId != 'undefined') { if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
obj.salesman_id = qobj.salesmanId; obj.salesman_id = qobj.salesmanId;
} }
if (qobj.clerkName && qobj.clerkName != 'undefined') { if (qobj.salesmanName && qobj.salesmanName != 'undefined') {
obj.salesman_name = qobj.clerkName; obj.salesman_name = qobj.salesmanName;
} }
if (qobj.clerkPhone && qobj.clerkPhone != 'undefined') { if (qobj.salesmanPhone && qobj.salesmanPhone != 'undefined') {
obj.salesman_phone = qobj.clerkPhone; obj.salesman_phone = qobj.salesmanPhone;
} }
return await this.create(obj, t); return await this.create(obj, t);
} }
/**
* 根据服务实例id查找服务所有信息
*/
async findByBizId(pobj){
var oid=pobj.bizId;
return await this.findOne({biz_id:oid});
}
} }
module.exports = BizoptDao; module.exports = BizoptDao;
...@@ -62,10 +62,167 @@ class DeliverybillDao extends Dao { ...@@ -62,10 +62,167 @@ class DeliverybillDao extends Dao {
/** /**
* 筛选 条件 TODO: 筛选功能字段(filter) * 筛选 条件
* company_name、v_coname、v_cophone、delivery_code
*/ */
if (qc.where.companyName) {
filters.push({
company_name: qc.where.companyName
});
delete qc.where.companyName;
}
if (qc.where.contactsName) {
filters.push({
v_coname: qc.where.contactsName
});
delete qc.where.contactsName;
}
if (qc.where.contactsPhone) {
filters.push({
v_cophone: qc.where.contactsPhone
});
delete qc.where.contactsPhone;
}
if (qc.where.deliveryNumber) {
filters.push({
delivery_code: qc.where.deliveryNumber
});
delete qc.where.deliveryNumber;
}
qc.where["$and"] = filters; qc.where["$and"] = filters;
return qw; return qw;
} }
async insertInfo(qobj, t) {
var obj = {
"delivery_code": qobj.orderId,
"product_code": qobj.product_code,
"product_name": qobj.product_name,
"service_address": qobj.service_address,
"delivery_status": qobj.delivery_status,
"facilitator_id": qobj.facilitator_id,
"biz_id": qobj.bizId
};
// source_number
if (qobj.source_number && qobj.source_number != 'undefined') {
obj.source_number = qobj.source_number;
delete qobj.source_number;
}
// demand_code
if (qobj.demand_code && qobj.demand_code != 'undefined') {
obj.demand_code = qobj.demand_code;
delete qobj.demand_code;
}
// sku_code
if (qobj.sku_code && qobj.sku_code != 'undefined') {
obj.sku_code = qobj.sku_code;
delete qobj.sku_code;
}
// scheme_number
if (qobj.solutionBizId && qobj.solutionBizId != 'undefined') {
obj.scheme_number = qobj.solutionBizId;
delete qobj.solutionBizId;
}
// selling_price
if (qobj.selling_price && qobj.selling_price != 'undefined') {
obj.selling_price = qobj.selling_price;
delete qobj.selling_price;
}
// cost_price
if (qobj.cost_price && qobj.cost_price != 'undefined') {
obj.cost_price = qobj.cost_price;
delete qobj.cost_price;
}
// close_reason
if (qobj.close_reason && qobj.close_reason != 'undefined') {
obj.close_reason = qobj.close_reason;
delete qobj.close_reason;
}
// facilitator_name
if (qobj.facilitator_name && qobj.facilitator_name != 'undefined') {
obj.facilitator_name = qobj.facilitator_name;
delete qobj.facilitator_name;
}
// salesman_opcode
if (qobj.salesman_opcode && qobj.salesman_opcode != 'undefined') {
obj.salesman_opcode = qobj.salesman_opcode;
delete qobj.salesman_opcode;
}
// salesman_id
if (qobj.salesman_id && qobj.salesman_id != 'undefined') {
obj.salesman_id = qobj.salesman_id;
delete qobj.salesman_id;
}
// salesman_name
if (qobj.salesman_name && qobj.salesman_name != 'undefined') {
obj.salesman_name = qobj.salesman_name;
delete qobj.salesman_name;
}
// salesman_phone
if (qobj.salesman_phone && qobj.salesman_phone != 'undefined') {
obj.salesman_phone = qobj.salesman_phone;
delete qobj.salesman_phone;
}
// source_name
if (qobj.source_name && qobj.source_name != 'undefined') {
obj.source_name = qobj.source_name;
delete qobj.source_name;
}
// master_source_number
if (qobj.master_source_number && qobj.master_source_number != 'undefined') {
obj.master_source_number = qobj.master_source_number;
delete qobj.master_source_number;
}
// settle_status
if (qobj.settle_status && qobj.settle_status != 'undefined') {
obj.settle_status = qobj.settle_status;
delete qobj.settle_status;
}
// settlebill_id
if (qobj.settlebill_id && qobj.settlebill_id != 'undefined') {
obj.settlebill_id = qobj.settlebill_id;
delete qobj.settlebill_id;
}
// delivery_man_id
if (qobj.delivery_man_id && qobj.delivery_man_id != 'undefined') {
obj.delivery_man_id = qobj.delivery_man_id;
delete qobj.delivery_man_id;
}
// delivery_man_name
if (qobj.delivery_man_name && qobj.delivery_man_name != 'undefined') {
obj.delivery_man_name = qobj.delivery_man_name;
delete qobj.delivery_man_name;
}
// delivery_man_opcode
if (qobj.delivery_man_opcode && qobj.delivery_man_opcode != 'undefined') {
obj.delivery_man_opcode = qobj.delivery_man_opcode;
delete qobj.delivery_man_opcode;
}
delete qobj.orderId;
delete qobj.product_code;
delete qobj.product_name;
delete qobj.service_address;
delete qobj.delivery_status;
delete qobj.facilitator_id;
obj.delivery_info = qobj;
return await this.create(obj, t);
}
async updateServer(qobj, whereobj, t) {
return await this.updateByWhere(qobj, whereobj, t);
}
async findOneByDeliveryCodeAndBizId(qobj) {
var qcwhere = { "delivery_code": qobj.orderId, "biz_id": qobj.bizId };
return await this.findOne(qcwhere);
}
/**
* 根据服务实例id查找服务所有信息
*/
async findByBizId(pobj){
var oid=pobj.bizId;
return await this.findOne({biz_id:oid});
}
} }
module.exports = DeliverybillDao; module.exports = DeliverybillDao;
...@@ -106,6 +106,43 @@ class BizOptService extends ServiceBase { ...@@ -106,6 +106,43 @@ class BizOptService extends ServiceBase {
}); });
} }
/**
* 查询商机表信息
* @param pobj
* @returns {Promise<{}>}
*/
async getInfo(pobj){
let result={};
let bizOpInfo = await this.dao.findByBizId(pobj);
if(!bizOpInfo){
throw new Error("没有服务信息");
}
//封装deliverybill表数据
result.bizOpInfo={
demandCode:bizOpInfo.demand_code,//商机编码
business_type:bizOpInfo.business_type,//商机类型
businessStatus:bizOpInfo.business_status,//当前商机状态
businessInfo:bizOpInfo.business_info,//商机信息
vConame:bizOpInfo.v_coname,//联系人-虚拟字段
vCophone:bizOpInfo.v_cophone,//联系电话-虚拟字段
sourceNumber:bizOpInfo.source_number,//渠道来源编号
serviceAddress:bizOpInfo.service_address,//服务地区
closeReason:bizOpInfo.close_reason,//状态为关闭原因
facilitatorId:bizOpInfo.facilitator_id,//服务商id
facilitatorName:bizOpInfo.facilitator_name,//服务商名称
salesmanOpcode:bizOpInfo.salesman_opcode,//业务员opcode
salesmanId:bizOpInfo.salesman_id,//业务员id
salesmanName:bizOpInfo.salesman_name,//业务员名称
salesmanPhone:bizOpInfo.salesman_phone,//业务员联系方式
sourceName:bizOpInfo.source_name,//渠道名称
createdAt:bizOpInfo.created_at,//创建时间
updatedAt:bizOpInfo.updated_at,//更新时间
version:bizOpInfo.version,//o
bizId:pobj.bizId//融易算-服务实例id
}
return result;
}
} }
module.exports = BizOptService; module.exports = BizOptService;
......
...@@ -234,5 +234,193 @@ class DeliverybillService extends ServiceBase { ...@@ -234,5 +234,193 @@ class DeliverybillService extends ServiceBase {
return "SUCCESS" return "SUCCESS"
} }
async insertInfo(qobj) {
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj, t);
});
}
async updateServer(qobj) {
var self = this;
var bill = await self.dao.findOneByDeliveryCodeAndBizId(qobj);
var obj = {};
var whereobj = {
"delivery_code": qobj.orderId,
"biz_id": qobj.bizId
};
// source_number
if (qobj.source_number && qobj.source_number != 'undefined') {
obj.source_number = qobj.source_number;
delete qobj.source_number;
}
// demand_code
if (qobj.demand_code && qobj.demand_code != 'undefined') {
obj.demand_code = qobj.demand_code;
delete qobj.demand_code;
}
// sku_code
if (qobj.sku_code && qobj.sku_code != 'undefined') {
obj.sku_code = qobj.sku_code;
delete qobj.sku_code;
}
// scheme_number
if (qobj.solutionBizId && qobj.solutionBizId != 'undefined') {
obj.scheme_number = qobj.solutionBizId;
delete qobj.solutionBizId;
}
// product_code
if (qobj.product_code && qobj.product_code != 'undefined') {
obj.product_code = qobj.product_code;
delete qobj.product_code;
}
// product_name
if (qobj.product_name && qobj.product_name != 'undefined') {
obj.product_name = qobj.product_name;
delete qobj.product_name;
}
// service_address
if (qobj.service_address && qobj.service_address != 'undefined') {
obj.service_address = qobj.service_address;
delete qobj.service_address;
}
// delivery_status
if (qobj.delivery_status && qobj.delivery_status != 'undefined') {
obj.delivery_status = qobj.delivery_status;
delete qobj.delivery_status;
}
// selling_price
if (qobj.selling_price && qobj.selling_price != 'undefined') {
obj.selling_price = qobj.selling_price;
delete qobj.selling_price;
}
// cost_price
if (qobj.cost_price && qobj.cost_price != 'undefined') {
obj.cost_price = qobj.cost_price;
delete qobj.cost_price;
}
// close_reason
if (qobj.close_reason && qobj.close_reason != 'undefined') {
obj.close_reason = qobj.close_reason;
delete qobj.close_reason;
}
// facilitator_id
if (qobj.facilitator_id && qobj.facilitator_id != 'undefined') {
obj.facilitator_id = qobj.facilitator_id;
delete qobj.facilitator_id;
}
// facilitator_name
if (qobj.facilitator_name && qobj.facilitator_name != 'undefined') {
obj.facilitator_name = qobj.facilitator_name;
delete qobj.facilitator_name;
}
// salesman_opcode
if (qobj.salesman_opcode && qobj.salesman_opcode != 'undefined') {
obj.salesman_opcode = qobj.salesman_opcode;
delete qobj.salesman_opcode;
}
// salesman_id
if (qobj.salesman_id && qobj.salesman_id != 'undefined') {
obj.salesman_id = qobj.salesman_id;
delete qobj.salesman_id;
}
// salesman_name
if (qobj.salesman_name && qobj.salesman_name != 'undefined') {
obj.salesman_name = qobj.salesman_name;
delete qobj.salesman_name;
}
// salesman_phone
if (qobj.salesman_phone && qobj.salesman_phone != 'undefined') {
obj.salesman_phone = qobj.salesman_phone;
delete qobj.salesman_phone;
}
// source_name
if (qobj.source_name && qobj.source_name != 'undefined') {
obj.source_name = qobj.source_name;
delete qobj.source_name;
}
// master_source_number
if (qobj.master_source_number && qobj.master_source_number != 'undefined') {
obj.master_source_number = qobj.master_source_number;
delete qobj.master_source_number;
}
// settle_status
if (qobj.settle_status && qobj.settle_status != 'undefined') {
obj.settle_status = qobj.settle_status;
delete qobj.settle_status;
}
// settlebill_id
if (qobj.settlebill_id && qobj.settlebill_id != 'undefined') {
obj.settlebill_id = qobj.settlebill_id;
delete qobj.settlebill_id;
}
// delivery_man_id
if (qobj.delivery_man_id && qobj.delivery_man_id != 'undefined') {
obj.delivery_man_id = qobj.delivery_man_id;
delete qobj.delivery_man_id;
}
// delivery_man_name
if (qobj.delivery_man_name && qobj.delivery_man_name != 'undefined') {
obj.delivery_man_name = qobj.delivery_man_name;
delete qobj.delivery_man_name;
}
// delivery_man_opcode
if (qobj.delivery_man_opcode && qobj.delivery_man_opcode != 'undefined') {
obj.delivery_man_opcode = qobj.delivery_man_opcode;
delete qobj.delivery_man_opcode;
}
delete qobj.orderId;
obj.delivery_info = JSON.parse((JSON.stringify(bill.delivery_info) + JSON.stringify(qobj)).replace(/}{/, ','));
return self.db.transaction(async function (t) {
return await self.dao.updateServer(obj, whereobj, t);
});
}
//根据bizId查询deliverybill表中的所有信息
async getInfo(pobj){
let result={};
let deliveryBillInfo = await this.dao.findByBizId(pobj);
//console.log("gggg"+deliveryBillInfo+pobj.bizId)
if(!deliveryBillInfo){
throw new Error("没有服务信息");
}
//封装deliverybill表数据
result.deliveryBillInfo={
deliveryCode:deliveryBillInfo.delivery_code,//交付单编号
sourceNumber:deliveryBillInfo.source_number,//渠道来源编号
demandCode:deliveryBillInfo.demand_code,//商机编号
skuCode:deliveryBillInfo.sku_code,//sku编号
schemeNumber:deliveryBillInfo.scheme_number,//方案编号
productCode:deliveryBillInfo.product_code,//产品编码
productName:deliveryBillInfo.product_name,//产品名称
serviceAddress:deliveryBillInfo.service_address,//服务地区
deliveryInfo:deliveryBillInfo.delivery_info,//交付单详情
payStatus:deliveryBillInfo.pay_status,//交付状态-虚拟字段
vConame:deliveryBillInfo.v_coname,//联系人-虚拟字段
vCophone:deliveryBillInfo.v_cophone,//联系电话-虚拟字段
delivery_status:deliveryBillInfo.delivery_status,//交付单状态
sellingPrice:deliveryBillInfo.selling_price,//交付单价格
costPrice:deliveryBillInfo.cost_price,//成本价
closeReason:deliveryBillInfo.close_reason,//状态为关闭原因
facilitatorId:deliveryBillInfo.facilitator_id,//服务商id
facilitatorName:deliveryBillInfo.facilitator_name,//服务商名称
salesmanOpcode:deliveryBillInfo.salesman_opcode,//业务员opcode
salesmanId:deliveryBillInfo.salesman_id,//业务员id
salesmanName:deliveryBillInfo.salesman_name,//业务员名称
salesmanPhone:deliveryBillInfo.salesman_phone,//业务员联系方式
sourceName:deliveryBillInfo.source_name,//渠道名称
createdAt:deliveryBillInfo.created_at,//创建时间
updatedAt:deliveryBillInfo.updated_at,//更新时间
version:deliveryBillInfo.version,//o
masterSourceNumber:deliveryBillInfo.master_source_number,//主来源单
settleStatus:deliveryBillInfo.settle_status,//结算状态
settlebillId:deliveryBillInfo.settlebill_id,//结算单id
deliveryManId:deliveryBillInfo.delivery_man_id,//销售员id
deliveryManName:deliveryBillInfo.delivery_man_name,//销售员姓名
deliveryManOpcode:deliveryBillInfo.delivery_man_opcode,//销售员opcode
bizId:pobj.bizId//融易算-服务实例id
}
return result;
}
} }
module.exports = DeliverybillService; module.exports = DeliverybillService;
\ No newline at end of file
...@@ -3,6 +3,7 @@ var objsettings = require("../config/objsettings"); ...@@ -3,6 +3,7 @@ var objsettings = require("../config/objsettings");
var settings = require("../config/settings"); var settings = require("../config/settings");
const request = require('request'); const request = require('request');
const cryptoJS = require('crypto-js'); const cryptoJS = require('crypto-js');
const md5 = require('MD5');
class System { class System {
static declare(ns) { static declare(ns) {
...@@ -330,6 +331,46 @@ class System { ...@@ -330,6 +331,46 @@ class System {
return plaintext; return plaintext;
} }
/**
* 签名认证
* @param {json} vo json对象
* @param {string} secret 签名信息
*/
static signValid(obj, secret) {
console.log("secret:{}", secret);
// obj json字符串
var svrSign;
if (obj == "{}" || !secret || secret == 'undefined') {
svrSign = "";
} else {
// 对传入的json obj进行处理得到toSignStr
let arr = [];
for (var key in obj) {
arr.push(key)
}
arr.sort();
let str = '';
for (var i in arr) {
if (arr[i] != "sign" && arr[i] != "ip" &&
(!(Object.prototype.toString.call(obj[arr[i]]) == '[object Object]' || Object.prototype.toString.call(obj[arr[i]]) == '[object Array]')
&& (obj[arr[i]] && obj[arr[i]] != 'undefined'))) {
str += arr[i] + "=" + obj[arr[i]] + "&";
}
}
var toSignStr = str.substr(0, str.length - 1);
var sb = toSignStr + secret;
console.log("cmd=ApiSignUtils:toSign msg=original Sign:" + sb.toString() + " req param:" + obj);
// 对sb进行md5加密后得到svrSign
svrSign = md5(sb);
console.log("svrSign===>" + svrSign);
}
if (svrSign.toLowerCase() == obj["sign"].toLowerCase()) {
console.log("cmd=ApiSignUtils:SignValid msg=original Sign:" + svrSign)
return true;
}
console.error("cmd=ApiSignUtils:SignValid msg=Sign validtate fail! svrSign:" + svrSign + " reqSign:" + obj["sign"]);
return false;
}
} }
Date.prototype.Format = function (fmt) { //author: meizz Date.prototype.Format = function (fmt) { //author: meizz
...@@ -415,4 +456,22 @@ module.exports = System; ...@@ -415,4 +456,22 @@ module.exports = System;
// }catch(e){ // }catch(e){
// console.log(e); // console.log(e);
// } // }
// })()
// (async () => {
// var obj = {
// "postWay": '2',
// "courier_number": '1805679087555',
// "companyId": 102,
// "customerId": 499482,
// "sign": '57acb7037f64d558edf2e844340791e2',
// "currentPeriod": 202001
// }
// var secret = "2a24a72dc78679bb0796dd3af50a429a";
// try {
// var flag = await System.signValid(obj, secret)
// console.log(flag);
// } catch (e) {
// console.log(e);
// }
// })() // })()
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ 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