Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
8cf94c51
Commit
8cf94c51
authored
Jun 18, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增强制取消接口
parent
1870eeaf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
315 additions
and
5 deletions
+315
-5
OrderModule.cs
Mall.Module.Product/OrderModule.cs
+234
-4
UserModule.cs
Mall.Module.User/UserModule.cs
+1
-1
OrderController.cs
Mall.WebApi/Controllers/Product/OrderController.cs
+80
-0
No files found.
Mall.Module.Product/OrderModule.cs
View file @
8cf94c51
...
@@ -4838,7 +4838,10 @@ namespace Mall.Module.Product
...
@@ -4838,7 +4838,10 @@ namespace Mall.Module.Product
bool
flag
=
goods_OrderAfterSaleRepository
.
Update
(
keyValues
,
wheres
);
bool
flag
=
goods_OrderAfterSaleRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
if
(
flag
)
{
{
OrderRefundFinanceModule
(
model
,
tenantId
,
mallBaseId
);
if
(
tenantId
==
1
)
{
OrderRefundFinanceModule
(
model
,
tenantId
,
mallBaseId
);
}
goods_OrderAfterSaleLogRepository
.
Insert
(
new
RB_Goods_OrderAfterSaleLog
()
goods_OrderAfterSaleLogRepository
.
Insert
(
new
RB_Goods_OrderAfterSaleLog
()
{
{
Id
=
0
,
Id
=
0
,
...
@@ -5553,7 +5556,7 @@ namespace Mall.Module.Product
...
@@ -5553,7 +5556,7 @@ namespace Mall.Module.Product
});
});
}
}
goods_OrderRepository
.
DBSession
.
Commit
();
goods_OrderRepository
.
DBSession
.
Commit
();
if
(
flag
&&
type
==
1
)
{
if
(
flag
&&
type
==
1
&&
tenantId
==
1
)
{
//同意 创建财务单据
//同意 创建财务单据
OrderRefundFinanceModule
(
omodel
);
OrderRefundFinanceModule
(
omodel
);
}
}
...
@@ -5567,12 +5570,231 @@ namespace Mall.Module.Product
...
@@ -5567,12 +5570,231 @@ namespace Mall.Module.Product
}
}
}
}
/// <summary>
/// 后台强制取消订单
/// </summary>
/// <param name="omodel"></param>
/// <param name="type"></param>
/// <param name="remark"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
bool
SetOrderForcedToCancel
(
RB_Goods_Order_Extend
omodel
,
string
RefundOrderNo
,
int
tenantId
,
int
mallBaseId
)
{
var
trans
=
goods_OrderRepository
.
DbTransaction
;
try
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
};
keyValues
.
Add
(
nameof
(
RB_Goods_Order
.
OrderStatus
),
OrderStatusEnum
.
Cancel
);
keyValues
.
Add
(
nameof
(
RB_Goods_Order
.
RefundOrderNo
),
RefundOrderNo
);
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods_Order
.
OrderId
),
FiledValue
=
omodel
.
OrderId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods_Order
.
TenantId
),
FiledValue
=
tenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods_Order
.
MallBaseId
),
FiledValue
=
mallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
goods_OrderRepository
.
Update
(
keyValues
,
wheres
,
trans
);
if
(
flag
)
{
#
region
回滚
int
TotalIntegralNumber
=
0
;
//回滚商品库存
var
detailList
=
goods_OrderDetailRepository
.
GetOrderDetailList
(
new
RB_Goods_OrderDetail_Extend
()
{
OrderId
=
omodel
.
OrderId
,
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
});
if
(
detailList
.
Any
())
{
string
goodsIds
=
string
.
Join
(
","
,
detailList
.
Select
(
x
=>
x
.
GoodsId
??
0
).
Distinct
());
var
goodsList
=
goodsRepository
.
GetList
(
new
RB_Goods_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
});
var
speciPList
=
goods_SpecificationPriceRepository
.
GetList
(
new
RB_Goods_SpecificationPrice_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
});
foreach
(
var
item
in
detailList
)
{
var
gmodel
=
goodsList
.
Where
(
x
=>
x
.
Id
==
item
.
GoodsId
).
FirstOrDefault
();
if
(
gmodel
==
null
)
{
continue
;
}
if
(
string
.
IsNullOrEmpty
(
item
.
SpecificationSort
))
{
if
(
gmodel
.
IsCustomSpecification
==
1
)
{
continue
;
}
}
else
{
if
(
gmodel
.
IsCustomSpecification
!=
1
)
{
continue
;
}
var
speciPModel
=
speciPList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
).
FirstOrDefault
();
if
(
speciPModel
==
null
)
{
continue
;
}
//更新商品规格表库存 + 商品表总库存
Dictionary
<
string
,
object
>
keyValues2
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods_SpecificationPrice
.
InventoryNum
),
(
speciPModel
.
InventoryNum
??
0
)+(
item
.
Number
??
0
)}
};
List
<
WhereHelper
>
wheres2
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods_SpecificationPrice
.
Id
),
FiledValue
=
speciPModel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
goods_SpecificationPriceRepository
.
Update
(
keyValues2
,
wheres2
,
trans
);
}
//更新商品表库存
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods
.
InventoryNum
),
(
gmodel
.
InventoryNum
??
0
)+(
item
.
Number
??
0
)}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods
.
Id
),
FiledValue
=
gmodel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
goodsRepository
.
Update
(
keyValues1
,
wheres1
,
trans
);
goods_LogRepository
.
Insert
(
new
RB_Goods_Log
()
{
Id
=
0
,
Type
=
2
,
SourceId
=
item
.
GoodsId
,
Content
=
$"后台强制取消订单
{
omodel
.
OrderId
}
,还原商品库存:"
+
item
.
Number
,
CreateDate
=
DateTime
.
Now
,
MallBaseId
=
mallBaseId
,
TenantId
=
tenantId
});
if
(
item
.
IntegralNumber
>
0
)
{
TotalIntegralNumber
+=
(
item
.
IntegralNumber
??
0
);
}
}
}
var
umodel
=
member_UserRepository
.
GetEntity
(
omodel
.
UserId
);
//积分抵扣回滚
if
(
TotalIntegralNumber
>
0
)
{
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_User_Extend
.
Integral
),
umodel
.
Integral
+
TotalIntegralNumber
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_User_Extend
.
Id
),
FiledValue
=
umodel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag2
=
member_UserRepository
.
Update
(
keyValues1
,
wheres1
,
trans
);
if
(
flag2
)
{
member_IntegralRepository
.
Insert
(
new
Model
.
Entity
.
User
.
RB_Member_Integral
()
{
Id
=
0
,
CreateDate
=
DateTime
.
Now
,
Description
=
"订单取消返回积分抵扣,订单号:"
+
omodel
.
OrderNo
,
Image
=
0
,
Integral
=
TotalIntegralNumber
,
MallBaseId
=
omodel
.
MallBaseId
,
PlatformType
=
omodel
.
OrderSource
,
Remarks
=
""
,
TenantId
=
omodel
.
TenantId
,
Type
=
Common
.
Enum
.
MarketingCenter
.
RecordTypeEnum
.
Income
,
UserId
=
omodel
.
UserId
,
OrderId
=
omodel
.
OrderId
},
trans
);
}
}
//优惠券回滚
if
(!
string
.
IsNullOrEmpty
(
omodel
.
CouponsIds
))
{
var
cList
=
member_CouponRepository
.
GetList
(
new
RB_Member_DiscountCoupon_Extend
()
{
UseState
=
1
,
Ids
=
omodel
.
CouponsIds
,
UserId
=
omodel
.
UserId
,
TenantId
=
omodel
.
TenantId
,
MallBaseId
=
omodel
.
MallBaseId
});
foreach
(
var
item
in
cList
)
{
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
UseState
),
0
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_DiscountCoupon_Extend
.
Id
),
FiledValue
=
item
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
member_CouponRepository
.
Update
(
keyValues1
,
wheres1
,
trans
);
}
}
//余额支付回滚
string
goodsName
=
detailList
.
FirstOrDefault
().
GoodsName
;
if
(
detailList
.
Count
>
1
)
{
if
(
goodsName
.
Length
>
12
)
{
goodsName
=
goodsName
.
Substring
(
0
,
12
)
+
".."
;
}
goodsName
+=
"等"
+
detailList
.
Count
+
"件商品"
;
}
else
{
if
(
goodsName
.
Length
>
18
)
{
goodsName
=
goodsName
.
Substring
(
0
,
18
)
+
".."
;
}
}
new
MiniProgramMsgModule
().
SendOrderCancelMsg
(
tenantId
,
mallBaseId
,
umodel
.
OpenId
,
omodel
.
OrderNo
,
omodel
.
CancelRemark
??
""
,
(
omodel
.
Income
??
0
).
ToString
(),
goodsName
);
#
endregion
//记录日志
string
Content
=
$"后台强制取消订单"
;
goods_LogRepository
.
Insert
(
new
RB_Goods_Log
()
{
Content
=
Content
,
CreateDate
=
DateTime
.
Now
,
Id
=
0
,
MallBaseId
=
mallBaseId
,
SourceId
=
omodel
.
OrderId
,
TenantId
=
tenantId
,
Type
=
1
});
}
goods_OrderRepository
.
DBSession
.
Commit
();
if
(
flag
&&
tenantId
==
1
)
{
//同意 创建财务单据
OrderRefundFinanceModule
(
omodel
,
true
);
}
return
flag
;
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
""
);
goods_OrderRepository
.
DBSession
.
Rollback
();
return
false
;
}
}
/// <summary>
/// <summary>
/// 生成退款单据
/// 生成退款单据
/// </summary>
/// </summary>
/// <param name="omodel"></param>
/// <param name="omodel"></param>
/// <returns></returns>
/// <returns></returns>
public
bool
OrderRefundFinanceModule
(
RB_Goods_Order_Extend
omodel
)
public
bool
OrderRefundFinanceModule
(
RB_Goods_Order_Extend
omodel
,
bool
IsForcedToCancel
=
false
)
{
{
var
flag
=
false
;
var
flag
=
false
;
try
try
...
@@ -5600,6 +5822,10 @@ namespace Mall.Module.Product
...
@@ -5600,6 +5822,10 @@ namespace Mall.Module.Product
};
};
item
.
IsPublic
=
8
;
//默认原路退款
item
.
IsPublic
=
8
;
//默认原路退款
string
Remark
=
"名称:"
+
umodel
.
Name
+
"("
+
umodel
.
Id
+
")"
+
" "
+
System
.
DateTime
.
Now
.
ToString
(
"yyyy年MM月dd日"
)
+
" 自动生成财务单据"
;
if
(
IsForcedToCancel
)
{
Remark
=
"后台强制取消该订单,用户名称:"
+
umodel
.
Name
+
"("
+
umodel
.
Id
+
")"
+
" "
+
System
.
DateTime
.
Now
.
ToString
(
"yyyy年MM月dd日"
)
+
" 自动生成财务单据"
;
}
var
financeObj
=
new
var
financeObj
=
new
{
{
CreateBy
=
Config
.
NetworkDirector
,
CreateBy
=
Config
.
NetworkDirector
,
...
@@ -5614,7 +5840,7 @@ namespace Mall.Module.Product
...
@@ -5614,7 +5840,7 @@ namespace Mall.Module.Product
OrderSource
=
16
,
OrderSource
=
16
,
OtherType
=
14
,
OtherType
=
14
,
ReFinanceId
=
omodel
.
OrderId
,
ReFinanceId
=
omodel
.
OrderId
,
Remark
=
"名称:"
+
umodel
.
Name
+
"("
+
umodel
.
Id
+
")"
+
" "
+
System
.
DateTime
.
Now
.
ToString
(
"yyyy年MM月dd日"
)
+
"自动生成财务单据"
,
Remark
=
Remark
,
detailList
detailList
};
};
string
sign
=
EncryptionHelper
.
AesEncrypt
(
JsonHelper
.
Serialize
(
financeObj
),
Config
.
FinanceKey
);
string
sign
=
EncryptionHelper
.
AesEncrypt
(
JsonHelper
.
Serialize
(
financeObj
),
Config
.
FinanceKey
);
...
@@ -5926,6 +6152,10 @@ namespace Mall.Module.Product
...
@@ -5926,6 +6152,10 @@ namespace Mall.Module.Product
}
}
}
}
}
}
else
if
(
type
==
3
)
{
//强制取消
}
}
}
return
flag
;
return
flag
;
}
}
...
...
Mall.Module.User/UserModule.cs
View file @
8cf94c51
...
@@ -1919,7 +1919,7 @@ namespace Mall.Module.User
...
@@ -1919,7 +1919,7 @@ namespace Mall.Module.User
}
}
};
};
bool
flag
=
distributor_RemitRepository
.
Update
(
keyValues
,
wheres
);
bool
flag
=
distributor_RemitRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
if
(
flag
&&
uid
==
"1"
)
{
{
//提现审核通过 自动生成财务单据
//提现审核通过 自动生成财务单据
OrderIncomeFinanceModule
(
remitId
,
Convert
.
ToInt32
(
uid
),
mallBaseId
,
remark
);
OrderIncomeFinanceModule
(
remitId
,
Convert
.
ToInt32
(
uid
),
mallBaseId
,
remark
);
...
...
Mall.WebApi/Controllers/Product/OrderController.cs
View file @
8cf94c51
...
@@ -538,6 +538,86 @@ namespace Mall.WebApi.Controllers.MallBase
...
@@ -538,6 +538,86 @@ namespace Mall.WebApi.Controllers.MallBase
}
}
}
}
/// <summary>
/// 后台订单强制取消
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetOrderForcedToCancel
()
{
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
OrderId
=
parms
.
GetInt
(
"OrderId"
,
0
);
//string Remark = parms.GetStringValue("Remark");
if
(
OrderId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
var
omodel
=
orderModule
.
GetOrderInfo
(
OrderId
);
if
(
omodel
==
null
)
{
return
ApiResult
.
Failed
(
"订单不存在"
);
}
if
(
omodel
.
Status
==
1
)
{
return
ApiResult
.
Failed
(
"订单已删除"
);
}
if
(
omodel
.
Recycled
==
1
)
{
return
ApiResult
.
Failed
(
"订单已进入回收站无法操作"
);
}
if
(
omodel
.
OrderStatus
!=
OrderStatusEnum
.
NonPayment
&&
omodel
.
OrderStatus
!=
OrderStatusEnum
.
WaitSendGoods
)
{
return
ApiResult
.
Failed
(
"该订单已无法取消"
);
}
int
IsNormalServer
=
Convert
.
ToInt32
(
new
ConfigurationBuilder
().
Add
(
new
JsonConfigurationSource
{
Path
=
"appsettings.json"
}).
Build
().
GetSection
(
"IsNormalServer"
).
Value
);
if
(
IsNormalServer
==
1
&&
omodel
.
OrderStatus
==
OrderStatusEnum
.
WaitSendGoods
)
{
//获取小程序信息
var
mallModel
=
orderModule
.
GetMiniProgramExtend
(
req
.
MallBaseId
);
int
RefundNum
=
orderModule
.
GetOrderRefundOnlineTradeNum
(
OrderId
,
req
.
TenantId
,
req
.
MallBaseId
);
string
RefundOrderNo
=
omodel
.
OrderNo
+
(
RefundNum
+
1
);
var
pram
=
new
Common
.
Pay
.
WeChatPat
.
PayParam
()
{
TotalFee
=
Convert
.
ToInt32
((
omodel
.
Income
??
0
)
*
100
),
RefundFee
=
Convert
.
ToInt32
((
omodel
.
Income
??
0
)
*
100
),
OrderNumber
=
omodel
.
MerchantsNo
,
RefundNumber
=
RefundOrderNo
};
var
Robj
=
new
App_Code
.
PayUtil
().
Refund
(
pram
,
mallModel
,
_accessor
);
if
(
Robj
.
IsSuccess
)
{
bool
flag
=
orderModule
.
SetOrderForcedToCancel
(
omodel
,
RefundOrderNo
,
req
.
TenantId
,
req
.
MallBaseId
);
if
(
flag
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
();
}
}
else
{
LogHelper
.
Write
(
JsonConvert
.
SerializeObject
(
Robj
));
return
ApiResult
.
Failed
();
}
}
else
{
bool
flag
=
orderModule
.
SetOrderForcedToCancel
(
omodel
,
""
,
req
.
TenantId
,
req
.
MallBaseId
);
if
(
flag
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
();
}
}
}
/// <summary>
/// <summary>
/// 修改订单明细价格
/// 修改订单明细价格
/// </summary>
/// </summary>
...
...
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