public async Task <IActionResult> SetPayed([FromForm] string order_uid, [FromForm] int?pay_method,
                                                   [FromForm] string external_payment_no,
                                                   [FromForm] string img, [FromForm] string comment)
        {
            order_uid.Should().NotBeNullOrEmpty();
            pay_method.Should().NotBeNull();
            var imgs = this.JsonToEntity_ <string[]>(img);

            var loginadmin = await this.GetLoginAdminAsync();

            var olog = new OperationLogMessage(loginadmin).UpdateOrAdd("订单管理", true).WithMessage("设为已支付").WithExtraData(new
            {
                order_uid,
                pay_method,
                external_payment_no,
                img,
                comment
            });

            await this.AddOperationLog(olog);

            await this._service.SetPayed(loginadmin.UserID, order_uid, pay_method.Value, external_payment_no, comment, imgs);

            await this.AddOrderStatusHistoryLog(order_uid);

            return(SuccessJson());
        }
        public async Task <IActionResult> ApproveOrder([FromForm] string order_uid, [FromForm] bool?approved, [FromForm] string comment)
        {
            order_uid.Should().NotBeNullOrEmpty();
            approved.Should().NotBeNull();
            comment ??= string.Empty;
            if (!approved.Value && ValidateHelper.IsEmpty(comment))
            {
                throw new MsgException("请输入拒绝理由");
            }

            var loginadmin = await this.GetLoginAdminAsync();

            var olog = new OperationLogMessage(loginadmin).UpdateOrAdd("订单管理", true).WithMessage("审核订单")
                       .WithExtraData(new
            {
                order_uid,
                approved,
                comment
            });

            await this.AddOperationLog(olog);

            await this._service.ApproveOrReject(loginadmin.UserID, order_uid, approved.Value, comment);

            await this.AddOrderStatusHistoryLog(order_uid);

            return(SuccessJson());
        }
Exemple #3
0
        public override async Task <IActionResult> Delete([FromForm] string uid)
        {
            var loginadmin = await this.GetLoginAdminAsync();

            var olog = new OperationLogMessage(loginadmin).Delete("线路管理").WithExtraData(new { uid });

            await this.AddOperationLog(olog);

            return(await base.Delete(uid));
        }
Exemple #4
0
        public override async Task <IActionResult> Save([FromForm] string data)
        {
            var loginadmin = await this.GetLoginAdminAsync();

            this.AfterSave = async update =>
            {
                var olog = new OperationLogMessage(loginadmin).UpdateOrAdd("线路管理", update).WithExtraData(new { data });
                await this.AddOperationLog(olog);
            };

            return(await base.Save(data));
        }
        public async Task <IActionResult> UpdateOrderStatus([FromForm] string order_uid, [FromForm] int status)
        {
            var loginadmin = await this.GetLoginAdminAsync();

            var olog = new OperationLogMessage(loginadmin).UpdateOrAdd("订单管理", true).WithMessage("修改订单状态")
                       .WithExtraData(new { order_uid, status });

            await this.AddOperationLog(olog);

            var data = await this._service.UpdateOrderStatus(order_uid, status);

            await this.AddOrderStatusHistoryLog(data.UID);

            return(SuccessJson());
        }
        public override async Task <IActionResult> Delete([FromForm] string uid)
        {
            var loginadmin = await this.GetLoginAdminAsync();

            this.AfterSave = async update =>
            {
                var olog = new OperationLogMessage(loginadmin).UpdateOrAdd("橱窗管理", update).WithExtraData(new { uid });
                await this.AddOperationLog(olog);
            };

            var res = await base.Delete(uid);

            await this.__remove_cache__();

            return(res);
        }
Exemple #7
0
        public override async Task <IActionResult> Save([FromForm] string data)
        {
            var loginadmin = await this.GetLoginAdminAsync();

            this.AfterSave = async update =>
            {
                var olog = new OperationLogMessage(loginadmin).PageAction("案例管理", update ? "更新" : "新建").WithExtraData(new { data });
                await this.AddOperationLog(olog);
            };

            var res = await base.Save(data);

            var key = this.cacheKeyManager.ShowCase();

            await this._cache.RemoveAsync(key);

            return(res);
        }
