Example #1
0
        public async Task <APIResult> AddExpressSingle([FromBody] AddExpressSingleModel input)
        {
            var order = db.ConglomerationOrder.Find(input.OrderId);

            if (!order.Type.Equals(ConsignmentType.快递))
            {
                return(Error("订单类型为自提"));
            }
            if (!order.Status.Equals(ShopOrderStatus.待配送))
            {
                return(Error("订单不是待配送状态"));
            }
            var express = db.ConglomerationExpress.FirstOrDefault(m => m.ShopConglomerationOrderId.Equals(input.OrderId));

            express.ExpressSingle = input.ExpressSingle;
            order.Status          = ShopOrderStatus.已完成;
            db.SaveChanges();

            #region 积分获取
            var sourceType = await ShopIntegralRechargeServer.GetOrderSourceType(db, input.OrderId, true, _logger);

            await ShopIntegralRechargeServer.GetOrderIntegral(db, input.OrderId, sourceType, _logger);

            #endregion
            return(Success());
        }
Example #2
0
        public async Task <APIResult> SetOrderStatus([FromBody] SetStatusArgsModel args)
        {
            var model = db.GetSingle <ShopOrder>(args.Id);

            if (model == null)
            {
                throw new Exception("数据库记录不存在");
            }

            //获取到订单后判断是否拥有指定的店铺的权限
            CheckShopActor(model.ShopId, ShopActorType.超级管理员);
            model.Status = args.Status;
            db.SaveChanges();
            #region 积分获取
            var sourceType = await ShopIntegralRechargeServer.GetOrderSourceType(db, args.Id, false, _logger);

            await ShopIntegralRechargeServer.GetOrderIntegral(db, args.Id, sourceType, _logger);

            #endregion
            return(Success());
        }
Example #3
0
        //[Authorize]
        public async Task <APIResult> ManagerRefund([FromBody] ToAmountArgsModel args)
        {
            string exmsg = string.Empty;

            try
            {
                var shoporder = db.Set <ShopOrder>().FirstOrDefault(r => r.Id == args.id);
                //if (shoporder == null) throw new Exception("未找到此订单");
                //CheckShopActor(shoporder.ShopId, ShopActorType.超级管理员);//检测用户权限
                var shopMemberConsume = db.GetSingle <ShopMemberConsume>(shoporder.ShopMemberConsumeId ?? 0);
                if (shopMemberConsume != null)
                {
                    var shopMemberRufund = db.Query <ShopMemberRufund>()
                                           .Where(m => !m.IsDel && m.ShopOrderId == shoporder.Id)
                                           .FirstOrDefault();
                    if (shopMemberRufund != null)
                    {
                        throw new Exception("该订单已退款");
                    }
                    ShopMemberServer shopMemberServer = new ShopMemberServer(db, shoporder.ShopId, shoporder.MemberId);
                    shopMemberServer.RefundToBalance(shoporder);
                    shoporder.Status = ShopOrderStatus.已退款;
                    db.SaveChanges();
                    var orderType = await ShopIntegralRechargeServer.GetOrderSourceType(db, args.id, false, _logger); //积分回滚

                    await ShopIntegralRechargeServer.IntegralReturn(db, args.id, orderType, _logger);

                    return(Success("退款成功"));
                }
                else
                {
                    var shoppayinfo = db.Set <ShopPayInfo>().FirstOrDefault(r => r.ShopId == shoporder.ShopId && r.IsEnable == true);
                    if (shoppayinfo == null)
                    {
                        throw new Exception("未找到商户退款配置");
                    }
                    var membertradeforrechange = financeDb.Set <MemberTradeForRechange>().Where(r => r.OrderId == shoporder.Id && r.OrderType == OrderType.普通订单 && r.Status == MemberTradeForRechangeStatus.成功);

                    if (membertradeforrechange != null && membertradeforrechange.Count() > 0) //代表有支付成功的数据
                    {
                        Refunds refunds      = new Refunds(proxyFactory);
                        var     refundresult = refunds.RefundAction(new RefundArgsModel()
                        {
                            ShopFlag = shoppayinfo.ShopFlag, TradeNo = membertradeforrechange.First().TradeNo, OrderType = OrderType.普通订单, OrderId = shoporder.Id
                        });
                        if (refundresult.Status == MemberTradeForRefundStatus.成功)
                        {
                            shoporder.Status = ShopOrderStatus.已退款;
                            DecreaseCommodity(shoporder);
                            db.SaveChanges();
                            return(Success());
                        }
                        else if (refundresult.Status == MemberTradeForRefundStatus.退款中)
                        {
                            shoporder.Status = ShopOrderStatus.退款中;
                            db.SaveChanges();
                        }
                        else
                        {
                            shoporder.Status = ShopOrderStatus.退款中;
                            db.SaveChanges();
                        }
                        var orderType = await ShopIntegralRechargeServer.GetOrderSourceType(db, args.id, false, _logger); //积分回滚

                        await ShopIntegralRechargeServer.IntegralReturn(db, args.id, orderType, _logger);

                        return(Success("您的退款申请已经提交,银行处理退款中"));
                    }
                    else
                    {
                        throw new Exception($"找不到订单{shoporder.OrderNumber}支付成功的记录");
                    }
                }
            }
            catch (Exception ex)
            {
                exmsg = ex.Message;
                throw new Exception(ex.Message);
            }
        }