Exemplo n.º 1
0
        /// <summary>
        /// Amount is rounded to 2 decimals!
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public async Task <Result <OrderResp> > CreateOrder(CreateOrderReq req)
        {
            string             endpoint = "/orders";
            Result <OrderResp> result   = await _apiClient.Post <OrderResp>(endpoint, req);

            return(result);
        }
Exemplo n.º 2
0
    /// <summary>
    /// 创建支付订单
    /// </summary>
    protected virtual void CreateOrder(ProductVo product)
    {
        _product = product;

        Debug.LogError("CreateOrder==>" + product.ToString());

        CreateOrderReq req = new CreateOrderReq
        {
            Channel       = PayAgent.PayChannel,
            Origin        = PayAgent.PayChannel,
            CommodityId   = product.CommodityId,
            Type          = product.ProductType,
            Version       = "100",
            Environment   = 0, //TODO 0沙箱,1正式
            PayType       = (int)PayAgent.PayType.GooglePlay,
            SdkVersion    = "100",
            Tag           = AppConfig.Instance.payKey,
            TriggerGiftId = new TriggerGiftIdPb()
            {
                Id = _product.ExtInt
            }
        };

        byte[] buffer = NetWorkManager.GetByteData(req);

        LoadingOverlay.Instance.Show();
        NetWorkManager.Instance.Send <CreateOrderRes>(CMD.RECHARGEC_CREATEORDER, buffer, OnGetOrderSuccess,
                                                      OnGetOrderError);
    }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([FromBody] CreateOrderReq req)
        {
            var merchantCode = Guid.Parse(User.Claims.FirstOrDefault(x => x.Type == "MerchantCode").Value);
            await _mediator.Send(new CreateOrderCommand(merchantCode, req.MerchantAddressCode, req.ShouldUpdateCustomer, req.CustomerCode, req.FirstName, req.LastName,
                                                        req.Phone, req.OrderNote, req.IsContactlessDelivery, req.ReceiverAddress, req.OrderProducts));

            return(Created("Create", ""));
        }
Exemplo n.º 4
0
    /// <summary>
    /// 创建支付订单
    /// </summary>
    protected virtual void CreateOrder(ProductVo product)
    {
        LoadingOverlay.Instance.Show();

        _product = product;
        string param = GalaSDKBaseFunction.PayCreateOrderParameter();

        Debug.LogError("CreateOrder==>" + product.ToString() + "\n param:" + param);

        JSONObject extJson = new JSONObject();

        extJson.AddField("productName", _product.Name);
        extJson.AddField("productDesc", _product.Name);

        if (!param.IsNullOrEmpty() && !param.Equals("false"))
        {
            JSONObject paramJson = new JSONObject(param);
            if (paramJson != null && paramJson.keys != null)
            {
                for (int i = 0; i < paramJson.keys.Count; i++)
                {
                    string key = paramJson.keys[i];
                    extJson.AddField(key, paramJson[key].str);
                }
            }
        }

        CreateOrderReq req = new CreateOrderReq
        {
            Channel       = PayAgent.GetPaySdk(payType),
            Origin        = PayChannel,
            CommodityId   = product.CommodityId,
            Type          = product.ProductType,
            Version       = PayVersion.GetPayVersion(payType),
            SdkVersion    = PayVersion.GetPaySdkVersion(payType),
            Environment   = 0, //TODO 0沙箱,1正式
            PayType       = (int)payType,
            Tag           = AppConfig.Instance.payKey,
            IsClose       = int.Parse(AppConfig.Instance.SwitchControl.CheckAdultPay),
            TriggerGiftId = new TriggerGiftIdPb()
            {
                Id = _product.ExtInt
            },
            Extra = extJson.ToString()
        };

        byte[] buffer = NetWorkManager.GetByteData(req);

        LoadingOverlay.Instance.Show();
        NetWorkManager.Instance.Send <CreateOrderRes>(CMD.RECHARGEC_CREATEORDER, buffer, OnGetOrderSuccess, OnGetOrderError);
    }