Exemple #8
0
        public async Task <IActionResult> ConfirmDesign([FromForm] string order_uid)
        {
            order_uid.Should().NotBeNullOrEmpty();
            var loginuser = await this.GetLoginUserAsync();

            var olog = new OperationLogMessage(loginuser).UpdateOrAdd("订单", true).WithMessage("确认设计").WithExtraData(new
            {
                order_uid
            });

            await this.AddOperationLog(olog);

            await this._service.ConfirmDesign(loginuser.UserID, order_uid);

            await this.AddOrderStatusHistoryLog(order_uid);

            return(SuccessJson());
        }
Exemple #9
0
        public async Task <IActionResult> UpdateOrder([FromForm] string data)
        {
            var model = this.JsonToEntity_ <OrderEntity>(data);

            model.UID.Should().NotBeNullOrEmpty();
            if (ValidateHelper.IsEmpty(model.CustomerDemand))
            {
                return(GetJsonRes("用户需求不能为空"));
            }
            if (ValidateHelper.IsEmpty(model.ImageList))
            {
                return(GetJsonRes("请上传用户需求图"));
            }
            if (ValidateHelper.IsEmpty(model.OrderItems))
            {
                return(GetJsonRes("请至少选择一个广告位"));
            }

            var loginuser = await this.GetLoginUserAsync();

            var olog = new OperationLogMessage(loginuser).UpdateOrAdd("订单", true).WithMessage("修改订单").WithExtraData(model);

            await this.AddOperationLog(olog);

            model.UserUID = loginuser.UserID;

            var is_mine = await this._service.IsMyOrder(model.UID, loginuser.UserID);

            is_mine.Should().BeTrue();

            var order_res = await this._service.UpdateOrder(model);

            order_res.ThrowIfNotSuccess();

            await this.AddOrderStatusHistoryLog(order_res.Data.UID);

            var res = new
            {
                order_res.Data.UID,
                order_res.Data.OrderNo,
            };

            return(SuccessJson(res));
        }
Exemple #10
0
        public async Task <IActionResult> SetPaymentPending([FromForm] string order_uid)
        {
            var loginuser = await this.GetLoginUserAsync();

            var olog = new OperationLogMessage(loginuser).UpdateOrAdd("订单", true).WithMessage("支付成功,冻结订单支付").WithExtraData(new
            {
                order_uid
            });

            await this.AddOperationLog(olog);

            var is_mine = await this._service.IsMyOrder(order_uid, loginuser.UserID);

            is_mine.Should().BeTrue();

            await this._service.SetPaymentPending(order_uid);

            return(SuccessJson());
        }
Exemple #11
0
        public async Task <IActionResult> CloseOrder([FromForm] string order_uid)
        {
            order_uid.Should().NotBeNullOrEmpty();

            var loginadmin = await this.GetLoginAdminAsync();

            var olog = new OperationLogMessage(loginadmin).UpdateOrAdd("订单管理", true).WithMessage("关闭订单").WithExtraData(new
            {
                order_uid
            });

            await this.AddOperationLog(olog);

            await this._service.CloseOrder(order_uid, "不想要了");

            await this.AddOrderStatusHistoryLog(order_uid);

            return(SuccessJson());
        }
Exemple #12
0
        public async Task <IActionResult> CloseOrder([FromForm] string order_uid)
        {
            order_uid.Should().NotBeNullOrEmpty();
            var loginuser = await this.GetLoginUserAsync();

            var olog = new OperationLogMessage(loginuser).UpdateOrAdd("订单", true).WithMessage("关闭订单").WithExtraData(new
            {
                order_uid
            });

            await this.AddOperationLog(olog);

            var mine = await this._service.IsMyOrder(order_uid, loginuser.UserID);

            mine.Should().BeTrue();

            await this._service.CloseOrder(order_uid, "用户主动关闭,不想要了");

            await this.AddOrderStatusHistoryLog(order_uid);

            return(SuccessJson());
        }
