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
f018ded6
Commit
f018ded6
authored
Feb 13, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
e79ba71b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
394 deletions
+122
-394
center-order/app/base/service/impl/dbcorder/orderinfoSve.js
+122
-394
No files found.
center-order/app/base/service/impl/dbcorder/orderinfoSve.js
View file @
f018ded6
...
@@ -10,11 +10,6 @@ class OrderInfoService extends ServiceBase {
...
@@ -10,11 +10,6 @@ class OrderInfoService extends ServiceBase {
this
.
moneyJourneyDao
=
system
.
getObject
(
"db.dbcpay.moneyjourneyDao"
);
this
.
moneyJourneyDao
=
system
.
getObject
(
"db.dbcpay.moneyjourneyDao"
);
this
.
pushlogSve
=
system
.
getObject
(
"service.common.pushlogSve"
);
this
.
pushlogSve
=
system
.
getObject
(
"service.common.pushlogSve"
);
}
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
/*
/*
* 订单验证
* 订单验证
*/
*/
...
@@ -47,6 +42,7 @@ class OrderInfoService extends ServiceBase {
...
@@ -47,6 +42,7 @@ class OrderInfoService extends ServiceBase {
pfProfitSum
=
0
;
pfProfitSum
=
0
;
}
}
var
channelProfitSum
=
Number
(
totalProfitSum
)
-
Number
(
pfProfitSum
);
var
channelProfitSum
=
Number
(
totalProfitSum
)
-
Number
(
pfProfitSum
);
var
payTime
=
channelOrder
.
payTime
||
new
Date
();
var
params
=
{
var
params
=
{
uapp_id
:
pobj
.
appInfo
.
uapp_id
,
//int(11) //
uapp_id
:
pobj
.
appInfo
.
uapp_id
,
//int(11) //
orderNo
:
orderNo
,
//varchar(64) //订单号
orderNo
:
orderNo
,
//varchar(64) //订单号
...
@@ -56,7 +52,7 @@ class OrderInfoService extends ServiceBase {
...
@@ -56,7 +52,7 @@ class OrderInfoService extends ServiceBase {
ownerUserId
:
pobj
.
userInfo
.
channel_userId
,
//varchar(20) //
ownerUserId
:
pobj
.
userInfo
.
channel_userId
,
//varchar(20) //
needNo
:
channelOrder
.
needNo
||
""
,
//varchar(64) //需求单号
needNo
:
channelOrder
.
needNo
||
""
,
//varchar(64) //需求单号
needNoOrderNo
:
channelOrder
.
needNoOrderNo
||
""
,
//varchar(64) //需求订单号
needNoOrderNo
:
channelOrder
.
needNoOrderNo
||
""
,
//varchar(64) //需求订单号
payTime
:
channelOrder
.
orderStatus
&&
channelOrder
.
orderStatus
==
1
?
new
Date
()
:
null
,
//datetime //
payTime
:
channelOrder
.
orderStatus
&&
channelOrder
.
orderStatus
==
1
?
payTime
:
null
,
//datetime //
quantity
:
actionBody
.
quantity
,
//int(11) //项目订单数量(即服务项目的倍数,默认值为1)
quantity
:
actionBody
.
quantity
,
//int(11) //项目订单数量(即服务项目的倍数,默认值为1)
serviceQuantity
:
0
,
//int(11) //项目订单交付数量(即与项目订单数量相对应)
serviceQuantity
:
0
,
//int(11) //项目订单交付数量(即与项目订单数量相对应)
orderStatus
:
channelOrder
.
orderStatus
||
1
,
//int //订单状态: 1: 待付款, 2: 已付款, 4: 待服务, 8: 已完成
orderStatus
:
channelOrder
.
orderStatus
||
1
,
//int //订单状态: 1: 待付款, 2: 已付款, 4: 待服务, 8: 已完成
...
@@ -92,8 +88,8 @@ class OrderInfoService extends ServiceBase {
...
@@ -92,8 +88,8 @@ class OrderInfoService extends ServiceBase {
opPayType
:
"00"
,
// 操作付款类型:00: 创建订单, 10: 补单
opPayType
:
"00"
,
// 操作付款类型:00: 创建订单, 10: 补单
serviceItemSnapshot
:
JSON
.
stringify
(
actionBody
.
product_info
),
//产品快照
serviceItemSnapshot
:
JSON
.
stringify
(
actionBody
.
product_info
),
//产品快照
};
};
var
orderProduct
=
await
self
.
orderProductDao
.
create
(
orderProductObj
,
t
);
//订单产品
var
orderProduct
=
await
this
.
orderProductDao
.
create
(
orderProductObj
,
t
);
//订单产品
if
(
channelOrder
.
orderStatus
==
2
)
{
if
(
channelOrder
.
orderStatus
&&
channelOrder
.
orderStatus
==
2
)
{
//订单状态: 1: 待付款, 2: 已付款, 4: 待服务, 8: 已完成
var
moneyObj
=
{
var
moneyObj
=
{
uapp_id
:
pobj
.
appInfo
.
uapp_id
,
uapp_id
:
pobj
.
appInfo
.
uapp_id
,
sourceOrderNo
:
orderNo
,
// 来源单号
sourceOrderNo
:
orderNo
,
// 来源单号
...
@@ -101,35 +97,30 @@ class OrderInfoService extends ServiceBase {
...
@@ -101,35 +97,30 @@ class OrderInfoService extends ServiceBase {
ownerUserId
:
pobj
.
userInfo
.
channel_userId
,
ownerUserId
:
pobj
.
userInfo
.
channel_userId
,
accountType
:
"other"
,
//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
accountType
:
"other"
,
//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
directionType
:
"sr"
,
//凭单类型,"sr": "收","zc": "支"
directionType
:
"sr"
,
//凭单类型,"sr": "收","zc": "支"
voucherDate
:
channelOrder
.
payTime
,
//凭单时间
voucherDate
:
payTime
,
//凭单时间
recvAmount
:
channelOrder
.
t
otalSum
,
//收总额
recvAmount
:
channelOrder
.
payT
otalSum
,
//收总额
sourceType
:
"orderinfo"
,
//来源类型 "orderinfo": "订单","expensevoucher": "费用单"
sourceType
:
"orderinfo"
,
//来源类型 "orderinfo": "订单","expensevoucher": "费用单"
auditStatus
:
"tg"
,
//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
auditStatus
:
"tg"
,
//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
};
};
var
moneyJourney
=
await
self
.
moneyJourneyDao
.
create
(
moneyObj
,
t
);
var
moneyJourney
=
await
this
.
moneyJourneyDao
.
create
(
moneyObj
,
t
);
var
orderReceiptVoucherObj
=
{
var
orderReceiptVoucherObj
=
{
uapp_id
:
pobj
.
appInfo
.
uapp_id
,
uapp_id
:
pobj
.
appInfo
.
uapp_id
,
sourceOrderNo
:
orderNo
,
// 来源单号
sourceOrderNo
:
orderNo
,
// 来源单号
accountType
:
"other"
,
accountType
:
"other"
,
payDate
:
channelOrder
.
payTime
,
//支付时间
payDate
:
payTime
,
//支付时间
totalSum
:
channelOrder
.
t
otalSum
,
//订单总额
totalSum
:
channelOrder
.
payT
otalSum
,
//订单总额
auditStatus
:
"tg"
auditStatus
:
"tg"
// payOrderNo: DataTypes.STRING, //支付凭证流水单号,如:微信支付凭证单号
// payOrderNo: DataTypes.STRING, //支付凭证流水单号,如:微信支付凭证单号
// buyerOpenId: DataTypes.STRING,//用户在支付商户appid下的唯一标识或买家在支付宝的用户id
// buyerOpenId: DataTypes.STRING,//用户在支付商户appid下的唯一标识或买家在支付宝的用户id
// passTradeNo: DataTypes.STRING,//通道的统一订单号
// passTradeNo: DataTypes.STRING,//通道的统一订单号
// buyerAliLogonId: DataTypes.STRING,//买家支付宝账号
// buyerAliLogonId: DataTypes.STRING,//买家支付宝账号
// certifyFileUrl: order.orderNo, //支付证明文件Url
// certifyFileUrl: order.orderNo, //支付证明文件Url
// wxPayOrderCode: order.orderNo,//业务微信支付订单号
// wxPayOrderCode: order.orderNo,//业务微信支付订单号
// aliPayOrderCode: order.orderNo,//业务支付宝支付订单号
// aliPayOrderCode: order.orderNo,//业务支付宝支付订单号
// busPayOrderCode: order.orderNo,//业务支付订单号
// busPayOrderCode: order.orderNo,//业务支付订单号
};
if
(
channelOrder
.
payStatus
==
'yfk'
||
channelOrder
.
payStatus
==
'bfyfk'
)
{
orderReceiptVoucherObj
.
auditStatus
=
"tg"
;
}
var
orderReceiptVoucher
=
await
self
.
orderReceiptVoucherDao
.
create
(
orderReceiptVoucherObj
,
t
);
};
var
orderReceiptVoucher
=
await
this
.
orderReceiptVoucherDao
.
create
(
orderReceiptVoucherObj
,
t
);
}
}
}
}
/**
/**
...
@@ -152,117 +143,14 @@ class OrderInfoService extends ServiceBase {
...
@@ -152,117 +143,14 @@ class OrderInfoService extends ServiceBase {
if
(
verifyResult
.
status
!=
0
)
{
if
(
verifyResult
.
status
!=
0
)
{
return
verifyResult
;
return
verifyResult
;
}
}
var
orderNo
=
await
self
.
getBusUid
(
"tm"
+
pobj
.
appInfo
.
uapp_id
);
var
self
=
this
;
return
await
self
.
db
.
transaction
(
async
function
(
t
)
{
return
await
self
.
db
.
transaction
(
async
function
(
t
)
{
var
orderNo
=
await
self
.
getBusUid
(
"o"
);
var
orderNo
=
await
self
.
getBusUid
(
"tm"
+
pobj
.
appInfo
.
uapp_id
);
var
item
=
self
.
createOrder
(
pobj
,
orderNo
,
t
);
//创建订单
var
orderObj
=
{
uapp_id
:
app
.
uAppId
,
orderNo
:
orderNo
,
channelServiceNo
:
channelOrder
.
channelServiceNo
,
channelUserId
:
channelUser
.
channelUserId
,
channelOrderNo
:
channelOrder
.
channelOrderNo
,
ownerUserId
:
channelUser
.
channelUserId
,
quantity
:
channelOrder
.
quantity
,
needNo
:
channelOrder
.
needNo
,
payTime
:
channelOrder
.
payTime
,
orderPayStatus
:
channelOrder
.
payStatus
,
totalSum
:
channelOrder
.
totalSum
,
payTotalSum
:
channelOrder
.
payTotalSum
,
totalServiceCharge
:
0
,
// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense
:
0
,
// 官费总额(产品配置的官费*订单件数)
totalTaxes
:
0
,
// 税费总额(订单总额-(订单总额/(1+产品费率)))
totalProfitSum
:
0
,
// 订单毛利润总额(订单总额-官费总额)
totalDiscounts
:
0
,
// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
pfProfitSum
:
0
,
// 订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum
:
0
,
// 订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
// pfSettleProfit :DataTypes.INTEGER,// 平台结算渠道利润,0否,1是
invoiceApplyStatus
:
"00"
,
// 发票状态:00: 未申请, 10: 已申请,20:已开票
};
if
(
verifyResult
&&
verifyResult
.
code
==
1
&&
verifyResult
.
data
)
{
var
orderCostObj
=
verifyResult
.
data
;
orderObj
.
totalServiceCharge
=
orderCostObj
.
totalServiceCharge
||
0
;
orderObj
.
totalPublicExpense
=
orderCostObj
.
totalPublicExpense
||
0
;
orderObj
.
totalTaxes
=
orderCostObj
.
totalTaxes
||
0
;
orderObj
.
totalProfitSum
=
orderCostObj
.
totalProfitSum
||
0
;
orderObj
.
totalDiscounts
=
orderCostObj
.
totalDiscounts
||
0
;
orderObj
.
pfProfitSum
=
orderCostObj
.
pfProfitSum
||
0
;
orderObj
.
channelProfitSum
=
orderCostObj
.
channelProfitSum
||
0
;
}
var
order
=
await
self
.
dao
.
create
(
orderObj
,
t
);
//创建订单
//var orderProductNo = await self.getBusUid("op");
if
(
productItem
)
{
var
orderProductObj
=
{
uapp_id
:
app
.
uAppId
,
sourceOrderNo
:
order
.
orderNo
,
// 来源单号
productType_id
:
productItem
.
productType_id
,
//产品类型Id
productOneType_id
:
productItem
.
productOneType_id
,
//产品大类Id
itemCode
:
productItem
.
itemCode
,
//产品编码
itemName
:
productItem
.
itemName
,
//产品名称
channelItemCode
:
productItem
.
channelItemCode
,
// 渠道产品编码
channelItemName
:
productItem
.
channelItemName
,
// 渠道产品名称
serviceItemCode
:
productItem
.
serviceItemCode
,
// 服务商产品编码
picUrl
:
productItem
.
picUrl
,
// 产品图片地址
proPrice
:
productItem
.
proPrice
,
// 产品价格
quantity
:
channelOrder
.
quantity
,
// 订单数量(即产品的倍数,默认值为1)
opPayType
:
"00"
,
// 操作付款类型:00: 创建订单, 10: 补单
serviceItemSnapshot
:
JSON
.
stringify
(
productItem
),
//产品快照
};
var
orderProduct
=
await
self
.
orderProductDao
.
create
(
orderProductObj
,
t
);
//订单产品
}
if
(
order
.
totalSum
>
0
)
{
//支付成功
var
moneyObj
=
{
uapp_id
:
app
.
uAppId
,
sourceOrderNo
:
order
.
orderNo
,
// 来源单号
channelUserId
:
channelUser
.
channelUserId
,
ownerUserId
:
channelUser
.
channelUserId
,
accountType
:
"other"
,
//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
directionType
:
"sr"
,
//凭单类型,"sr": "收","zc": "支"
voucherDate
:
channelOrder
.
payTime
,
//凭单时间
recvAmount
:
channelOrder
.
totalSum
,
//收总额
sourceType
:
"orderinfo"
,
//来源类型 "orderinfo": "订单","expensevoucher": "费用单"
auditStatus
:
"dsh"
,
//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
};
if
(
channelOrder
.
payStatus
==
'yfk'
||
channelOrder
.
payStatus
==
'bfyfk'
)
{
moneyObj
.
auditStatus
=
"tg"
;
}
var
moneyJourney
=
await
self
.
moneyJourneyDao
.
create
(
moneyObj
,
t
);
var
orderReceiptVoucherObj
=
{
uapp_id
:
app
.
uAppId
,
sourceOrderNo
:
order
.
orderNo
,
// 来源单号
accountType
:
"other"
,
payDate
:
channelOrder
.
payTime
,
//支付时间
totalSum
:
channelOrder
.
totalSum
,
//订单总额
// payOrderNo: DataTypes.STRING, //支付凭证流水单号,如:微信支付凭证单号
// buyerOpenId: DataTypes.STRING,//用户在支付商户appid下的唯一标识或买家在支付宝的用户id
// passTradeNo: DataTypes.STRING,//通道的统一订单号
// buyerAliLogonId: DataTypes.STRING,//买家支付宝账号
// certifyFileUrl: order.orderNo, //支付证明文件Url
wxPayOrderCode
:
order
.
orderNo
,
//业务微信支付订单号
aliPayOrderCode
:
order
.
orderNo
,
//业务支付宝支付订单号
busPayOrderCode
:
order
.
orderNo
,
//业务支付订单号
auditStatus
:
"dsh"
};
if
(
channelOrder
.
payStatus
==
'yfk'
||
channelOrder
.
payStatus
==
'bfyfk'
)
{
orderReceiptVoucherObj
.
auditStatus
=
"tg"
;
}
var
orderReceiptVoucher
=
await
self
.
orderReceiptVoucherDao
.
create
(
orderReceiptVoucherObj
,
t
);
}
var
requestid
=
self
.
getUUID
();
if
(
productItem
&&
productItem
.
deliveryUrl
)
{
obj
[
"orderNo"
]
=
order
.
orderNo
;
self
.
pushData
(
requestid
,
obj
,
productItem
.
deliveryUrl
,
req
);
}
return
system
.
getResultSuccess
({
return
system
.
getResultSuccess
({
orderNo
:
order
.
orderNo
,
orderNo
:
orderNo
,
channelServiceNo
:
order
.
channelServiceNo
,
channelServiceNo
:
pobj
.
actionBody
.
channelOrder
.
channelServiceNo
||
orderNo
,
channelParams
:
obj
.
channelParams
,
channelParams
:
opobj
.
actionBody
.
channelOrder
.
channelParams
||
""
requestid
:
requestid
});
});
});
});
...
@@ -276,143 +164,14 @@ class OrderInfoService extends ServiceBase {
...
@@ -276,143 +164,14 @@ class OrderInfoService extends ServiceBase {
if
(
verifyResult
.
status
!=
0
)
{
if
(
verifyResult
.
status
!=
0
)
{
return
verifyResult
;
return
verifyResult
;
}
}
var
orderNo
=
await
self
.
getBusUid
(
"o"
+
pobj
.
appInfo
.
uapp_id
);
var
self
=
this
;
var
params
=
{
uapp_id
:
pobj
.
appInfo
.
uapp_id
,
//int(11) //
orderNo
:
,
//varchar(64) //订单号
channelServiceNo
:
,
//varchar(64) //渠道服务单号
channelOrderNo
:
,
//varchar(1024) //渠道订单号列表,多个以,隔开
channelUserId
:
,
//varchar(64) //
ownerUserId
:
,
//varchar(20) //
needNo
:
,
//varchar(64) //需求单号
needNoOrderNo
:
,
//varchar(64) //需求订单号
payTime
:
,
//datetime //
quantity
:
,
//int(11) //项目订单数量(即服务项目的倍数,默认值为1)
serviceQuantity
:
,
//int(11) //项目订单交付数量(即与项目订单数量相对应)
orderPayStatusName
:
,
//varchar(50) //
orderPayStatus
:
,
//enum //订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
totalSum
:
,
//decimal(12,2) //订单总额(产品价格×优惠费率×订单件数)
payTotalSum
:
,
//decimal(12,2) //
refundSum
:
,
//decimal(12,2) //订单总额(产品价格×优惠费率×订单件数)
totalServiceCharge
:
,
//decimal(12,2) //服务费总额(产品配置的服务费*订单件数)
totalPublicExpense
:
,
//decimal(12,2) //官费总额(产品配置的官费*订单件数)
totalProfitSum
:
,
//decimal(12,2) //订单毛利润总额(订单总额-官费总额)
totalDiscounts
:
,
//decimal(12,2) //优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)暂时没有用到
pfProfitSum
:
,
//decimal(12,2) //订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum
:
,
//decimal(12,2) //订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
pfSettleProfit
:
,
//int(11) //平台结算渠道利润,0否,1是
invoiceApplyStatus
:
,
//varchar(10) //发票状态:00: 未申请, 10: 已申请,20:已开票
notes
:
,
//varchar(255) //
opNotes
:
,
//varchar(255) //操作备注
created_at
:
,
//datetime //
updated_at
:
,
//datetime //
deleted_at
:
,
//datetime //
version
:
,
//int(11) //
};
return
await
self
.
db
.
transaction
(
async
function
(
t
)
{
return
await
self
.
db
.
transaction
(
async
function
(
t
)
{
var
orderNo
=
await
self
.
getBusUid
(
"o"
);
var
orderNo
=
await
self
.
getBusUid
(
"ot"
+
pobj
.
appInfo
.
uapp_id
);
//创建订单
var
item
=
self
.
createOrder
(
pobj
,
orderNo
,
t
);
var
orderObj
=
{
uapp_id
:
app
.
uAppId
,
orderNo
:
orderNo
,
channelServiceNo
:
channelOrder
.
channelServiceNo
,
channelUserId
:
channelUser
.
channelUserId
,
channelOrderNo
:
channelOrder
.
channelOrderNo
,
ownerUserId
:
channelUser
.
channelUserId
,
quantity
:
channelOrder
.
quantity
,
needNo
:
channelOrder
.
needNo
,
payTime
:
channelOrder
.
payTime
,
orderPayStatus
:
channelOrder
.
payStatus
,
totalSum
:
channelOrder
.
totalSum
,
payTotalSum
:
channelOrder
.
payTotalSum
,
totalServiceCharge
:
0
,
// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense
:
0
,
// 官费总额(产品配置的官费*订单件数)
totalTaxes
:
0
,
// 税费总额(订单总额-(订单总额/(1+产品费率)))
totalProfitSum
:
0
,
// 订单毛利润总额(订单总额-官费总额)
totalDiscounts
:
0
,
// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
pfProfitSum
:
0
,
// 订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum
:
0
,
// 订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
// pfSettleProfit :DataTypes.INTEGER,// 平台结算渠道利润,0否,1是
invoiceApplyStatus
:
"00"
,
// 发票状态:00: 未申请, 10: 已申请,20:已开票
};
if
(
verifyResult
&&
verifyResult
.
code
==
1
&&
verifyResult
.
data
)
{
var
orderCostObj
=
verifyResult
.
data
;
orderObj
.
totalServiceCharge
=
orderCostObj
.
totalServiceCharge
||
0
;
orderObj
.
totalPublicExpense
=
orderCostObj
.
totalPublicExpense
||
0
;
orderObj
.
totalTaxes
=
orderCostObj
.
totalTaxes
||
0
;
orderObj
.
totalProfitSum
=
orderCostObj
.
totalProfitSum
||
0
;
orderObj
.
totalDiscounts
=
orderCostObj
.
totalDiscounts
||
0
;
orderObj
.
pfProfitSum
=
orderCostObj
.
pfProfitSum
||
0
;
orderObj
.
channelProfitSum
=
orderCostObj
.
channelProfitSum
||
0
;
}
var
order
=
await
self
.
dao
.
create
(
orderObj
,
t
);
//创建订单
//var orderProductNo = await self.getBusUid("op");
if
(
productItem
)
{
var
orderProductObj
=
{
uapp_id
:
app
.
uAppId
,
sourceOrderNo
:
order
.
orderNo
,
// 来源单号
productType_id
:
productItem
.
productType_id
,
//产品类型Id
productOneType_id
:
productItem
.
productOneType_id
,
//产品大类Id
itemCode
:
productItem
.
itemCode
,
//产品编码
itemName
:
productItem
.
itemName
,
//产品名称
channelItemCode
:
productItem
.
channelItemCode
,
// 渠道产品编码
channelItemName
:
productItem
.
channelItemName
,
// 渠道产品名称
serviceItemCode
:
productItem
.
serviceItemCode
,
// 服务商产品编码
picUrl
:
productItem
.
picUrl
,
// 产品图片地址
proPrice
:
productItem
.
proPrice
,
// 产品价格
quantity
:
channelOrder
.
quantity
,
// 订单数量(即产品的倍数,默认值为1)
opPayType
:
"00"
,
// 操作付款类型:00: 创建订单, 10: 补单
serviceItemSnapshot
:
JSON
.
stringify
(
productItem
),
//产品快照
};
var
orderProduct
=
await
self
.
orderProductDao
.
create
(
orderProductObj
,
t
);
//订单产品
}
if
(
order
.
totalSum
>
0
)
{
//支付成功
var
moneyObj
=
{
uapp_id
:
app
.
uAppId
,
sourceOrderNo
:
order
.
orderNo
,
// 来源单号
channelUserId
:
channelUser
.
channelUserId
,
ownerUserId
:
channelUser
.
channelUserId
,
accountType
:
"other"
,
//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
directionType
:
"sr"
,
//凭单类型,"sr": "收","zc": "支"
voucherDate
:
channelOrder
.
payTime
,
//凭单时间
recvAmount
:
channelOrder
.
totalSum
,
//收总额
sourceType
:
"orderinfo"
,
//来源类型 "orderinfo": "订单","expensevoucher": "费用单"
auditStatus
:
"dsh"
,
//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
};
if
(
channelOrder
.
payStatus
==
'yfk'
||
channelOrder
.
payStatus
==
'bfyfk'
)
{
moneyObj
.
auditStatus
=
"tg"
;
}
var
moneyJourney
=
await
self
.
moneyJourneyDao
.
create
(
moneyObj
,
t
);
var
orderReceiptVoucherObj
=
{
uapp_id
:
app
.
uAppId
,
sourceOrderNo
:
order
.
orderNo
,
// 来源单号
accountType
:
"other"
,
payDate
:
channelOrder
.
payTime
,
//支付时间
totalSum
:
channelOrder
.
totalSum
,
//订单总额
// payOrderNo: DataTypes.STRING, //支付凭证流水单号,如:微信支付凭证单号
// buyerOpenId: DataTypes.STRING,//用户在支付商户appid下的唯一标识或买家在支付宝的用户id
// passTradeNo: DataTypes.STRING,//通道的统一订单号
// buyerAliLogonId: DataTypes.STRING,//买家支付宝账号
// certifyFileUrl: order.orderNo, //支付证明文件Url
wxPayOrderCode
:
order
.
orderNo
,
//业务微信支付订单号
aliPayOrderCode
:
order
.
orderNo
,
//业务支付宝支付订单号
busPayOrderCode
:
order
.
orderNo
,
//业务支付订单号
auditStatus
:
"dsh"
};
if
(
channelOrder
.
payStatus
==
'yfk'
||
channelOrder
.
payStatus
==
'bfyfk'
)
{
orderReceiptVoucherObj
.
auditStatus
=
"tg"
;
}
var
orderReceiptVoucher
=
await
self
.
orderReceiptVoucherDao
.
create
(
orderReceiptVoucherObj
,
t
);
}
var
requestid
=
self
.
getUUID
();
if
(
productItem
&&
productItem
.
deliveryUrl
)
{
obj
[
"orderNo"
]
=
order
.
orderNo
;
self
.
pushData
(
requestid
,
obj
,
productItem
.
deliveryUrl
,
req
);
}
return
system
.
getResultSuccess
({
return
system
.
getResultSuccess
({
orderNo
:
order
.
orderNo
,
orderNo
:
orderNo
,
channelServiceNo
:
order
.
channelServiceNo
,
channelServiceNo
:
pobj
.
actionBody
.
channelOrder
.
channelServiceNo
||
orderNo
,
channelParams
:
obj
.
channelParams
,
channelParams
:
opobj
.
actionBody
.
channelOrder
.
channelParams
||
""
requestid
:
requestid
});
});
});
});
...
@@ -431,135 +190,103 @@ class OrderInfoService extends ServiceBase {
...
@@ -431,135 +190,103 @@ class OrderInfoService extends ServiceBase {
/**
/**
* 数据推送
* 数据推送
*/
*/
async
pushData
(
requestid
,
params
,
url
,
req
)
{
//
async pushData(requestid, params, url, req) {
var
rc
=
system
.
getObject
(
"util.execClient"
);
//
var rc = system.getObject("util.execClient");
var
obj
=
params
;
//
var obj = params;
var
rtn
=
null
;
//
var rtn = null;
try
{
//
try {
rtn
=
await
rc
.
execPushDataPost
(
obj
,
url
,
req
.
headers
[
"token"
],
req
.
headers
[
"request-id"
]);
//
rtn = await rc.execPushDataPost(obj, url, req.headers["token"], req.headers["request-id"]);
var
returnType
=
"0"
;
//
var returnType = "0";
if
(
rtn
.
stdout
)
{
//
if (rtn.stdout) {
var
j
=
JSON
.
parse
(
rtn
.
stdout
);
//
var j = JSON.parse(rtn.stdout);
if
(
j
&&
j
.
status
==
0
)
{
//
if (j && j.status == 0) {
returnType
=
"1"
;
//
returnType = "1";
}
//
}
}
//
}
this
.
pushlogSve
.
createDb
({
//
this.pushlogSve.createDb({
appid
:
req
.
app
.
id
,
//
appid: req.app.id,
requestId
:
requestid
,
//
requestId: requestid,
op
:
url
,
//
op: url,
content
:
JSON
.
stringify
(
obj
),
//
content: JSON.stringify(obj),
resultInfo
:
JSON
.
stringify
(
rtn
),
//
resultInfo: JSON.stringify(rtn),
clientIp
:
req
.
clientIp
,
//
clientIp: req.clientIp,
returnType
:
returnType
,
//
returnType: returnType,
agent
:
req
.
uagent
,
//
agent: req.uagent,
opTitle
:
"数据推送-创建订单"
,
//
opTitle: "数据推送-创建订单",
});
//
});
}
catch
(
e
)
{
//
} catch (e) {
this
.
pushlogSve
.
createDb
({
//
this.pushlogSve.createDb({
appid
:
req
.
app
.
id
,
//
appid: req.app.id,
requestId
:
requestid
,
//
requestId: requestid,
op
:
url
,
//
op: url,
content
:
JSON
.
stringify
(
obj
),
//
content: JSON.stringify(obj),
resultInfo
:
JSON
.
stringify
(
e
.
stack
),
//
resultInfo: JSON.stringify(e.stack),
clientIp
:
req
.
clientIp
,
//
clientIp: req.clientIp,
returnType
:
'0'
,
//
returnType: '0',
agent
:
req
.
uagent
,
//
agent: req.uagent,
opTitle
:
"数据推送-创建订单"
,
//
opTitle: "数据推送-创建订单",
});
//
});
}
//
}
}
//
}
async
findAndCountAll
(
obj
,
req
)
{
//
async findAndCountAll(obj, req) {
var
app
=
req
.
app
;
//
var app = req.app;
if
(
!
app
||
!
app
.
uAppId
)
{
//
if (!app || !app.uAppId) {
return
system
.
getResult
(
null
,
"渠道信息有误"
);
//
return system.getResult(null, "渠道信息有误");
}
//
}
obj
[
"search"
][
"uapp_id"
]
=
app
.
uAppId
;
//
obj["search"]["uapp_id"] = app.uAppId;
const
result
=
await
this
.
dao
.
findAndCountAll
(
obj
);
//
const result = await this.dao.findAndCountAll(obj);
return
system
.
getResultSuccess
(
result
);
//
return system.getResultSuccess(result);
}
//
}
async
getOrderDetailByOrderNo
(
obj
,
req
)
{
//
async getOrderDetailByOrderNo(obj, req) {
var
orderNo
=
obj
.
orderNo
;
//
var orderNo = obj.orderNo;
if
(
!
orderNo
)
{
//
if (!orderNo) {
return
system
.
getResult
(
null
,
"订单编号不能为空"
);
//
return system.getResult(null, "订单编号不能为空");
}
//
}
var
app
=
req
.
app
;
//
var app = req.app;
if
(
!
app
||
!
app
.
uAppId
)
{
//
if (!app || !app.uAppId) {
return
system
.
getResult
(
null
,
"渠道信息有误"
);
//
return system.getResult(null, "渠道信息有误");
}
//
}
var
order
=
await
this
.
dao
.
model
.
findOne
({
//
var order = await this.dao.model.findOne({
where
:
{
orderNo
:
orderNo
,
uapp_id
:
app
.
uAppId
},
//
where: { orderNo: orderNo, uapp_id: app.uAppId },
attributes
:
[
"orderNo"
,
"channelServiceNo"
,
"channelOrderNo"
,
"channelUserId"
,
"ownerUserId"
,
"needNo"
,
//
attributes: ["orderNo", "channelServiceNo", "channelOrderNo", "channelUserId", "ownerUserId", "needNo",
"payTime"
,
"quantity"
,
"serviceQuantity"
,
"orderPayStatus"
,
"orderPayStatusName"
,
"totalSum"
,
"payTotalSum"
,
//
"payTime", "quantity", "serviceQuantity", "orderPayStatus", "orderPayStatusName", "totalSum", "payTotalSum",
"refundSum"
,
"created_at"
,
"opNotes"
,
"notes"
//
"refundSum", "created_at", "opNotes", "notes"
],
//
],
raw
:
true
//
raw: true
});
//
});
if
(
order
&&
order
.
orderNo
)
{
//
if (order && order.orderNo) {
var
orderproducts
=
await
this
.
orderProductDao
.
model
.
findAll
({
//
var orderproducts = await this.orderProductDao.model.findAll({
where
:
{
sourceOrderNo
:
order
.
orderNo
},
//
where: { sourceOrderNo: order.orderNo },
attributes
:
[
"sourceOrderNo"
,
"itemCode"
,
"itemName"
,
"channelItemCode"
,
"channelItemName"
,
//
attributes: ["sourceOrderNo", "itemCode", "itemName", "channelItemCode", "channelItemName",
"serviceItemCode"
,
"picUrl"
,
"proPrice"
,
"quantity"
,
"opPayType"
,
"serviceItemSnapshot"
,
//
"serviceItemCode", "picUrl", "proPrice", "quantity", "opPayType", "serviceItemSnapshot",
"created_at"
//
"created_at"
],
//
],
raw
:
true
//
raw: true
});
//
});
order
[
"orderproducts"
]
=
orderproducts
;
//
order["orderproducts"] = orderproducts;
var
receptvouchers
=
await
this
.
orderReceiptVoucherDao
.
model
.
findAll
({
//
var receptvouchers = await this.orderReceiptVoucherDao.model.findAll({
where
:
{
sourceOrderNo
:
order
.
orderNo
},
//
where: { sourceOrderNo: order.orderNo },
attributes
:
[
//
attributes: [
"sourceOrderNo"
,
"accountType"
,
"accountTypeName"
,
"payDate"
,
"totalSum"
,
"payOrderNo"
,
"buyerOpenId"
,
//
"sourceOrderNo", "accountType", "accountTypeName", "payDate", "totalSum", "payOrderNo", "buyerOpenId",
"passTradeNo"
,
"buyerAliLogonId"
,
"certifyFileUrl"
,
"wxPayOrderCode"
,
"aliPayOrderCode"
,
"busPayOrderCode"
,
//
"passTradeNo", "buyerAliLogonId", "certifyFileUrl", "wxPayOrderCode", "aliPayOrderCode", "busPayOrderCode",
"auditStatusName"
,
"auditStatus"
//
"auditStatusName", "auditStatus"
],
//
],
raw
:
true
//
raw: true
});
//
});
order
[
"receptvouchers"
]
=
receptvouchers
;
//
order["receptvouchers"] = receptvouchers;
var
refundvouchers
=
await
this
.
orderRefundVoucherDao
.
model
.
findAll
({
//
var refundvouchers = await this.orderRefundVoucherDao.model.findAll({
where
:
{
sourceOrderNo
:
order
.
orderNo
},
//
where: { sourceOrderNo: order.orderNo },
attributes
:
[
//
attributes: [
"busPayOrderCode"
,
//
"busPayOrderCode",
"sourceOrderNo"
,
"accountType"
,
"accountTypeName"
,
"payDate"
,
"totalSum"
,
"payOrderNo"
,
"buyerOpenId"
,
//
"sourceOrderNo", "accountType", "accountTypeName", "payDate", "totalSum", "payOrderNo", "buyerOpenId",
"passTradeNo"
,
"certifyFileUrl"
,
"auditStatusName"
,
"auditStatus"
//
"passTradeNo", "certifyFileUrl", "auditStatusName", "auditStatus"
],
//
],
raw
:
true
//
raw: true
});
//
});
order
[
"refundvouchers"
]
=
refundvouchers
;
//
order["refundvouchers"] = refundvouchers;
}
//
}
return
system
.
getResultSuccess
(
order
);
//
return system.getResultSuccess(order);
}
//
}
}
}
module
.
exports
=
OrderInfoService
;
module
.
exports
=
OrderInfoService
;
// var task = new OrderInfoService();
\ No newline at end of file
// var obj={
// "itemCode": "1406046",
// "channelParams": {},
// "channelUser": {
// "channelUserId": "z120315554031547444",
// "channelUserName": "testUser",
// "channelUserMoblie": "15010929368",
// "nickname": "",
// "orgName": "",
// "orgPath": ""
// },
// "channelOrder": {
// "channelServiceNo": "z1203155540315474427",
// "channelOrderNo": "z12031,z1203d12",
// "needNo": "z1203155540315474427",
// "quantity": 1,
// "totalSum":699,
// "payTotalSum":699,
// "payStatus": "yfk",
// "payTime": "2019-09-11 10:23:21"
// }
// };
// var req={
// app:{ id: 2,uAppId:123},
// user:{ id: 6, app_id: 2, nickname: "测试用户",channelUserId:"testUserId01" }
// };
// task.createOrder(obj,req).then(d=>{
// console.log("d");
// console.log(d);
// })
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