Exemplo n.º 5
0
    /// <summary>
    /// 创建订单
    /// </summary>
    /// <param name="product"></param>
    /// <param name="succCallBack"></param>
    private void CreateOrder(ProductVo product, Action succCallBack)
    {
        LoadingOverlay.Instance.Show();

        CreateOrderReq req = new CreateOrderReq
        {
            Origin        = PayAgent.PayChannel,
            Channel       = PayAgent.PayChannel,
            CommodityId   = product.CommodityId,
            Type          = product.ProductType,
            PayType       = -1,
            Environment   = 0,
            SdkVersion    = "100",
            Version       = "100",
            Tag           = AppConfig.Instance.payKey,
            IsClose       = int.Parse(AppConfig.Instance.SwitchControl.CheckAdultPay),
            TriggerGiftId = new TriggerGiftIdPb()
            {
                Id = product.ExtInt
            },
        };

        byte[] buffer = NetWorkManager.GetByteData(req);
        NetWorkManager.Instance.Send <CreateOrderRes>(CMD.RECHARGEC_CREATEORDER, buffer, (res =>
        {
            LoadingOverlay.Instance.Hide();
            Debug.LogError("IOS创建订单成功回调--->" + "响应码:" + res.Ret + ";充值总金额:" + res.TotalRecharge);
            if (res.Ret == ErrorCode.SERVER_TOURIST_NOT_RECHARGE ||
                res.Ret == ErrorCode.SERVER_RECHARGE_UPPERLIMIT ||
                res.Ret == ErrorCode.SERVER_NOT_OPPEN_RECHARGE)
            {
                ShowWallowPayView(res.Ret, res.TotalRecharge);
                return;
            }

            succCallBack?.Invoke();
        }), OnGetOrderError);
    }
