mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:23:26 +08:00
【新增】小程序端确认收货增加推送【微信发货信息管理】同步确认收货功能。
This commit is contained in:
@@ -435,6 +435,11 @@ const install = (Vue, vm) => {
|
||||
//支付宝小程序手机授权(拉取手机号码)
|
||||
let loginByGetPhoneNumberForAli = (params, config = {}) => http.post('/Api/User/DecryptPhoneNumberByAli', params, { custom: { methodName: 'user.loginByGetPhoneNumberForAli', needToken: false } });
|
||||
|
||||
//查询当前订单是否接入微信发货信息管理
|
||||
let orderShippingList = (params, config = {}) => http.post('/Api/Order/OrderShippingList', params, { custom: { methodName: 'order.orderShippingList', needToken: true } });
|
||||
//根据订单编号获取当前订单的支付信息
|
||||
let getOrderPayInfo = (params, config = {}) => http.post('/Api/Order/GetOrderPayInfo', params, { custom: { methodName: 'order.getOrderPayInfo', needToken: true } });
|
||||
|
||||
// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
|
||||
vm.$u.api = {
|
||||
shopConfigV2,
|
||||
@@ -641,7 +646,10 @@ const install = (Vue, vm) => {
|
||||
submitInvoiceApply,
|
||||
|
||||
getAliPayAppAuthTokenBYCode,
|
||||
loginByGetPhoneNumberForAli
|
||||
loginByGetPhoneNumberForAli,
|
||||
|
||||
orderShippingList,
|
||||
getOrderPayInfo
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -729,34 +729,73 @@
|
||||
tackDeliery(orderId) {
|
||||
let _this = this;
|
||||
this.$common.modelShow('提示', '确认收货操作吗?', () => {
|
||||
let data = {
|
||||
id: orderId
|
||||
}
|
||||
_this.$u.api.confirmOrder(data).then(res => {
|
||||
if (res.status) {
|
||||
_this.$refs.uToast.show({
|
||||
message: '确认收货成功', type: 'success', complete: function () {
|
||||
// 更改订单列表页的订单状态
|
||||
let pages = getCurrentPages(); // 当前页
|
||||
let beforePage = pages[pages.length - 2]; // 上个页面
|
||||
if (beforePage !== undefined && beforePage.route === 'pages/member/order/index/index') {
|
||||
// #ifdef MP-WEIXIN
|
||||
beforePage.$vm.isReload = true
|
||||
// #endif
|
||||
// #ifdef APP-PLUS || APP-PLUS-NVUE
|
||||
beforePage.isReload = true
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY || MP-TOUTIAO
|
||||
_this.$db.set('orderUserShip', true, true);
|
||||
// #endif
|
||||
}
|
||||
_this.orderDetail()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_this.$u.toast(res.msg)
|
||||
// #ifdef MP-WEIXIN
|
||||
if (_this.orderInfo.paymentItem[0].paymentCode == 'wechatpay' && _this.orderInfo.paymentItem[0].status == 2) {
|
||||
let payData = {
|
||||
id: _this.orderInfo.paymentItem[0].tradeNo
|
||||
}
|
||||
})
|
||||
_this.$u.api.orderShippingList(payData).then(res => {
|
||||
if (res.status && res.data == true) {
|
||||
//拉起确认收货组件
|
||||
if (wx.openBusinessView) {
|
||||
wx.openBusinessView({
|
||||
businessType: 'weappOrderConfirm',
|
||||
extraData: {
|
||||
transaction_id: _this.orderInfo.paymentItem[0].tradeNo
|
||||
},
|
||||
success(e) {
|
||||
_this.doTackDeliery(orderId);
|
||||
},
|
||||
fail() { },
|
||||
complete() { }
|
||||
});
|
||||
} else {
|
||||
_this.$u.toast("您的微信版本过低,请升级微信");
|
||||
}
|
||||
} else {
|
||||
_this.doTackDeliery(orderId);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_this.doTackDeliery(orderId);
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef MP-WEIXIN
|
||||
_this.doTackDeliery(orderId);
|
||||
// #endif
|
||||
})
|
||||
},
|
||||
//执行确认收货.
|
||||
doTackDeliery(orderId) {
|
||||
let _this = this;
|
||||
let data = {
|
||||
id: orderId
|
||||
}
|
||||
_this.$u.api.confirmOrder(data).then(res => {
|
||||
if (res.status) {
|
||||
_this.$refs.uToast.show({
|
||||
message: '确认收货成功', type: 'success', complete: function () {
|
||||
// 更改订单列表页的订单状态
|
||||
let pages = getCurrentPages(); // 当前页
|
||||
let beforePage = pages[pages.length - 2]; // 上个页面
|
||||
if (beforePage !== undefined && beforePage.route === 'pages/member/order/index/index') {
|
||||
// #ifdef MP-WEIXIN
|
||||
beforePage.$vm.isReload = true;
|
||||
// #endif
|
||||
// #ifdef APP-PLUS || APP-PLUS-NVUE
|
||||
beforePage.isReload = true;
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY || MP-TOUTIAO
|
||||
_this.$db.set('orderUserShip', true, true);
|
||||
// #endif
|
||||
}
|
||||
_this.orderDetail()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_this.$u.toast(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 申请售后
|
||||
|
||||
@@ -172,25 +172,73 @@
|
||||
// 确认收货
|
||||
tackDelivery(index, orderIndex) {
|
||||
let _this = this;
|
||||
this.$common.modelShow('提示', '确认执行收货操作吗?', () => {
|
||||
let data = {
|
||||
id: _this.listData[orderIndex].orderId
|
||||
var orderId = _this.listData[orderIndex].orderId;
|
||||
this.$common.modelShow('提示', '确认收货操作吗?', () => {
|
||||
// #ifdef MP-WEIXIN
|
||||
let payInfoData = {
|
||||
id: orderId
|
||||
}
|
||||
_this.$u.api.confirmOrder(data).then(res => {
|
||||
if (res.status) {
|
||||
_this.$refs.uToast.show({
|
||||
message: '确认收货成功', type: 'success', complete: function () {
|
||||
if (this.tab !== 0) {
|
||||
_this.listData.splice(orderIndex, 1)
|
||||
_this.$u.api.getOrderPayInfo(payInfoData).then(resPayInfo => {
|
||||
console.log(resPayInfo);
|
||||
if (resPayInfo.status && resPayInfo.data.paymentCode == 'wechatpay' && resPayInfo.data.status == 2) {
|
||||
let payData = {
|
||||
id: resPayInfo.data.tradeNo
|
||||
}
|
||||
_this.$u.api.orderShippingList(payData).then(res => {
|
||||
if (res.status && res.data == true) {
|
||||
//拉起确认收货组件
|
||||
if (wx.openBusinessView) {
|
||||
wx.openBusinessView({
|
||||
businessType: 'weappOrderConfirm',
|
||||
extraData: {
|
||||
transaction_id: resPayInfo.data.tradeNo
|
||||
},
|
||||
success(e) {
|
||||
_this.doTackDeliery(orderIndex, orderId);
|
||||
},
|
||||
fail() { },
|
||||
complete() { }
|
||||
});
|
||||
} else {
|
||||
_this.getOrders();
|
||||
_this.$u.toast("您的微信版本过低,请升级微信");
|
||||
}
|
||||
} else {
|
||||
_this.doTackDeliery(orderIndex, orderId);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_this.$u.toast(res.msg)
|
||||
} else if (resPayInfo.status && resPayInfo.data.paymentCode != 'wechatpay' && resPayInfo.data.status == 2) {
|
||||
_this.doTackDeliery(orderIndex, orderId);
|
||||
}
|
||||
else {
|
||||
_this.$u.toast(resPayInfo.msg)
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
_this.doTackDeliery(orderIndex, orderId);
|
||||
// #endif
|
||||
})
|
||||
},
|
||||
//执行确认收货.
|
||||
doTackDeliery(orderIndex, orderId) {
|
||||
let _this = this;
|
||||
let data = {
|
||||
id: orderId
|
||||
}
|
||||
_this.$u.api.confirmOrder(data).then(res => {
|
||||
if (res.status) {
|
||||
_this.$refs.uToast.show({
|
||||
message: '确认收货成功', type: 'success', complete: function () {
|
||||
if (this.tab !== 0) {
|
||||
_this.listData.splice(orderIndex, 1)
|
||||
} else {
|
||||
_this.getOrders();
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_this.$u.toast(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 订单状态统一在这处理
|
||||
|
||||
@@ -13,6 +13,7 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Auth.HttpContextUser;
|
||||
using CoreCms.Net.Caching.AccressToken;
|
||||
using CoreCms.Net.Caching.AutoMate.RedisCache;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IServices;
|
||||
@@ -24,9 +25,13 @@ using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.WeChat.Service.Enums;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
@@ -51,7 +56,9 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
private readonly ICoreCmsUserServices _userServices;
|
||||
private readonly ICoreCmsClerkServices _clerkServices;
|
||||
private readonly ICoreCmsInvoiceServices _invoiceServices;
|
||||
|
||||
private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
|
||||
private readonly ICoreCmsUserWeChatInfoServices _userWeChatInfoServices;
|
||||
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
@@ -61,7 +68,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
, ICoreCmsBillAftersalesServices aftersalesServices
|
||||
, ICoreCmsSettingServices settingServices
|
||||
, ICoreCmsAreaServices areaServices
|
||||
, ICoreCmsBillReshipServices reshipServices, ICoreCmsShipServices shipServices, ICoreCmsLogisticsServices logisticsServices, ICoreCmsOrderDistributionModelServices orderDistributionModelServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserServices userServices, ICoreCmsClerkServices clerkServices, ICoreCmsInvoiceServices invoiceServices)
|
||||
, ICoreCmsBillReshipServices reshipServices, ICoreCmsShipServices shipServices, ICoreCmsLogisticsServices logisticsServices, ICoreCmsOrderDistributionModelServices orderDistributionModelServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserServices userServices, ICoreCmsClerkServices clerkServices, ICoreCmsInvoiceServices invoiceServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, ICoreCmsBillPaymentsServices billPaymentsServices)
|
||||
{
|
||||
_user = user;
|
||||
_orderServices = orderServices;
|
||||
@@ -76,6 +83,9 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
_userServices = userServices;
|
||||
_clerkServices = clerkServices;
|
||||
_invoiceServices = invoiceServices;
|
||||
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
|
||||
_userWeChatInfoServices = userWeChatInfoServices;
|
||||
_billPaymentsServices = billPaymentsServices;
|
||||
}
|
||||
|
||||
|
||||
@@ -701,7 +711,6 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 提交发票申请=======================================================
|
||||
|
||||
/// <summary>
|
||||
@@ -765,9 +774,96 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
|
||||
#endregion
|
||||
|
||||
#region 查询当前订单是否接入微信发货信息管理
|
||||
/// <summary>
|
||||
/// 查询当前订单是否接入微信发货信息管理
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<WebApiCallBack> OrderShippingList([FromBody] FMStringId entity)
|
||||
{
|
||||
var jm = new WebApiCallBack
|
||||
{
|
||||
data = false
|
||||
};
|
||||
var user = await _userWeChatInfoServices.QueryByClauseAsync(p => p.userId == _user.ID);
|
||||
if (user == null)
|
||||
{
|
||||
jm.msg = "微信用户信息获取失败";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//构建请求
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
var request = new WxaSecOrderGetOrderListRequest()
|
||||
{
|
||||
AccessToken = accessToken,
|
||||
OpenId = user.openid
|
||||
};
|
||||
var response = await client.ExecuteWxaSecOrderGetOrderListAsync(request, HttpContext.RequestAborted);
|
||||
if (response.ErrorCode == (int)WeChatReturnCode.ReturnCode.请求成功)
|
||||
{
|
||||
var isHave = response.OrderList.Any(p => p.TransactionId == entity.id && p.OrderState == 2);
|
||||
jm.status = true;
|
||||
jm.code = 0;
|
||||
jm.data = isHave;
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.msg = response.ErrorMessage;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据订单编号获取当前订单的支付信息
|
||||
/// <summary>
|
||||
/// 根据订单编号获取当前订单的支付信息
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<WebApiCallBack> GetOrderPayInfo([FromBody] FMStringId entity)
|
||||
{
|
||||
var jm = new WebApiCallBack
|
||||
{
|
||||
data = false
|
||||
};
|
||||
var user = await _userServices.QueryByClauseAsync(p => p.id == _user.ID);
|
||||
if (user == null)
|
||||
{
|
||||
jm.msg = "用户获取失败";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var order = await _orderServices.QueryByClauseAsync(p => p.orderId == entity.id && p.userId == user.id);
|
||||
if (order == null)
|
||||
{
|
||||
jm.msg = "订单获取失败";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var payment = await _billPaymentsServices.QueryByClauseAsync(p => p.userId == user.id && p.sourceId == order.orderId && p.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed);
|
||||
if (payment == null)
|
||||
{
|
||||
jm.msg = "订单未支付";
|
||||
return jm;
|
||||
}
|
||||
|
||||
jm.code = 0;
|
||||
jm.status = true;
|
||||
jm.data = payment;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user