Commit 23e49b7c by linboxuan

lin pannong

parent 0b0b22af
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ProductAPI extends WEBBase {
constructor() {
super();
this.signSve = system.getObject("service.common.signSve");
}
/**
* 优客工厂
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getAppInfoByAppKey":// 根据优客token获取用户信息,生成userPin返回前端 actionBody
opResult = await this.signSve.getAppInfoByAppKey(pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = ProductAPI;
\ No newline at end of file
......@@ -7,33 +7,69 @@ class edi extends APIBase {
this.centerorderSve = system.getObject("service.common.centerorderSve");
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
this.utilsServicedSve = system.getObject("service.utilsSve.utilsServiceSve");
this.utilsServiceSve = system.getObject("service.utilsSve.utilsServiceSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, pobj.actionBody, req);
return result;
async create(pobj,query,req) {
console.log(pobj);
// 校验必填 pannong 2.1
var checkResult = await this.serviceCreateCheck(pobj,req.headers);
if(checkResult.status != 0) {
return checkResult;
}
var qobj = {appInfo:pobj.appInfo};
qobj.actionBody = pobj;
var result = await this.utilsServiceSve.submitService(qobj,qobj.actionBody,req);
return result
}
async opActionProcess(pobj, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
case "submitService":
opResult = await this.utilsServicedSve.submitService(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
async serviceCreateCheck(pobj,headers) {
if(!headers.appkey) {
return system.getResult(null, "headers.appkey cannot be empty");
}
if(!headers.sign) {
return system.getResult(null, "headers.sign cannot be empty");
}
if(!pobj.bizId) {
return system.getResult(null, "bizId cannot be empty");
}
if(!pobj.contactName) {
return system.getResult(null, "contactName cannot be empty");
}
if(!pobj.contactMobile) {
return system.getResult(null, "contactName cannot be empty");
}
if(!pobj.timeUnit) {
return system.getResult(null, "contactName cannot be empty");
}
if(!pobj.quantity) {
return system.getResult(null, "contactName cannot be empty");
}
if(!pobj.companyInfo) {
return system.getResult(null, "contactName cannot be empty");
}
if(!pobj.companyInfo.companyName) {
return system.getResult(null, "companyName cannot be empty");
}
if(!pobj.companyInfo.taxpayerType) {
return system.getResult(null, "taxpayerType cannot be empty");
}
if(!pobj.companyInfo.acctgSystemId) {
return system.getResult(null, "acctgSystemId cannot be empty");
}
if(!pobj.companyInfo.companyForm) {
return system.getResult(null, "companyForm cannot be empty");
}
if(!pobj.companyInfo.industry) {
return system.getResult(null, "industry cannot be empty");
}
if(!pobj.companyInfo.taxpayerNumber) {
return system.getResult(null, "taxpayerNumber cannot be empty");
}
if(!pobj.companyInfo.companyArea) {
return system.getResult(null, "companyArea cannot be empty");
}
return system.getResultSuccess()
}
}
......
......@@ -1011,31 +1011,6 @@ class UtilsNeedService extends AppServiceBase {
* @param {*} actionBody
*/
async produceNoticeAliEsp(req, pobj, actionBody) {
// 如果状态为USER_UPLOAD_PRODUCE需要转换url
// if(actionBody.operationType == "USER_UPLOAD_PRODUCE" ) {
// if(actionBody.extInfo) {
// // businessLicense:['business_license/12195411 61213057/1599115976393/p08xo9frgzj.png']
// // idCardList:[' ["card/1219541161213057/1599115980036/s1nn3sozulo.png"] ']
// // 注意idCardList 是二维数组 需要再转换一下 不知道为什么
// var extJson = JSON.parse(actionBody.extInfo);
// var businessLicenseArr = [];
// if(extJson.idCardList) {
// // 抽出数组
// var idCardListA = JSON.parse(extJson.idCardList);
// var idCardListArr = [];
// for(var i = 0; i < idCardListA.lenght; i++) {
// idCardListArr.push(await this.opDownFileInfo(idCardListA[i]));
// }
// }
// for(var i = 0; i < extJson.businessLicense.lenght; i++) {
// businessLicenseArr.push(await this.opDownFileInfo(extJson.businessLicense[i]));
// }
// actionBody.extInfo = {
// businessLicenseArr,
// idCardListArr
// }
// }
// }
switch (actionBody.operationType) {
case "USER_PAY_PRODUCE":
// 修改需求,方案 订单状态
......@@ -1223,6 +1198,7 @@ class UtilsNeedService extends AppServiceBase {
// 2020 0927 lin 新增 edi状态更新
async ediNotify(pobj, actionBody) {
// 如果状态为USER_UPLOAD_PRODUCE需要转换url
if (actionBody.operationType == "USER_UPLOAD_PRODUCE") {
if (actionBody.extInfo) {
// businessLicense:['business_license/12195411 61213057/1599115976393/p08xo9frgzj.png']
......
......@@ -10,6 +10,8 @@ class utils360Sve extends AppServiceBase {
this.centerAppUrl = settings.centerAppUrl();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve")
this.pushlogSve = system.getObject("service.common.pushlogSve");
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
}
/**
......@@ -17,8 +19,79 @@ class utils360Sve extends AppServiceBase {
* @param {*} pobj
* @param {*} actionBody
*/
async submitService(pobj, actionBody) {
// 明天开始写逻辑
async submitService(pobj, actionBody,req) {
// 获取userpin 为什么在这里获取?原因:getWay获取不到手机号 再去调用其他接口浪费资源
pobj.actionType = "getLoginByUserName";
pobj.actionBody.channelUserId = actionBody.contactMobile; // 即:86_18512345678
pobj.actionBody.userName = actionBody.contactMobile;
pobj.actionBody.mobile = actionBody.contactMobile;
// pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();//采用jwt方式封装userpin
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody);
if (tmpOpResult.status != 0) {
return system.getResult(null, "创建用户信息失败");
}
pobj.userInfo = {
channel_userid: actionBody.contactMobile,
channel_username: actionBody.contactMobile,
mobile: actionBody.contactMobile
}
// 询价
pobj.actionBody.channelItemCode = "kjxg";
pobj.actionBody.pathCode = "/kjfw/kjxg/";// 写死
pobj.actionType = "getProductPrice";
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
var productPriceResult = await this.restPostUrl(pobj, url);
if (productPriceResult.status != 0) {
return system.getResult(null, "productPrice is empty");
}
// addOrder
pobj.actionBody.bizId = actionBody.bizId;
pobj.actionBody.userName = actionBody.contactName;
pobj.actionBody.mobile = actionBody.contactMobile;
pobj.actionBody.orderNo = actionBody.bizId;
pobj.actionBody.totalSum = productPriceResult.data.price;
pobj.actionBody.orderPrice = productPriceResult.data.price;
pobj.actionBody.payTotalSum = productPriceResult.data.price;
pobj.actionBody.price = productPriceResult.data.price;
pobj.actionBody.payCode = productPriceResult.data.payCode;
pobj.actionBody.channelItemCode = productPriceResult.data.channelItemCode;
pobj.actionBody.quantity = 1;
pobj.actionBody.channelOrder = {
channelServiceNo: actionBody.bizId,
channelOrderNo: actionBody.bizId,
orderStatus: 2
}
var orderrtn = await this.utilsOrderSve.addOrder(pobj, pobj.actionBody);
if (orderrtn.status != 0 && orderrtn.status != -1) {
return system.getResultFail(-5012, "订单创建失败");
}
if (orderrtn.data) {
pobj.actionBody.orderNo = orderrtn.data.orderNo;
}
var deliveryObj = {
actionBody: {
"bizId":pobj.actionBody.bizId,
"contactName":pobj.actionBody.contactName,
"contactMobile":pobj.actionBody.contactMobile,
"timeUnit":pobj.actionBody.timeUnit,
"quantity":pobj.actionBody.quantity,
"companyInfo":{
"companyName":pobj.actionBody.companyInfo.companyName,
"taxpayerType":pobj.actionBody.companyInfo.taxpayerType,
"acctgSystemId":pobj.actionBody.companyInfo.acctgSystemId,
"companyForm":pobj.actionBody.companyInfo.companyForm,
"industry":pobj.actionBody.companyInfo.industry,
"taxpayerNumber":pobj.actionBody.companyInfo.taxpayerNumber,
"companyArea":pobj.actionBody.companyInfo.companyArea
}
},
appInfo: pobj.appInfo
}
this.utilsPushSve.aliBusiness2Delivery(deliveryObj, "submitService");
return system.getResultSuccess();
}
......
......@@ -18,7 +18,7 @@ module.exports = {
"foodCloseNeed", "foodRecordLog", "foodRecordLogList", "getParamsFor360", "addOrderWeb", "getPayRecords", "getLoginInfo", "putUserMobileByVcode",
"putUserPwdByMobile", "icpNotifyNew"
],
apiMustUserpinList: ["submitNeed", "paySuccess", "icpNotify", "getLoginInfo", "icpNotifyNew", "submitIcpProgramme","serviceProviderSubmitMaterial","abolishIcpProgramme"],
apiSecretPathList: ["/api/icp/consultation/submit","/api/icp/feedback/submit","/api/icp/order/notify"]
apiMustUserpinList: ["submitNeed", "paySuccess", "icpNotify", "getLoginInfo", "icpNotifyNew", "submitIcpProgramme","serviceProviderSubmitMaterial","abolishIcpProgramme","submitService"],
apiSecretPathList: ["/api/icp/consultation/submit","/api/icp/feedback/submit","/api/icp/order/notify","/api/opreceive/service/create"]
}
}
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