Exemplo n.º 6
0
        public bool CreateOrder(CreateOrderReq order)
        {
            bool res = _rep.CreateOrder(order.CompanyName, order.email, order.phone, order.address, order.productID, order.orderDate, order.amount);

            return(res);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 改单流程
        /// </summary>
        /// <returns></returns>
        private JsonResult ChangeOrder()
        {
            var ID         = ChangeOrderID.Value;
            var customerID = ConfigurationManager.AppSettings["CustomerID"];
            var ChangeID   = Guid.NewGuid();
            var CreateDate = DateTime.Now;
            var XmsOrderId = string.Empty;
            var _orderInfo = OrderInfo;


            var orderChannel = OrderApiClientChannelFactory.GetChannel();
            var oldOrder     = orderChannel.FindByID(ID);

            #region
            //CreateOrderResponse xmlOrderRes = null;
            //if (_orderInfo.details.attendCount < 60 || oldOrder.MMCoEApproveState == MMCoEApproveState.APPROVESUCCESS)
            //{
            //    // 调用小秘书改单
            //    var openApiChannel = OpenApiChannelFactory.GetChannel();
            //    var _res = openApiChannel.createOrder2(ChangeID.ToString(), oldOrder.XmsOrderId,
            //        string.IsNullOrEmpty(oldOrder.XmsOrderId) ? "0" : "1", _orderInfo);
            //    if (_res.code != "200")
            //    {
            //        return Json(new { state = 0, txt = "改单失败", errCode = _res.code });
            //    }
            //    xmlOrderRes = _res;
            //    if (string.IsNullOrEmpty(oldOrder.XmsOrderId))
            //    {
            //        XmsOrderId = xmlOrderRes.result.xmsOrderId;
            //    }

            //}
            #endregion

            var _enterpriseOrderId = oldOrder.EnterpriseOrderId;
            if (string.IsNullOrEmpty(_enterpriseOrderId))
            {
                int RandKey  = new Random().Next(1, 999);
                var two      = (RandKey < 10 ? "00" + RandKey : (RandKey < 100 ? "0" + RandKey : RandKey.ToString()));
                var _channel = _orderInfo.supplier;
                var _date    = DateTime.Now.ToString("yyMMddHHmmss");
                _enterpriseOrderId = _channel.ToUpper() + "-" + _date + two;
            }

            var foodList = _orderInfo.foods.foods.Select(a => a.ToFoodRequest()).ToArray();
            var foods    = new List <iPathFeast.ApiEntity.Food>();
            foreach (var item in foodList)
            {
                foods.Add(new iPathFeast.ApiEntity.Food()
                {
                    foodId   = item.foodId,
                    foodName = item.foodName,
                    count    = Convert.ToInt32(item.count)
                });
            }
            var type = string.IsNullOrEmpty(oldOrder.XmsOrderId) ? "0" : "1";
            if (_orderInfo.details.attendCount < 60 || oldOrder.MMCoEApproveState == MMCoEApproveState.APPROVESUCCESS)
            {
                // 调用小秘书下单
                //var openApiChannel = OpenApiChannelFactory.GetChannel();
                //var _res = openApiChannel.createOrder2(ID.ToString(), string.Empty, "0", _orderInfo);
                var req = new CreateOrderReq()
                {
                    _Channels         = oldOrder.Channel,
                    enterpriseOrderId = _enterpriseOrderId,
                    oldiPathOrderId   = oldOrder.XmsOrderId,
                    CustomerID        = Guid.Parse(customerID),
                    sendTime          = _orderInfo.details.deliverTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                    foodFee           = _orderInfo.foods.foodFee.ToString(),
                    packageFee        = _orderInfo.foods.packageFee.ToString(),
                    sendFee           = _orderInfo.foods.sendFee.ToString(),
                    totalFee          = _orderInfo.foods.allPrice.ToString(),
                    invoiceTitle      = _orderInfo.hospital.invoiceTitle + " - " + _orderInfo.hospital.dutyParagraph,
                    orderTime         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    remark            = _orderInfo.details.remark,
                    dinnerName        = _orderInfo.details.consignee,
                    dinnernum         = _orderInfo.details.attendCount.ToString(),
                    phone             = _orderInfo.details.phone,
                    address           = _orderInfo.hospital.address + " - " + _orderInfo.details.deliveryAddress,
                    resId             = _orderInfo.foods.resId,
                    longitude         = _orderInfo.hospital.longitude,
                    latitude          = _orderInfo.hospital.latitude,
                    hospitalId        = _orderInfo.hospital.hospital,
                    foods             = foods,
                    cityId            = _orderInfo.hospital.city,
                    cn       = _orderInfo.CnCode,
                    cnAmount = _orderInfo.meeting.budgetTotal.ToString(),
                    mudId    = _orderInfo.meeting.userId,
                    typeId   = type
                };
                var _res = apiClient.CreateOrder(req);
                if (_res.errorCode != "0")
                {
                    return(Json(new { state = 0, txt = _res.errorMsg, errCode = _res.errorCode }));
                }
                if (string.IsNullOrEmpty(oldOrder.XmsOrderId))
                {
                    XmsOrderId = _res.iPathOrderId;
                }
            }

            // 写入改单后的新数据
            //var res = orderChannel.Change(ID, ChangeID, _orderInfo);
            //if (res > 0)
            //{
            //    OrderInfo = null;
            //    if (!string.IsNullOrEmpty(XmsOrderId))
            //    {
            //        // 从未在小秘书下单过的改单,下单成功后应写入小秘书单号
            //        orderChannel.SaveXmsOrderId(ID, XmsOrderId);
            //    }

            //    oldOrder = orderChannel.FindByID(ID);
            //    WxMessageHandler.GetInstance().SendMessageToUser(CurrentWxUser.UserId, oldOrder);
            //    return Json(new { state = 1, isChange = 1 });
            //}
            return(Json(new { state = 0, txt = "改单失败", errCode = "9001" }));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 下新单
        /// </summary>
        /// <returns></returns>
        private JsonResult NewOrder()
        {
            var ID                 = Guid.NewGuid();
            var customerID         = ConfigurationManager.AppSettings["CustomerID"];
            var CreateDate         = DateTime.Now;
            var XmsOrderId         = string.Empty;
            var _orderInfo         = OrderInfo;
            int RandKey            = new Random().Next(1, 999);
            var two                = (RandKey < 10 ? "00" + RandKey : (RandKey < 100 ? "0" + RandKey : RandKey.ToString()));
            var _channel           = _orderInfo.supplier;
            var _date              = DateTime.Now.ToString("yyMMddHHmmss");
            var _enterpriseOrderId = _channel.ToUpper() + "-" + _date + two;
            var foodList           = _orderInfo.foods.foods.Select(a => a.ToFoodRequest()).ToArray();
            var foods              = new List <iPathFeast.ApiEntity.Food>();

            foreach (var item in foodList)
            {
                foods.Add(new iPathFeast.ApiEntity.Food()
                {
                    foodId   = item.foodId,
                    foodName = item.foodName,
                    count    = Convert.ToInt32(item.count)
                });
            }

            if (string.IsNullOrEmpty(_orderInfo.mmCoE) && _orderInfo.details.attendCount < 60)
            {
                // 调用小秘书下单
                //var openApiChannel = OpenApiChannelFactory.GetChannel();
                //var _res = openApiChannel.createOrder2(ID.ToString(), string.Empty, "0", _orderInfo);
                var req = new CreateOrderReq()
                {
                    _Channels         = _channel,
                    enterpriseOrderId = _enterpriseOrderId,
                    oldiPathOrderId   = string.Empty,
                    CustomerID        = Guid.Parse(customerID),
                    sendTime          = _orderInfo.details.deliverTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                    foodFee           = _orderInfo.foods.foodFee.ToString(),
                    packageFee        = _orderInfo.foods.packageFee.ToString(),
                    sendFee           = _orderInfo.foods.sendFee.ToString(),
                    totalFee          = _orderInfo.foods.allPrice.ToString(),
                    invoiceTitle      = _orderInfo.hospital.invoiceTitle + " - " + _orderInfo.hospital.dutyParagraph,
                    orderTime         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    remark            = _orderInfo.details.remark,
                    dinnerName        = _orderInfo.details.consignee,
                    dinnernum         = _orderInfo.details.attendCount.ToString(),
                    phone             = _orderInfo.details.phone,
                    address           = _orderInfo.hospital.address + " - " + _orderInfo.details.deliveryAddress,
                    resId             = _orderInfo.foods.resId,
                    longitude         = _orderInfo.hospital.longitude,
                    latitude          = _orderInfo.hospital.latitude,
                    hospitalId        = _orderInfo.hospital.hospital,
                    foods             = foods,
                    cityId            = _orderInfo.hospital.city,
                    cn       = _orderInfo.CnCode,
                    cnAmount = _orderInfo.meeting.budgetTotal.ToString(),
                    mudId    = _orderInfo.meeting.userId,
                    typeId   = "0"
                };
                var _res = apiClient.CreateOrder(req);
                if (_res.errorCode != "0")
                {
                    return(Json(new { state = 0, txt = _res.errorMsg, errCode = _res.errorCode }));
                }
                XmsOrderId = _res.iPathOrderId;
            }
            // 写入数据库订单记录
            var channel = OrderApiClientChannelFactory.GetChannel();

            //var res = channel.Add(ID, CurrentWxUser.UserId, XmsOrderId, _orderInfo, _enterpriseOrderId,_channel);
            //if (res > 0)
            //{
            //    OrderInfo = null;
            //    var order = channel.FindByID(ID);
            //    WxMessageHandler.GetInstance().SendMessageToUser(CurrentWxUser.UserId, order);
            //    return Json(new { state = 1, isChange = 0 });
            //}
            return(Json(new { state = 0, txt = "下单失败", errCode = "9001" }));
        }
Exemplo n.º 9
0
        public IActionResult CreateOrder([FromBody] CreateOrderReq req)
        {
            var res = _svc.CreateOrder(req);

            return(Ok(res));
        }
Exemplo n.º 10
0
        /// <summary>
        /// MMCoE审批
        /// </summary>
        /// <param name="id"></param>
        /// <param name="state"></param>
        /// <param name="reason"></param>
        /// <returns></returns>
        public JsonResult SaveMMCoEResult(Guid orderId, int state, string reason)
        {
            var channel         = OrderApiClientChannelFactory.GetChannel();
            var evaluateChannel = EvaluateClientChannelFactory.GetChannel();
            var order           = channel.FindByID(orderId);
            var customerID      = ConfigurationManager.AppSettings["CustomerID"];

            //审批驳回
            if (state == 2)
            {
                var res = channel.MMCoEResult(orderId, state, reason);
                if (res == 1)
                {
                    P_ORDER_APPROVE entity = new P_ORDER_APPROVE();
                    entity.ID           = Guid.NewGuid();
                    entity.OrderID      = orderId;
                    entity.CN           = order.CN;
                    entity.UserId       = order.UserId;
                    entity.OldState     = order.State;
                    entity.NewState     = OrderState.REJECT;
                    entity.Result       = 0;
                    entity.Comment      = reason;
                    entity.IsWXClient   = 1;
                    entity.CreateDate   = DateTime.Now;
                    entity.CreateUserId = CurrentWxUser.UserId;
                    //添加审批记录
                    var evaluateRes = evaluateChannel.AddOrderApprove(entity);

                    if (evaluateRes == 0)
                    {
                        LogHelper.Info($"订单状态修改成功,添加审批记录失败 - [{ orderId.ToString()}]");
                    }
                    // 发用户消息
                    WxMessageHandler.GetInstance().SendMessageToUser(order.UserId, order);
                    return(Json(new { state = 1, txt = "订单审批已驳回" }));
                }
                else
                {
                    LogHelper.Info($"(审批驳回)订单状态修改失败 - [{ orderId.ToString()}]");
                }
            }

            //审批通过
            else
            {
                //订单审批
                var _res = channel.MMCoEResult(orderId, state, reason);
                if (_res == 1)
                {
                    //var openApiChannel = OpenApiChannelFactory.GetChannel();
                    //下新单
                    if (order.IsChange == 0)
                    {
                        var     json      = order.Detail;
                        P_Order orderInfo = JsonConvert.DeserializeObject <P_Order>(json);
                        var     foodList  = orderInfo.foods.foods.Select(a => a.ToFoodRequest()).ToArray();
                        var     foods     = new List <iPathFeast.ApiEntity.Food>();
                        foreach (var item in foodList)
                        {
                            foods.Add(new iPathFeast.ApiEntity.Food()
                            {
                                foodId   = item.foodId,
                                foodName = item.foodName,
                                count    = Convert.ToInt32(item.count)
                            });
                        }

                        //调用小秘书下单接口
                        //var openApiRes = openApiChannel.createOrder2(orderId.ToString(), string.Empty, "0", orderInfo);
                        var req = new CreateOrderReq()
                        {
                            _Channels         = order.Channel,
                            enterpriseOrderId = order.EnterpriseOrderId,
                            oldiPathOrderId   = string.Empty,
                            CustomerID        = Guid.Parse(customerID),
                            sendTime          = orderInfo.details.deliverTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                            foodFee           = orderInfo.foods.foodFee.ToString(),
                            packageFee        = orderInfo.foods.packageFee.ToString(),
                            sendFee           = orderInfo.foods.sendFee.ToString(),
                            totalFee          = orderInfo.foods.allPrice.ToString(),
                            invoiceTitle      = orderInfo.hospital.invoiceTitle + " - " + orderInfo.hospital.dutyParagraph,
                            orderTime         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            remark            = orderInfo.details.remark,
                            dinnerName        = orderInfo.details.consignee,
                            dinnernum         = orderInfo.details.attendCount.ToString(),
                            phone             = orderInfo.details.phone,
                            address           = orderInfo.hospital.address + " - " + orderInfo.details.deliveryAddress,
                            resId             = orderInfo.foods.resId,
                            longitude         = orderInfo.hospital.longitude,
                            latitude          = orderInfo.hospital.latitude,
                            hospitalId        = orderInfo.hospital.hospital,
                            foods             = foods,
                            cityId            = orderInfo.hospital.city,
                            cn       = order.CN,
                            cnAmount = orderInfo.meeting.budgetTotal.ToString(),
                            mudId    = orderInfo.meeting.userId,
                            typeId   = "0"
                        };
                        var openApiRes = apiClient.CreateOrder(req);
                        if (openApiRes.errorCode == "0")
                        {
                            var _channel = OrderApiClientChannelFactory.GetChannel();
                            // 审批下单成功,保存小秘书单号
                            var res = channel.SaveXmsOrderId(orderId, openApiRes.iPathOrderId);
                            if (res > 0)
                            {
                                var _order = channel.FindByID(orderId);

                                P_ORDER_APPROVE entity = new P_ORDER_APPROVE();
                                entity.ID           = Guid.NewGuid();
                                entity.OrderID      = orderId;
                                entity.CN           = _order.CN;
                                entity.UserId       = _order.UserId;
                                entity.OldState     = order.State;
                                entity.NewState     = _order.State;
                                entity.Result       = 1;
                                entity.Comment      = reason;
                                entity.IsWXClient   = 1;
                                entity.CreateDate   = DateTime.Now;
                                entity.CreateUserId = CurrentWxUser.UserId;
                                //添加审批记录
                                var evaluateRes = evaluateChannel.AddOrderApprove(entity);

                                if (evaluateRes == 0)
                                {
                                    LogHelper.Info($"审批通过,下单成功,保存小秘书单号成功,添加审批记录失败 - [{ orderId.ToString()}]");
                                }
                                //发用户消息
                                WxMessageHandler.GetInstance().SendMessageToUser(order.UserId, _order);
                                return(Json(new { state = 1, txt = "订单审批已通过" }));
                            }
                            else
                            {
                                LogHelper.Info("审批通过,下单成功,保存小秘书单号失败");
                            }
                        }
                        else
                        {
                            //审批退回审批前状态
                            var res = channel._MMCoEResult(orderId, 1, "");
                            if (res == 1)
                            {
                                return(Json(new { state = 0, txt = "调用小秘书下单接口失败,订单审批失败", errCode = openApiRes.errorCode }));
                            }
                            else
                            {
                                LogHelper.Info($"订单状态修改成功,调用小秘书下单接口失败,订单审批退回失败 - [{ orderId.ToString()}]");
                            }
                        }
                    }
                    //改单
                    else
                    {
                        var     json       = order.ChangeDetail;
                        P_Order orderInfo  = JsonConvert.DeserializeObject <P_Order>(json);
                        var     ChangeID   = Guid.NewGuid();
                        var     XmsOrderId = string.Empty;
                        var     foodList   = orderInfo.foods.foods.Select(a => a.ToFoodRequest()).ToArray();
                        var     foods      = new List <iPathFeast.ApiEntity.Food>();
                        foreach (var item in foodList)
                        {
                            foods.Add(new iPathFeast.ApiEntity.Food()
                            {
                                foodId   = item.foodId,
                                foodName = item.foodName,
                                count    = Convert.ToInt32(item.count)
                            });
                        }
                        var _enterpriseOrderId = order.EnterpriseOrderId;
                        if (string.IsNullOrEmpty(_enterpriseOrderId))
                        {
                            int RandKey  = new Random().Next(1, 999);
                            var two      = (RandKey < 10 ? "00" + RandKey : (RandKey < 100 ? "0" + RandKey : RandKey.ToString()));
                            var _channel = orderInfo.supplier;
                            var _date    = DateTime.Now.ToString("yyMMddHHmmss");
                            _enterpriseOrderId = _channel.ToUpper() + "-" + _date + two;
                        }
                        var type = string.IsNullOrEmpty(order.XmsOrderId) ? "0" : "1";
                        var req  = new CreateOrderReq()
                        {
                            _Channels         = order.Channel,
                            enterpriseOrderId = _enterpriseOrderId,
                            oldiPathOrderId   = order.XmsOrderId,
                            CustomerID        = Guid.Parse(customerID),
                            sendTime          = orderInfo.details.deliverTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                            foodFee           = orderInfo.foods.foodFee.ToString(),
                            packageFee        = orderInfo.foods.packageFee.ToString(),
                            sendFee           = orderInfo.foods.sendFee.ToString(),
                            totalFee          = orderInfo.foods.allPrice.ToString(),
                            invoiceTitle      = orderInfo.hospital.invoiceTitle + " - " + orderInfo.hospital.dutyParagraph,
                            orderTime         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            remark            = orderInfo.details.remark,
                            dinnerName        = orderInfo.details.consignee,
                            dinnernum         = orderInfo.details.attendCount.ToString(),
                            phone             = orderInfo.details.phone,
                            address           = orderInfo.hospital.address + " - " + orderInfo.details.deliveryAddress,
                            resId             = orderInfo.foods.resId,
                            longitude         = orderInfo.hospital.longitude,
                            latitude          = orderInfo.hospital.latitude,
                            hospitalId        = orderInfo.hospital.hospital,
                            foods             = foods,
                            cityId            = orderInfo.hospital.city,
                            cn       = orderInfo.CnCode,
                            cnAmount = orderInfo.meeting.budgetTotal.ToString(),
                            mudId    = orderInfo.meeting.userId,
                            typeId   = type
                        };
                        //调用小秘书下单接口
                        //var openApiRes = openApiChannel.createOrder2(order.ChangeID.ToString(), order.XmsOrderId,
                        //    string.IsNullOrEmpty(order.XmsOrderId) ? "0" : "1", orderInfo);
                        var openApiRes = apiClient.CreateOrder(req);

                        if (openApiRes.errorCode == "0")
                        {
                            if (string.IsNullOrEmpty(order.XmsOrderId))
                            {
                                XmsOrderId = openApiRes.iPathOrderId;
                            }
                            var _channel = OrderApiClientChannelFactory.GetChannel();
                            // 写入改单后的新数据
                            //var res = _channel.Change(orderId, ChangeID, orderInfo);
                            //if (res > 0)
                            //{
                            //    if (!string.IsNullOrEmpty(XmsOrderId))
                            //    {
                            //        // 从未在小秘书下单过的改单,下单成功后应写入小秘书单号
                            //        _channel.SaveXmsOrderId(orderId, XmsOrderId);
                            //    }
                            //}
                            OrderInfo = null;
                            var _order = channel.FindByID(orderId);

                            P_ORDER_APPROVE entity = new P_ORDER_APPROVE();
                            entity.ID           = Guid.NewGuid();
                            entity.OrderID      = orderId;
                            entity.CN           = _order.CN;
                            entity.UserId       = _order.UserId;
                            entity.OldState     = order.State;
                            entity.NewState     = _order.State;
                            entity.Result       = 1;
                            entity.Comment      = reason;
                            entity.IsWXClient   = 1;
                            entity.CreateDate   = DateTime.Now;
                            entity.CreateUserId = CurrentWxUser.UserId;
                            //添加审批记录
                            var evaluateRes = evaluateChannel.AddOrderApprove(entity);

                            if (evaluateRes == 0)
                            {
                                LogHelper.Info($"审批通过,(改单)下单成功,保存小秘书单号成功,添加审批记录失败 - [{ orderId.ToString()}]");
                            }

                            //发用户消息
                            WxMessageHandler.GetInstance().SendMessageToUser(order.UserId, _order);
                            return(Json(new { state = 1, txt = "订单审批已通过" }));
                        }
                        else
                        {
                            var res = channel._MMCoEResult(orderId, 1, "");
                            if (res == 1)
                            {
                                return(Json(new { state = 0, txt = openApiRes.errorMsg, errCode = openApiRes.errorCode }));
                            }
                            else
                            {
                                LogHelper.Info($"订单状态修改成功,调用供应商下单接口失败,订单审批退回失败 - [{ orderId.ToString()}]");
                            }
                        }
                    }
                }
                else
                {
                    LogHelper.Info($"(审批通过)订单状态修改失败 - [{ orderId.ToString()}]");
                }
            }

            return(Json(new { state = 0, txt = "订单审批失败,请刷新页面后重试。", errCode = 9007 }));
        }
Exemplo n.º 11
0
        public void CreateOrder()
        {
            Shipper shipper = new Shipper()
            {
                shipper_name        = "易酷",
                shipper_countrycode = "CN",
                shipper_street      = "福建省莆田市工业园",
                shipper_telephone   = "18650805022",
                shipper_mobile      = "18650805022"
            };

            Consignee consignee = new Consignee()
            {
                consignee_name = "Marie Denise Medard Francois",
                /// <summary>
                /// 收件人国家二字代码
                /// </summary>
                consignee_countrycode = "US",
                /// <summary>
                /// 收件人省
                /// </summary>
                consignee_province = "US-FL",
                /// <summary>
                /// 收件人城市
                /// </summary>
                consignee_city = "Mattapan",
                /// <summary>
                /// 收件人地址
                /// </summary>
                consignee_street = "760 Cummins HWY Apt11",
                /// <summary>
                /// 收件人邮编
                /// </summary>
                consignee_postcode = "02126",
                /// <summary>
                /// 收件人电话
                /// </summary>
                consignee_telephone = "862-235-2637",
                /// <summary>
                /// 收件人手机
                /// </summary>
                consignee_mobile = "",
                /// <summary>
                /// 税号
                /// </summary>
                consignee_tariff = "",
            };

            List <Invoice> invoiceList = new List <Invoice>();

            Invoice invoice = new Invoice();

            invoice.invoice_enname     = "Dresses";
            invoice.invoice_cnname     = "是否是";
            invoice.invoice_quantity   = "1";
            invoice.invoice_unitcharge = "2.34";
            invoice.consignee_street   = "760 Cummins HWY Apt11";
            invoice.consignee_postcode = "02126";
            invoiceList.Add(invoice);

            var start = consignee.consignee_province.IndexOf("-") + 1;

            var cons = consignee.consignee_province.Substring(start);

            CreateOrderReqModel model = new CreateOrderReqModel()
            {
                reference_no    = "LB20121891902",
                shipping_method = "EUBYD",
                order_weight    = "10",
                consignee       = consignee,
                shipper         = shipper,
                invoice         = invoiceList
            };
            CreateOrderReq req       = new CreateOrderReq(model);
            YDHClient      yDHClient = new YDHClient();
            var            response  = yDHClient.PostRequestAsync(req);

            Assert.Equal(true, 1 > 0);
        }