Commit 3edb9083 by largezhou

Merge branch 'test' into 'master' (merge request !1)

test
分配 相关修改
parents cf3081d5 4bad2708
......@@ -467,6 +467,24 @@ class UserService extends ServiceBase {
})
}
async findCostBySkuCode(skucode) {
let productpricetmp = await this.db.models.productprice.findOne({
where: { skucode: skucode, isEnabled: true },
include: [
{ model: this.db.models.productcost, where: { expensetype: 'service' }, as: "costs", attributes: ['id', 'expensetype', 'costamount'] }
],
raw: true,
}
)
let costAmount = 0
//获取服务费成本
if (productpricetmp && productpricetmp['costs.costamount']) {
costAmount = Number(productpricetmp['costs.costamount'])
} else {
console.log("skucode not find product:", skucode)
}
return costAmount
}
/**
*
* @param {*} clientMobile 客户电话
......@@ -480,26 +498,7 @@ class UserService extends ServiceBase {
var self = this
//按照服务商名字查询到公司,按照公司查询出users,条件是可以接受派单任务,并且技能标签含有,产品类别名称
return this.db.transaction(async function (t) {
//按照产品简码,查询服务成本
let productpricetmp = await self.db.models.productprice.findOne({
where: { skucode: skucode },
include: [
{ model: self.db.models.productcost, as: "costs", attributes: ['id', 'expensetype', 'costamount'] }
],
transaction: t
}
)
let serviceCost = productpricetmp.costs.filter(c => {
if (c.expensetype == "service") {
return true
}
})
let costAmount = 0
//获取服务费成本
if (serviceCost.length > 0) {
costAmount = serviceCost[0].costamount
}
//先检查缓存是否存在bizuser todo key再加个字母d
var resultcache = await self.cacheManager["ClientBindBizUserCache"].getCache(clientMobile)
let isGoExec = false
......@@ -513,69 +512,68 @@ class UserService extends ServiceBase {
await self.cacheManager["ClientBindBizUserCache"].invalidate(clientMobile)
}
}
if (isGoExec) {
let companyFind = await self.companyDao.model.findOne({
where: { name: spName }, include: [
{
model: self.db.models.user, as: "us", attributes: ['id', 'userName', 'mobile', 'isAllocated', 'opath', 'skilltags', 'regiontags', 'isAllArea', 'isSalesman', 'isDelivery'], raw: true
}
], excludes: ['orgJson'], transaction: t
});
console.log("getBizUserForDelivery获取服务商信息:" + JSON.stringify(companyFind));
let users = companyFind.us
let cansels = users.filter(u => {
if (regionName && regionName != "" && u.regiontags) {
if (u.isAllocated && u.isDelivery && u.skilltags.indexOf(productCatName) >= 0) {
if (u.regiontags.indexOf(regionName) >= 0 || u.isAllArea) {
return true
let companyFind = await self.companyDao.model.findOne({
where: { name: spName }, include: [
{
model: self.db.models.user, as: "us", attributes: ['id', 'userName', 'mobile', 'isAllocated', 'opath', 'skilltags', 'regiontags', 'isAllArea', 'isSalesman', 'isDelivery'], raw: true
}
], excludes: ['orgJson'], transaction: t
});
console.log("getBizUserForDelivery获取服务商信息:" + companyFind);
if (companyFind) {
if (isGoExec) {
let users = companyFind.us
let cansels = users.filter(u => {
if (regionName && regionName != "" && u.regiontags) {
if (u.isAllocated && u.isDelivery && u.skilltags.indexOf(productCatName) >= 0) {
if (u.regiontags.indexOf(regionName) >= 0 || u.isAllArea) {
return true
} else {
return false
}
} else {
return false
}
} else {
return false
if (u.isAllocated && u.isDelivery && u.isAllArea && u.skilltags.indexOf(productCatName) >= 0) {
return true
} else {
return false
}
}
} else {
if (u.isAllocated && u.isDelivery && u.isAllArea && u.skilltags.indexOf(productCatName) >= 0) {
return true
} else {
return false
})
console.log("getBizUserForDelivery可以接单的交付员:" + JSON.stringify(cansels) + "服务商id:" + companyFind.id);
let lngth = cansels.length
if (lngth > 0) {
let randindex = Math.floor(Math.random() * lngth)
let selresult = cansels[randindex]
//添加到缓存,按照客户电话key--缓存到业务员的对象
let tmp = {
userId: selresult.id,
userName: selresult.userName,
mobile: selresult.mobile,
opath: selresult.opath,
cost: costAmount,
compId: companyFind.id
}
await self.cacheManager["ClientBindBizUserCache"].cache(clientMobile, tmp)
return { userInfo: tmp, comInfo: { cost: tmp.cost, compId: tmp.compId } };
} else {
return { userInfo: null, comInfo: { cost: costAmount, compId: companyFind.id } };
}
})
console.log("getBizUserForDelivery可以接单的交付员:" + JSON.stringify(cansels) + "服务商id:" + companyFind.id);
let lngth = cansels.length
if (lngth > 0) {
let randindex = Math.floor(Math.random() * lngth)
let selresult = cansels[randindex]
//添加到缓存,按照客户电话key--缓存到业务员的对象
let tmp = {
userId: selresult.id,
userName: selresult.userName,
mobile: selresult.mobile,
opath: selresult.opath,
cost: costAmount,
compId: companyFind.id
}
await self.cacheManager["ClientBindBizUserCache"].cache(clientMobile, tmp)
return { userInfo: tmp, comInfo: { cost: tmp.cost, compId: tmp.compId } };
} else {
return { userInfo: null, comInfo: { cost: tmp.cost, compId: tmp.compId } };
}
} else {
if (resultcache) {//不继续,直接返回缓存
resultcache["cost"] = costAmount
return { userInfo: resultcache.tmp, comInfo: { cost: costAmount, compId: companyFind.id } };
} else {
return { userInfo: null, comInfo: { cost: costAmount, compId: companyFind.id } };
if (resultcache) {//不继续,直接返回缓存
resultcache["cost"] = costAmount
return { userInfo: resultcache.tmp, comInfo: { cost: costAmount, compId: companyFind.id } };
} else {
return { userInfo: null, comInfo: { cost: costAmount, compId: companyFind.id } };
}
}
} else {
return { userInfo: null, comInfo: null }
}
})
}
}
module.exports = UserService;
// let userS=new UserService()
// userS.getBizUserForBizChance("13381139519",'好生日','工商注册').then(rtn=>{
// console.log(rtn)
// })
\ No newline at end of file
module.exports = UserService;
\ No newline at end of file
......@@ -14,7 +14,7 @@ class TxHandler {
* @param {*} datajson
*/
//新商机处理
async addChance(datajson) {
async addChance (datajson) {
console.log("put in queue", datajson);
try {
var cachestr = sha235(JSON.stringify(datajson));
......@@ -101,7 +101,7 @@ class TxHandler {
}
//退回商机处理
async needClose(datajson) {
async needClose (datajson) {
console.log("put in queue" + JSON.stringify(datajson) + "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
try {
var cachestr = sha235(JSON.stringify(datajson));
......@@ -179,7 +179,7 @@ class TxHandler {
}
//交付单处理
async orderSubmit(datajson) {
async orderSubmit (datajson) {
console.log("put in queue-----------------------------------------------------------------------------------------------------", datajson);
try {
var cachestr = sha235(JSON.stringify(datajson));
......@@ -246,6 +246,10 @@ class TxHandler {
params.costPrice = salesmanInfo.comInfo.cost;
params.servicerCode = salesmanInfo.comInfo.compId;
}
//设置成本 tocheck
let costprice = await this.userService.findCostBySkuCode(datajson.actionBody.txPriceCode)
params.costPrice = costprice
if (salesmanInfo.userInfo && salesmanInfo.userInfo != 'undefined') {
params.clerkOpcode = salesmanInfo.userInfo.opath;
params.clerkId = salesmanInfo.userInfo.userId;
......@@ -464,7 +468,7 @@ class TxHandler {
}
//关闭交付单处理
async orderClose(datajson) {
async orderClose (datajson) {
console.log("put in queue", datajson);
try {
var cachestr = sha235(JSON.stringify(datajson));
......
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/ccc.png><title></title><link href=/css/chunk-14b9857b.0dc416de.css rel=prefetch><link href=/css/chunk-175acaff.d8eef113.css rel=prefetch><link href=/css/chunk-1b756945.9e7173ae.css rel=prefetch><link href=/css/chunk-21b5182a.6e6ae301.css rel=prefetch><link href=/css/chunk-2c359864.0dc416de.css rel=prefetch><link href=/css/chunk-3385141a.0dc416de.css rel=prefetch><link href=/css/chunk-3f4029e7.84fd9662.css rel=prefetch><link href=/css/chunk-5ccefbbb.9e7173ae.css rel=prefetch><link href=/css/chunk-61b0b1e5.9e7173ae.css rel=prefetch><link href=/css/chunk-738a8724.71e3d438.css rel=prefetch><link href=/css/chunk-8e32057a.e8e9a917.css rel=prefetch><link href=/css/chunk-e7e51fa0.9e7173ae.css rel=prefetch><link href=/css/chunk-ff3eaeb0.9e7173ae.css rel=prefetch><link href=/js/chunk-037694a5.7e50cc17.js rel=prefetch><link href=/js/chunk-0aa2a834.9028f9e8.js rel=prefetch><link href=/js/chunk-137dcf78.d8fcc61f.js rel=prefetch><link href=/js/chunk-14b9857b.35e42781.js rel=prefetch><link href=/js/chunk-15d6294e.55b58866.js rel=prefetch><link href=/js/chunk-175acaff.ca3f7e65.js rel=prefetch><link href=/js/chunk-1792c498.c1554a3b.js rel=prefetch><link href=/js/chunk-1a0615f2.b051fd28.js rel=prefetch><link href=/js/chunk-1b756945.f2391a13.js rel=prefetch><link href=/js/chunk-21b5182a.64203a99.js rel=prefetch><link href=/js/chunk-22347577.172e21a4.js rel=prefetch><link href=/js/chunk-24a41303.88feac34.js rel=prefetch><link href=/js/chunk-25d9ab36.087a7b9f.js rel=prefetch><link href=/js/chunk-2aeda6fa.2bd11851.js rel=prefetch><link href=/js/chunk-2b3066fa.9ae15683.js rel=prefetch><link href=/js/chunk-2c359864.90a950b1.js rel=prefetch><link href=/js/chunk-2d0d61ef.cce6bf6e.js rel=prefetch><link href=/js/chunk-2d0e68e0.1a313c84.js rel=prefetch><link href=/js/chunk-2d0efc5d.662e1339.js rel=prefetch><link href=/js/chunk-3385141a.a6e1a986.js rel=prefetch><link href=/js/chunk-3a0bcea0.192dd1cf.js rel=prefetch><link href=/js/chunk-3f4029e7.99f54f70.js rel=prefetch><link href=/js/chunk-477a8e91.c603527d.js rel=prefetch><link href=/js/chunk-4b58f216.e79a0ff7.js rel=prefetch><link href=/js/chunk-5ccefbbb.0f021a99.js rel=prefetch><link href=/js/chunk-5e7b929d.f3ce9ea9.js rel=prefetch><link href=/js/chunk-61b0b1e5.e4ead4e0.js rel=prefetch><link href=/js/chunk-65e97401.3b9c7780.js rel=prefetch><link href=/js/chunk-738a8724.0af49f4b.js rel=prefetch><link href=/js/chunk-75b126e3.7ed92c02.js rel=prefetch><link href=/js/chunk-8e32057a.99a05e99.js rel=prefetch><link href=/js/chunk-9947983a.dac20f72.js rel=prefetch><link href=/js/chunk-e7e51fa0.2dc827c3.js rel=prefetch><link href=/js/chunk-ff3eaeb0.73991da8.js rel=prefetch><link href=/css/app.4f840f8a.css rel=preload as=style><link href=/css/chunk-vendors.1d90d08d.css rel=preload as=style><link href=/js/app.f3eb5b36.js rel=preload as=script><link href=/js/chunk-vendors.d7971afc.js rel=preload as=script><link href=/css/chunk-vendors.1d90d08d.css rel=stylesheet><link href=/css/app.4f840f8a.css rel=stylesheet></head><body><noscript><strong>We're sorry but iview-admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.d7971afc.js></script><script src=/js/app.f3eb5b36.js></script></body></html>
\ No newline at end of file
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/ccc.png><title></title><link href=/css/chunk-14b9857b.0dc416de.css rel=prefetch><link href=/css/chunk-175acaff.d8eef113.css rel=prefetch><link href=/css/chunk-1b756945.9e7173ae.css rel=prefetch><link href=/css/chunk-21b5182a.6e6ae301.css rel=prefetch><link href=/css/chunk-2c359864.0dc416de.css rel=prefetch><link href=/css/chunk-3385141a.0dc416de.css rel=prefetch><link href=/css/chunk-3f4029e7.84fd9662.css rel=prefetch><link href=/css/chunk-5ccefbbb.9e7173ae.css rel=prefetch><link href=/css/chunk-61b0b1e5.9e7173ae.css rel=prefetch><link href=/css/chunk-738a8724.71e3d438.css rel=prefetch><link href=/css/chunk-8e32057a.e8e9a917.css rel=prefetch><link href=/css/chunk-e7e51fa0.9e7173ae.css rel=prefetch><link href=/css/chunk-ff3eaeb0.9e7173ae.css rel=prefetch><link href=/js/chunk-037694a5.7e50cc17.js rel=prefetch><link href=/js/chunk-0aa2a834.9028f9e8.js rel=prefetch><link href=/js/chunk-137dcf78.d8fcc61f.js rel=prefetch><link href=/js/chunk-14b9857b.35e42781.js rel=prefetch><link href=/js/chunk-15d6294e.55b58866.js rel=prefetch><link href=/js/chunk-175acaff.ca3f7e65.js rel=prefetch><link href=/js/chunk-1792c498.c1554a3b.js rel=prefetch><link href=/js/chunk-1a0615f2.b051fd28.js rel=prefetch><link href=/js/chunk-1b756945.f2391a13.js rel=prefetch><link href=/js/chunk-21b5182a.64203a99.js rel=prefetch><link href=/js/chunk-22347577.172e21a4.js rel=prefetch><link href=/js/chunk-24a41303.88feac34.js rel=prefetch><link href=/js/chunk-25d9ab36.087a7b9f.js rel=prefetch><link href=/js/chunk-2aeda6fa.2bd11851.js rel=prefetch><link href=/js/chunk-2b3066fa.9ae15683.js rel=prefetch><link href=/js/chunk-2c359864.90a950b1.js rel=prefetch><link href=/js/chunk-2d0d61ef.cce6bf6e.js rel=prefetch><link href=/js/chunk-2d0e68e0.1a313c84.js rel=prefetch><link href=/js/chunk-2d0efc5d.662e1339.js rel=prefetch><link href=/js/chunk-3385141a.a6e1a986.js rel=prefetch><link href=/js/chunk-3a0bcea0.192dd1cf.js rel=prefetch><link href=/js/chunk-3f4029e7.99f54f70.js rel=prefetch><link href=/js/chunk-477a8e91.c603527d.js rel=prefetch><link href=/js/chunk-4b58f216.e79a0ff7.js rel=prefetch><link href=/js/chunk-5ccefbbb.0f021a99.js rel=prefetch><link href=/js/chunk-5e7b929d.f3ce9ea9.js rel=prefetch><link href=/js/chunk-61b0b1e5.e4ead4e0.js rel=prefetch><link href=/js/chunk-65e97401.3b9c7780.js rel=prefetch><link href=/js/chunk-738a8724.0af49f4b.js rel=prefetch><link href=/js/chunk-75b126e3.7ed92c02.js rel=prefetch><link href=/js/chunk-8e32057a.99a05e99.js rel=prefetch><link href=/js/chunk-9947983a.dac20f72.js rel=prefetch><link href=/js/chunk-e7e51fa0.2dc827c3.js rel=prefetch><link href=/js/chunk-ff3eaeb0.73991da8.js rel=prefetch><link href=/css/app.4f840f8a.css rel=preload as=style><link href=/css/chunk-vendors.1d90d08d.css rel=preload as=style><link href=/js/app.0e336174.js rel=preload as=script><link href=/js/chunk-vendors.d7971afc.js rel=preload as=script><link href=/css/chunk-vendors.1d90d08d.css rel=stylesheet><link href=/css/app.4f840f8a.css rel=stylesheet></head><body><noscript><strong>We're sorry but iview-admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.d7971afc.js></script><script src=/js/app.0e336174.js></script></body></html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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