Exemple #13
0
        public async Task <IActionResult> AddOrderDeploymentDown([FromForm] string data)
        {
            var model = this.JsonToEntity_ <DeployEntity>(data);

            var loginadmin = await this.GetLoginAdminAsync();

            var olog = new OperationLogMessage(loginadmin).UpdateOrAdd("订单管理", true).WithMessage("下刊").WithExtraData(model);

            await this.AddOperationLog(olog);

            model.ImageList ??= new string[] { };

            model.ImageJson    = this.stringArraySerializer.Serialize(model.ImageList);
            model.DeployerUID  = loginadmin.UserID;
            model.DeployerName = loginadmin.UserName;

            var res = await this._service.AddOrderDeploymentDown(model);

            await this.AddOrderStatusHistoryLog(model.OrderUID);

            return(SuccessJson());
        }
Exemple #14
0
        public async Task <IActionResult> AddOrderDesign([FromForm] string data)
        {
            var model = this.JsonToEntity_ <DesignImageEntity>(data);

            model.DesignImages ??= new string[] { };
            if (!model.DesignImages.Any())
            {
                return(GetJsonRes("至少上传一张图片"));
            }

            var loginadmin = await this.GetLoginAdminAsync();

            var olog = new OperationLogMessage(loginadmin).UpdateOrAdd("订单管理", true).WithMessage("添加设计稿").WithExtraData(model);

            await this.AddOperationLog(olog);

            model.DesignImageJson = this.stringArraySerializer.Serialize(model.DesignImages);
            model.DesignerUID     = loginadmin.UserID;

            await this._service.AddOrderDesign(model);

            return(SuccessJson());
        }
Exemple #15
0
        public async Task <IActionResult> CreatePrepayOrder(string order_uid, string code)
        {
            var log = new Dictionary <string, object>
            {
                ["input"] = new { order_uid, code }
            };

            try
            {
                order_uid.Should().NotBeNullOrEmpty();
                code.Should().NotBeNullOrEmpty();

                var loginuser = await this.GetLoginUserAsync();

                log["user_uid"] = loginuser.UserID;

                var openid = await this.__get_openid__(loginuser.UserID, code);

                log["openid"] = openid;

                var order = await this.orderService.GetByUID(order_uid);

                order.Should().NotBeNull();
                order.UserUID.Should().Be(loginuser.UserID);

                if (order.TotalPriceInCent <= 0)
                {
                    throw new MsgException("订单金额必须大于0");
                }

                if (order.Status != (int)OrderStatusEnum.待付款)
                {
                    throw new MsgException("订单状态无法发起支付");
                }

                if (order.PaymentPending > 0)
                {
                    throw new MsgException("订单已支付,等待支付结果中");
                }

                log["order"] = order;

                var out_trade_no = await this.__create_out_trade_no__(order);

                log["out_trade_no"] = out_trade_no;

                var dict = new Dictionary <string, object>()
                {
                    ["out_trade_no"] = out_trade_no,
                    ["total_fee"]    = order.TotalPriceInCent,
                    ["body"]         = $"商品-订单号:{order.OrderNo}",
                    ["trade_type"]   = "JSAPI",
                    ["openid"]       = openid,
                };

                var wx_res = await this.wxPayApi.UnifiedOrder(dict);

                wx_res.Should().NotBeNull();

                log["wx_res"] = wx_res;

                if (!wx_res.IsSuccess())
                {
                    throw new WxPayException("创建支付订单号失败");
                }

                var olog = new OperationLogMessage(loginuser).UpdateOrAdd("支付", false).WithMessage("发起支付").WithExtraData(new
                {
                    order_uid,
                    openid,
                    pay_info = dict
                });
                await this.AddOperationLog(olog);

                var res = this.__prepay_data__(wx_res);
                return(SuccessJson(res));
            }
            catch (WxPayException e)
            {
                log["out_exception"]      = e.Message;
                log["out_exception_info"] = e.Info;

                var info = log.ToJson();

                this._logger.AddErrorLog(info, e);
                return(GetJsonRes("创建支付订单号失败"));
            }
        }