Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
59fdf874
Commit
59fdf874
authored
Mar 04, 2021
by
任晓松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync orde business
parent
e66d70cf
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
282 additions
and
2 deletions
+282
-2
center-order/app/base/api/impl/task/taskAction.js
+13
-1
center-order/app/base/db/impl/dbcorder/orderinfoDao.js
+46
-0
center-order/app/base/db/impl/dbcorder/orderinfofqDao.js
+40
-0
center-order/app/base/db/impl/dbneed/needinfofqDao.js
+4
-0
center-order/app/base/db/models/dbcorder/orderinfofq.js
+40
-0
center-order/app/base/service/impl/dbcorder/orderinfoSve.js
+139
-1
No files found.
center-order/app/base/api/impl/task/taskAction.js
View file @
59fdf874
...
@@ -8,7 +8,7 @@ class TaskAction extends APIBase {
...
@@ -8,7 +8,7 @@ class TaskAction extends APIBase {
this
.
opneedinfoSve
=
system
.
getObject
(
"service.dbneed.opneedinfoSve"
);
this
.
opneedinfoSve
=
system
.
getObject
(
"service.dbneed.opneedinfoSve"
);
}
}
/**
/**
*
接口跳转-POST请求
*
需求商机同步
* action_process 执行的流程
* action_process 执行的流程
* action_type 执行的类型
* action_type 执行的类型
* action_body 执行的参数
* action_body 执行的参数
...
@@ -18,5 +18,16 @@ class TaskAction extends APIBase {
...
@@ -18,5 +18,16 @@ class TaskAction extends APIBase {
return
result
;
return
result
;
}
}
/**
* 订单商机同步
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async
taskOrder
(
pobj
,
qobj
,
req
)
{
var
result
=
await
this
.
orderinfoSve
.
syncOrderBusiness
();
return
result
;
}
}
}
module
.
exports
=
TaskAction
;
module
.
exports
=
TaskAction
;
\ No newline at end of file
center-order/app/base/db/impl/dbcorder/orderinfoDao.js
View file @
59fdf874
const
system
=
require
(
"../../../system"
);
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
const
Dao
=
require
(
"../../dao.base"
);
const
{
Op
}
=
require
(
"sequelize"
);
class
OrderInfoDao
extends
Dao
{
class
OrderInfoDao
extends
Dao
{
constructor
()
{
constructor
()
{
super
(
Dao
.
getModelName
(
OrderInfoDao
));
super
(
Dao
.
getModelName
(
OrderInfoDao
));
...
@@ -56,5 +57,50 @@ class OrderInfoDao extends Dao {
...
@@ -56,5 +57,50 @@ class OrderInfoDao extends Dao {
await
this
.
customInsert
(
sql
,
null
,
t
);
await
this
.
customInsert
(
sql
,
null
,
t
);
return
system
.
getResultSuccess
()
return
system
.
getResultSuccess
()
}
}
/**
* 根据ids 获取需求
* @param ids
* @returns {Promise<void>}
*/
async
getOrdersByIds
(
ids
){
let
orders
=
await
this
.
findAll
({
where
:
{
channelOrderNo
:
{
[
Op
.
in
]:
ids
}
}
})
return
orders
;
}
/**
* 批量更新
* @param needs
* @returns {Promise<Array<Model>|*>}
*/
async
bulkUpdate
(
orders
){
let
result
=
await
this
.
bulkCreate
(
orders
,{
fields
:[
"id"
,
"status"
,
"statusName"
]
,
updateOnDuplicate
:
[
"status"
,
"statusName"
]
});
return
result
;
}
/**
* 批量更新
* @param needs
* @returns {Promise<Array<Model>|*>}
*/
async
bulkUpdateStatus
(
status
,
statusName
,
ids
){
let
result
=
await
this
.
updateByWhere
({
orderStatus
:
status
,
orderStatusName
:
statusName
},{
where
:
{
channelOrderNo
:{
[
Op
.
in
]:
ids
}
}
});
return
result
;
}
}
}
module
.
exports
=
OrderInfoDao
;
module
.
exports
=
OrderInfoDao
;
center-order/app/base/db/impl/dbcorder/orderinfofqDao.js
0 → 100644
View file @
59fdf874
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
const
{
Op
}
=
require
(
"sequelize"
);
class
OrderinfofqDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
OrderinfofqDao
));
}
/**
* 取300条未处理的数据
* @returns {Promise<Array<Model>>}
*/
async
getAllOrders
(){
let
fqNeeds
=
await
this
.
findAll
({
where
:
{
handleStatus
:
0
},
order
:
[[
"id"
,
"desc"
]],
limit
:
300
})
return
fqNeeds
;
}
/**
* 批量更新
* @param needs
* @returns {Promise<Array<Model>|*>}
*/
async
bulkUpdate
(
ids
){
let
result
=
await
this
.
updateByWhere
({
handleStatus
:
1
},{
where
:
{
channelOrderNo
:{
[
Op
.
in
]:
ids
}
}
});
return
result
;
}
}
module
.
exports
=
OrderinfofqDao
;
center-order/app/base/db/impl/dbneed/needinfofqDao.js
View file @
59fdf874
...
@@ -6,6 +6,10 @@ class NeedinfofqDao extends Dao {
...
@@ -6,6 +6,10 @@ class NeedinfofqDao extends Dao {
super
(
Dao
.
getModelName
(
NeedinfofqDao
));
super
(
Dao
.
getModelName
(
NeedinfofqDao
));
}
}
/**
* 取300条未处理的数据
* @returns {Promise<Array<Model>>}
*/
async
getAllNeeds
(){
async
getAllNeeds
(){
let
fqNeeds
=
await
this
.
findAll
({
let
fqNeeds
=
await
this
.
findAll
({
where
:
{
where
:
{
...
...
center-order/app/base/db/models/dbcorder/orderinfofq.js
0 → 100644
View file @
59fdf874
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
appKey
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"orderinfofq"
,
{
sourceName
:
DataTypes
.
STRING
(
128
),
// 来源名称(source_name)
serviceOrderNo
:
DataTypes
.
STRING
(
128
),
// 服务商订单号(页面中列表中显示该单号)-云服(no)
channelServiceNo
:
DataTypes
.
STRING
(
128
),
// 渠道服务单号
channelOrderNo
:
DataTypes
.
STRING
(
128
),
// 渠道订单号(页面中列表中显示该单号)(idempotent_no)
channelNeedNo
:
DataTypes
.
STRING
(
128
),
// 渠道需求号(页面中列表中显示该需求号)
needNo
:
DataTypes
.
STRING
(
128
),
//需求号(need_no)
payTime
:
DataTypes
.
DATE
,
// 支付时间(first_pay_time)
quantity
:
DataTypes
.
INTEGER
,
// 项目订单数量(即服务项目的倍数,默认值为1)
orderStatusName
:
DataTypes
.
STRING
(
50
),
//订单状态名称
orderStatus
:
DataTypes
.
INTEGER
,
// 订单状态: 1: 待付款, 2: 已付款, 4: 服务中, 8: 已完成, 16: 已退款, 32: 已作废
totalSum
:
DataTypes
.
DECIMAL
(
12
,
2
),
// 订单总额(产品价格×优惠费率×订单件数)
payTotalSum
:
DataTypes
.
DECIMAL
(
12
,
2
),
// 订单付款总额
refundSum
:
DataTypes
.
DECIMAL
(
12
,
2
),
// 退款金额
refundTime
:
DataTypes
.
DATE
,
//2020/6/17 lin新增 退款时间
notes
:
DataTypes
.
STRING
,
// 备注
isSolution
:
DataTypes
.
INTEGER
,
// 是否有方案,0无,1有
handleStatus
:
DataTypes
.
INTEGER
,
// 处理状态,0否,1是
source_code
:
DataTypes
.
STRING
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
timestamps
:
true
,
updated_at
:
true
,
// 2020 0618 lin修改
//freezeTableName: true,
// define the table's name
tableName
:
'c_order_info_fq'
,
validate
:
{
},
indexes
:
[
]
});
}
center-order/app/base/service/impl/dbcorder/orderinfoSve.js
View file @
59fdf874
...
@@ -17,7 +17,8 @@ class OrderInfoService extends ServiceBase {
...
@@ -17,7 +17,8 @@ class OrderInfoService extends ServiceBase {
this
.
needsolutionDao
=
system
.
getObject
(
"db.dbneed.needsolutionDao"
);
this
.
needsolutionDao
=
system
.
getObject
(
"db.dbneed.needsolutionDao"
);
this
.
orderRegionDao
=
system
.
getObject
(
"db.dbcorder.orderregionDao"
);
this
.
orderRegionDao
=
system
.
getObject
(
"db.dbcorder.orderregionDao"
);
this
.
push360Sve
=
system
.
getObject
(
'service.common.push360Sve'
);
this
.
push360Sve
=
system
.
getObject
(
'service.common.push360Sve'
);
this
.
orderinfoDao
=
system
.
getObject
(
'db.dbcorder.orderinfoDao'
);
this
.
orderinfofqDao
=
system
.
getObject
(
'db.dbcorder.orderinfofqDao'
);
}
}
//--------------------task----------------start-------------------
//--------------------task----------------start-------------------
...
@@ -2275,5 +2276,141 @@ class OrderInfoService extends ServiceBase {
...
@@ -2275,5 +2276,141 @@ class OrderInfoService extends ServiceBase {
}
}
return
system
.
getResultSuccess
(
orRet
);
return
system
.
getResultSuccess
(
orRet
);
}
}
/**
* 同步蜂擎订单商机
* @returns {Promise<void>}
*/
async
syncOrderBusiness
()
{
//获取 need_info_fq 未处理的需求
let
fqOrders
=
await
this
.
orderinfofqDao
.
getAllOrders
()
let
ids
=
[];
let
orderDict
=
{};
for
(
let
i
=
0
;
i
<
fqOrders
.
length
;
i
++
)
{
ids
.
push
(
fqOrders
[
i
].
channelOrderNo
);
orderDict
[
fqOrders
[
i
].
channelOrderNo
]
=
fqOrders
[
i
].
orderStatus
;
}
//根据ids 获取企服通需求
let
orders
=
await
this
.
orderinfoDao
.
getOrdersByIds
(
ids
);
let
setObj
=
[];
let
existIds
=
[];
let
ids1
=
[];
let
ids2
=
[];
let
ids3
=
[];
let
ids4
=
[];
let
ids5
=
[];
let
ids6
=
[];
let
ids7
=
[];
//已经存在的需求,更改状态
for
(
let
i
=
0
;
i
<
orders
.
length
;
i
++
){
let
order
=
orders
[
i
];
let
obj
=
{
id
:
order
.
id
,
}
if
(
orderDict
[
order
.
channelOrderNo
]
==
1
){
ids1
.
push
(
order
.
channelOrderNo
);
}
if
(
orderDict
[
order
.
channelOrderNo
]
==
2
){
ids2
.
push
(
order
.
channelOrderNo
);
}
if
(
orderDict
[
order
.
channelOrderNo
]
==
4
){
ids3
.
push
(
order
.
channelOrderNo
);
}
if
(
orderDict
[
order
.
channelOrderNo
]
==
8
){
ids4
.
push
(
order
.
channelOrderNo
);
}
if
(
orderDict
[
order
.
channelOrderNo
]
==
16
){
ids5
.
push
(
order
.
channelOrderNo
);
}
if
(
orderDict
[
order
.
channelOrderNo
]
==
32
){
ids6
.
push
(
order
.
channelOrderNo
);
}
if
(
orderDict
[
order
.
channelOrderNo
]
==
64
){
ids7
.
push
(
order
.
channelOrderNo
);
}
setObj
.
push
(
obj
);
existIds
.
push
(
order
.
channelOrderNo
);
}
// 不存在的订单 添加到企服通
let
createObj
=
[];
let
setFqObj1
=
[];
let
setFqObj2
=
[];
for
(
let
i
=
0
;
i
<
fqOrders
.
length
;
i
++
){
let
fqOrder
=
fqOrders
[
i
].
dataValues
;
if
(
!
existIds
.
includes
(
fqOrder
.
channelOrderNo
)){
fqOrder
.
orderNo
=
fqOrder
.
channelOrderNo
;
if
([
'360_icp '
,
'360_edi'
,
'360_sbzc'
].
includes
(
fqOrder
.
source_code
)){
fqOrder
.
uapp_id
=
50
;
}
if
([
'baidu_edi'
,
'baidu_gsreg'
,
'baidu_icp'
,
'baidu_radiotv'
,
'baidu_wangwen'
].
includes
(
fqOrder
.
source_code
)){
fqOrder
.
uapp_id
=
44
;
}
if
([
'edi_ali'
,
'ic_ali'
,
'icp_ali'
,
'tm_ali'
,
'tmd_ali'
].
includes
(
fqOrder
.
source_code
)){
fqOrder
.
uapp_id
=
18
;
}
if
([
'youke'
].
includes
(
fqOrder
.
source_code
)){
fqOrder
.
uapp_id
=
40
;
}
if
([
'tm_jdyun'
].
includes
(
fqOrder
.
source_code
)){
fqOrder
.
uapp_id
=
31
;
}
if
([
'tm_bw'
].
includes
(
fqOrder
.
source_code
)){
fqOrder
.
uapp_id
=
35
;
}
if
([
'tm_1688'
].
includes
(
fqOrder
.
source_code
)){
fqOrder
.
uapp_id
=
0
;
}
delete
fqOrder
.
sourceName
;
delete
fqOrder
.
source_code
;
delete
fqOrder
.
handleStatus
;
delete
fqOrder
.
id
;
if
(
!
setFqObj2
.
includes
(
fqOrder
.
channelOrderNo
)){
createObj
.
push
(
fqOrder
);
setFqObj2
.
push
(
fqOrder
.
channelOrderNo
);
}
}
else
{
setFqObj1
.
push
(
fqOrder
.
channelOrderNo
);
}
}
//企服通 批量更新状态
let
updateRet
=
[];
if
(
setObj
.
length
>
0
){
// updateRet = await this.needinfoDao.bulkUpdate(setObj);
// 1: 待付款, 2: 已付款, 4: 服务中, 8: 已完成, 16: 已退款, 32: 已作废, 64: 已付部分款
if
(
ids1
.
length
>
0
){
updateRet
=
await
this
.
orderinfoDao
.
bulkUpdateStatus
(
1
,
'待付款'
,
ids1
);
}
if
(
ids2
.
length
>
0
){
updateRet
=
await
this
.
orderinfoDao
.
bulkUpdateStatus
(
2
,
'已付款'
,
ids2
);
}
if
(
ids3
.
length
>
0
){
updateRet
=
await
this
.
orderinfoDao
.
bulkUpdateStatus
(
4
,
'服务中'
,
ids3
);
}
if
(
ids4
.
length
>
0
){
updateRet
=
await
this
.
orderinfoDao
.
bulkUpdateStatus
(
8
,
'已完成'
,
ids4
);
}
if
(
ids5
.
length
>
0
){
updateRet
=
await
this
.
orderinfoDao
.
bulkUpdateStatus
(
16
,
'已退款'
,
ids5
);
}
if
(
ids6
.
length
>
0
){
updateRet
=
await
this
.
orderinfoDao
.
bulkUpdateStatus
(
32
,
'已作废'
,
ids6
);
}
if
(
ids7
.
length
>
0
){
updateRet
=
await
this
.
orderinfoDao
.
bulkUpdateStatus
(
64
,
'已付部分款'
,
ids7
);
}
if
(
updateRet
.
length
>
0
){
updateRet
=
await
this
.
orderinfofqDao
.
bulkUpdate
(
setFqObj1
);
}
}
//企服通 批量添加
if
(
createObj
.
length
>
0
){
updateRet
=
await
this
.
orderinfoDao
.
bulkCreate
(
createObj
);
if
(
updateRet
.
length
>
0
){
updateRet
=
await
this
.
orderinfofqDao
.
bulkUpdate
(
setFqObj2
);
}
}
return
system
.
getResult
(
updateRet
)
}
}
}
module
.
exports
=
OrderInfoService
;
module
.
exports
=
OrderInfoService
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment