Commit 0dda07ae by 宋毅

tj

parent 357b8ef2
......@@ -62,7 +62,7 @@ class TmOrderAPI extends APIBase {
opResult = await this.toolSve.decryptStr(req.app, action_body.opStr);
break;
case "op1688ChannelPushOrder"://处理渠道订单信息
opResult = await this.orderSve.op1688ChannelPushOrder(action_body);
opResult = await this.orderSve.op1688ChannelPushOrderTest(action_body, pobj, req);
if (opResult.status == 0) {
opResult.data = null;
var encryptResult = await this.toolSve.encryptStr(req.app, action_body.channelUserId);
......@@ -93,6 +93,25 @@ class TmOrderAPI extends APIBase {
await this.pushData2(opResult, req, pobj, url);
}
break;
case "subExistTmOrder"://提交存在商标提报
opResult = await this.ordertmproductSve.addExistTmOrder(action_body);
if (opResult && opResult.status == 0 && opResult.data) {
var returnTms = opResult.data.tm;
for (var i = 0; i < pobj.actionBody.nclones.length; i++) {
var nclone = pobj.actionBody.nclones[i];
for (var j = 0; j < returnTms.length; j++) {
var returnTm = returnTms[j];
if (returnTm.nclOne && nclone.code && returnTm.nclOne == nclone.code) {
pobj.actionBody.nclones[i]["tbCode"] = returnTm.tbCode;
}
}
}
pobj.actionBody["deliveryOrderNo"] = opResult.data.deliveryOrderNo;
// await this.pushData(opResult, req, pobj);
var url = this.pushFqbossDataUrl + "api/channelaccessApi/createChannelOrder"
await this.pushData2(opResult, req, pobj, url);
}
break;
case "getTmOrderList"://商标交付列表
opResult = await this.ordertmproductSve.getTmOrderList(action_body);
break;
......@@ -152,6 +171,9 @@ class TmOrderAPI extends APIBase {
await this.pushData2(opResult, req, pobj, url);
}
break;
case "pushFqBusiness"://推送商机到峰擎
opResult = await this.orderSve.pushFqBusiness(action_body, pobj, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -119,5 +119,38 @@ class OrderDao extends Dao {
raw: true
});
}
async getItemByChannelServiceNo(channelServiceNo, appId) {//通过订单号查询订单
return this.model.findOne({
where: {
channelServiceNo: channelServiceNo,
app_id: appId
},
attributes: ["id",
"orderNo",
"channelUserId",
"channelServiceNo",
"channelOrderNo",
"needNo",
"invoiceApplyStatus",
"orderType",
"salesNum",
"salesDiliverNum",
"minitermNum",
"minitermDiliverNum",
"orderPayStatus",
"notes",
"totalServiceCharge",
"totalPublicExpense",
"totalTaxes",
"totalSum",
"appPayType",
"payTime",
"itemCode",
"itemName",
"buyerMoblie"
],
raw: true
});
}
}
module.exports = OrderDao;
......@@ -60,6 +60,7 @@ module.exports = (db, DataTypes) => {
productType_id :DataTypes.INTEGER, //产品类型Id
productOneType_id :DataTypes.INTEGER, //产品大类Id
serviceItemSnapshot :DataTypes.TEXT, //产品快照
buyerMoblie :DataTypes.STRING(64), // 买家手机号
}, {
paranoid: false,//假的删除
underscored: true,
......
......@@ -7,8 +7,10 @@ class OrderService extends ServiceBase {
super("dborder", ServiceBase.getDaoName(OrderService));
this.logCtl = system.getObject("web.common.oplogCtl");
this.appproductDao = system.getObject("db.dbapp.appproductDao");
this.ordertmproductDao = system.getObject("db.dborder.ordertmproductDao");
this.execClient = system.getObject("util.execClient");
}
async op1688ChannelPushOrder(action_body, req) {
async op1688ChannelPushOrder(action_body, pobj, req) {
try {
var reqUrl = "https://inte-mcp.chanjet.com/gsb/getOrder?token=" + action_body.token;
var rtn = await this.execClient.execGet("", reqUrl);
......@@ -27,18 +29,19 @@ class OrderService extends ServiceBase {
}//操作需求
return system.getResultSuccess();
} catch (e) {
console.log(e.stack, "渠道回调信息返回结果:error......1.....");
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "/igirl-channel/zhichan/igirl-channel/app/base/service/impl/dborder/orderSve/opChannelCallbackData",
content: "请求地址:" + reqUrl + ",error:" + e.stack,
content: "error:" + e.stack,
clientIp: pobj.clientIp,
optitle: "渠道回调信息返回结果:" + rtn.stdout,
});
}
}
async op1688ChannelPushOrderTest(action_body, req) {
async op1688ChannelPushOrderTest(action_body, pobj, req) {
try {
var returnValue = [
......@@ -51,7 +54,7 @@ class OrderService extends ServiceBase {
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "W171200000000_44",
"orderItemNum": "W171200000000_33",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
......@@ -67,7 +70,7 @@ class OrderService extends ServiceBase {
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "W171200000000_33",
"orderItemNum": "W171200000000_44",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
......@@ -75,10 +78,10 @@ class OrderService extends ServiceBase {
"signCustomerUid": "12345678990000"
}
];
this.addOrderNeed(action_body, req, returnValue);
await this.addOrderNeed(action_body, req, returnValue);
return system.getResultSuccess();
} catch (e) {
console.log(e.stack, "渠道回调信息返回结果:error...........")
console.log(e.stack, "渠道回调信息返回结果:error...........");
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
......@@ -96,19 +99,27 @@ class OrderService extends ServiceBase {
if (!productItem) {
return;
}
var self = this;
//创建订单
var ordercode = await this.getBusUid("ts");
for (let index = 0; index < returnValue.length; index++) {
const element = returnValue[index];
if (element) {
if (element.bizStatusExt == "service") {
var orderCount = await self.findCount({ where: { needNo: element.orderItemNum } });
if (orderCount > 0) {
continue;
}
var payTime = null;
if (element.gmtCreate && element.gmtCreate.length > 14) {
payTime = element.gmtCreate.substr(0, 4) + "-" + element.gmtCreate.substr(4, 2) +
"-" + element.gmtCreate.substr(6, 2) + " " + element.gmtCreate.substr(8, 2) + ":" +
element.gmtCreate.substr(10, 2) + ":" + element.gmtCreate.substr(12, 2);
}
addOrderList.push({
await self.db.transaction(async function (t) {
//创建订单
var ordercode = await self.getBusUid("tm");
var orderParams = {
app_id: req.app.id,//
orderNo: ordercode,// 订单号
channelServiceNo: element.orderItemNum,// 渠道服务单号
......@@ -142,11 +153,90 @@ class OrderService extends ServiceBase {
productType_id: productItem.productType_id,//产品类型Id
productOneType_id: productItem.productOneType_id,//产品大类Id
serviceItemSnapshot: JSON.stringify(productItem),//产品快照
};
var orderItem = await self.dao.create(orderParams, t);//创建订单
if (productItem.itemCode == "zzsbzc") {
var orderProductObj = {
app_id: req.app.id,//
productType_id: productItem.productType_id,//产品类型Id
productOneType_id: productItem.productOneType_id,//产品大类Id
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
orderServicePayStatus: "yfk",//支付状态:dfk: 待付款, yfk: 已支付
appDataOpType: req.app.appDataOpType,// 应用数据操作类型:00独立,10全委托,20部分委托
sourceOrderNo: ordercode,//来源单号
deliveryOrderNo: await self.getBusUid("jf"),
channelServiceNo: element.orderItemNum || null,// 渠道服务单号
needNo: element.orderItemNum || null,//需求单号
sourceType: "00",
channelUserId: req.user.channelUserId || "",// 渠道用户id
createuser_id: req.user.id,//
createuser: req.user.nickname,//
};
//创建服务单
var orderTm = await self.ordertmproductDao.create(orderProductObj, t);//创建商标订单
}
});
}
}
}
this.dao.model.bulkCreate(addOrderList);
}
async pushFqBusiness(action_body, pobj, req) {
var rc = system.getObject("util.aliyunClient");
var item = await this.dao.getItemByChannelServiceNo(action_body.channelServiceNo, req.app.id);
if (!item) {
return system.getResult(null, "没有找到相关订单信息");
}
if (item.itemCode != "fzsbzc") {
return system.getResult(null, "订单类型有误,请推送商标注册-专家辅助申请的订单");
}
if (item.buyerMoblie) {
return system.getResult(null, "订单已经推送过,请勿重覆推送");
}
var rtn = null;
var reqUrl = "https://yunfuapi.gongsibao.com/crm/order/submit";
try {
var body = {
idempotentId: item.itemCode,// 是 业务 ID
idempotentSource: req.app.appSourceCode ? "tm_" + req.app.appSourceCode : "tm_1688",// 是 业务来源(ali、jd)
idempotentSourceName: req.app.name || "1688应用",// 是 阿里,京东
city: "",// 否 所属城市
phone: action_body.buyerMoblie,// 是 手机号
userId: item.channelUserId,// 否 用户 ID
companyName: "",// 否 公司名称
orderPrice: item.totalSum,// 是 订单金额
productId: "5dc936eb296d1572b9bc5b8d",// 是 产品 ID
productQuantity: item.salesNum,// 是 产品数量
};
rtn = await rc.post(reqUrl, body);
this.logCtl.info({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "/igirl-channel/zhichan/igirl-channel/app/base/service/impl/dborder/orderSve/pushFqBusiness",
content: "请求地址:" + reqUrl + ",参数:" + JSON.stringify(body) + ",返回结果:" + JSON.stringify(rtn),
clientIp: pobj.clientIp,
optitle: "推送订单商机到FQ信息",
});
if (rtn.code != 200 && rtn.success != true) {
return system.getResult(null, "推送失败,selfrequestId=" + req.requestId + ",requestId=" + rtn.requestId);
}
await this.updateByWhere({ buyerMoblie: action_body.buyerMoblie }, { where: { channelServiceNo: action_body.channelServiceNo } });
return system.getResultSuccess(null, "推送成功");
} catch (e) {
//日志记录
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "/igirl-channel/zhichan/igirl-channel/app/base/service/impl/dborder/orderSve/pushFqBusiness",
content: "error:" + e.stack,
clientIp: pobj.clientIp,
optitle: "推送订单商机到FQ出错",
});
}
}
}
module.exports = OrderService;
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