Exemplo n.º 1
0
        /// <summary>
        /// 系统单个订单查询达达订单状态
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="order"></param>
        /// <param name="rid"></param>
        public void GetFoodDadaOrderDetailState <T>(ref T order, int rid)
        {
            int sendWay = Convert.ToInt32(order.GetType().GetProperty("GetWay").GetValue(order));

            if (sendWay != (int)miniAppOrderGetWay.达达配送)
            {
                return;
            }
            object objId = order.GetType().GetProperty("Id").GetValue(order);

            if (objId == null || DBNull.Value == objId)
            {
                return;
            }

            int orderId = Convert.ToInt32(objId);
            DadaOrderRelation remodel = DadaOrderRelationBLL.SingleModel.GetModelOrder(rid, orderId, (int)TmpType.小程序餐饮模板);

            if (remodel == null)
            {
                return;
            }

            DadaOrder dadaOrder = GetModelByOrderNo(remodel.uniqueorderno);

            if (dadaOrder != null)
            {
                order.GetType().GetProperty("dadastate").SetValue(order, dadaOrder.state);
                order.GetType().GetProperty("DadaOrderStateStr").SetValue(order, Enum.GetName(typeof(DadaOrderEnum), dadaOrder.state));
                order.GetType().GetProperty("dadaorderid").SetValue(order, remodel.uniqueorderno);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取餐饮版达达订单状态
        /// </summary>
        /// <param name="list"></param>
        /// <param name="rid"></param>
        /// <returns></returns>
        public void GetFoodDadaOrderState(ref List <FoodAdminGoodsOrder> list, int rid)
        {
            if (list == null || list.Count <= 0)
            {
                return;
            }

            string orderis = string.Join(",", list.Where(w => w.GetWay == (int)miniAppOrderGetWay.达达配送).Select(s => s.Id));

            if (!string.IsNullOrEmpty(orderis))
            {
                List <DadaOrderRelation> relist = DadaOrderRelationBLL.SingleModel.GetListByOrderIds(orderis, (int)TmpType.小程序餐饮模板, rid);
                if (relist == null || relist.Count <= 0)
                {
                    return;
                }

                DadaRelation merchantrelation = DadaRelationBLL.SingleModel.GetModelByRid(rid);
                if (merchantrelation == null)
                {
                    return;
                }

                DadaMerchant merchantmodel = DadaMerchantBLL.SingleModel.GetModel(merchantrelation.merchantid);
                if (merchantmodel == null)
                {
                    return;
                }

                string dadaqids = "'" + string.Join("','", relist.Select(s => s.uniqueorderno)) + "'";
                if (string.IsNullOrEmpty(dadaqids))
                {
                    return;
                }

                List <DadaOrder> dadaorderlist = GetListByQOderId(dadaqids);
                if (dadaorderlist == null || dadaorderlist.Count <= 0)
                {
                    return;
                }

                foreach (FoodAdminGoodsOrder orderitem in list)
                {
                    DadaOrderRelation dadarelation = relist.Where(w => w.orderid == orderitem.Id).FirstOrDefault();
                    if (dadarelation != null)
                    {
                        DadaOrder dadaorder = dadaorderlist.Where(w => w.origin_id == dadarelation.uniqueorderno).FirstOrDefault();
                        if (dadaorder != null)
                        {
                            orderitem.State             = dadaorder.state;
                            orderitem.DadaOrderStateStr = Enum.GetName(typeof(DadaOrderEnum), orderitem.State);
                            orderitem.sourceid          = merchantmodel.sourceid;
                            orderitem.dadaorderid       = dadarelation.uniqueorderno;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取修改达达订单状态sql
        /// </summary>
        /// <param name="orderid">小程序订单表ID</param>
        /// <param name="rid"></param>
        /// <param name="ordertype">看枚举TmpType</param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public string GetDadaOrderUpdateSql(int orderid, int rid, int ordertype, ref TransactionModel tran, bool gettransql = false)
        {
            DadaOrderRelation model = DadaOrderRelationBLL.SingleModel.GetModelOrder(rid, orderid, ordertype);

            if (model == null)
            {
                return("达达配送:没有找到订单关联数据");
            }

            DadaOrder order = GetModelByOrderNo(model.uniqueorderno);

            if (order == null)
            {
                return("达达配送:订单不存在");
            }

            DadaMerchant merchant = DadaMerchantBLL.SingleModel.GetModelByRId(rid);

            if (merchant == null || merchant.id <= 0)
            {
                return("达达配送:找不到商户数据");
            }


            DadaApiReponseModel <ResultReponseModel> result = AddOrder(order, merchant.sourceid, 0);

            if (result == null)
            {
                return("达达配送:新增订单接口异常");
            }
            //log4net.LogHelper.WriteInfo(this.GetType(),JsonConvert.SerializeObject(result));
            if (result.status == "success")
            {
                order.state = (int)DadaOrderEnum.推单中;
                if (gettransql)
                {
                    return(base.ExecuteNonQuery($"update dadaorder set state={order.state} where id={order.id}") > 0?"":"修改达达订单状态出错");
                }
                else
                {
                    tran.Add($"update dadaorder set state={order.state} where id={order.id}");
                }

                return("");
            }

            return(result.msg);
        }
Exemplo n.º 4
0
        public void GetFoodDadaOrderState <T>(ref List <T> list, int rid, int ordertype = (int)TmpType.小程序餐饮模板)
        {
            if (list == null || list.Count <= 0)
            {
                return;
            }
            List <string> orderids = new List <string>();

            foreach (T item in list)
            {
                int sendWay = Convert.ToInt32(item.GetType().GetProperty("GetWay").GetValue(item));
                if (sendWay == (int)miniAppOrderGetWay.达达配送)
                {
                    string orderid = item.GetType().GetProperty("Id").GetValue(item).ToString();
                    orderids.Add(orderid);
                }
            }
            string orderis = string.Join(",", orderids);

            if (!string.IsNullOrEmpty(orderis))
            {
                List <DadaOrderRelation> relist = DadaOrderRelationBLL.SingleModel.GetListByOrderIds(orderis, ordertype, rid);
                if (relist == null || relist.Count <= 0)
                {
                    return;
                }

                DadaRelation merchantrelation = DadaRelationBLL.SingleModel.GetModelByRid(rid);
                if (merchantrelation == null)
                {
                    return;
                }

                DadaMerchant merchantmodel = DadaMerchantBLL.SingleModel.GetModel(merchantrelation.merchantid);
                if (merchantmodel == null)
                {
                    return;
                }

                string dadaqids = "'" + string.Join("','", relist.Select(s => s.uniqueorderno)) + "'";
                if (string.IsNullOrEmpty(dadaqids))
                {
                    return;
                }

                List <DadaOrder> dadaorderlist = GetListByQOderId(dadaqids);
                if (dadaorderlist == null || dadaorderlist.Count <= 0)
                {
                    return;
                }

                foreach (T orderitem in list)
                {
                    int orderid = Convert.ToInt32(orderitem.GetType().GetProperty("Id").GetValue(orderitem).ToString());
                    DadaOrderRelation dadarelation = relist.Where(w => w.orderid == orderid).FirstOrDefault();
                    if (dadarelation != null)
                    {
                        DadaOrder dadaorder = dadaorderlist.Where(w => w.origin_id == dadarelation.uniqueorderno).FirstOrDefault();
                        if (dadaorder != null)
                        {
                            orderitem.GetType().GetProperty("dadastate").SetValue(orderitem, dadaorder.state);
                            orderitem.GetType().GetProperty("DadaOrderStateStr").SetValue(orderitem, Enum.GetName(typeof(DadaOrderEnum), dadaorder.state));
                            orderitem.GetType().GetProperty("sourceid").SetValue(orderitem, merchantmodel.sourceid);
                            orderitem.GetType().GetProperty("dadaorderid").SetValue(orderitem, dadarelation.uniqueorderno);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加达达订单
        /// </summary>
        /// <param name="rid">权限表ID</param>
        /// <param name="userid">用户ID</param>
        /// <param name="orderid">订单ID</param>
        /// <param name="cityname">订单所在城市名</param>
        /// <param name="price">价格(分)</param>
        /// <param name="receivername">收货人姓名</param>
        /// <param name="receivertel">收货人电话</param>
        /// <param name="address">收货地址</param>
        /// <param name="lat">收货地址纬度</param>
        /// <param name="lnt">收货地址经度</param>
        /// <param name="desc">备注</param>
        /// <param name="ordertype">看枚举TmpType</param>
        /// <returns></returns>
        public string AddDadaOrder(DistributionApiModel model)
        {
            string       msg      = "";
            DadaRelation relation = DadaRelationBLL.SingleModel.GetModelByRid(model.aid);

            if (relation != null)
            {
                DadaMerchant merchant = DadaMerchantBLL.SingleModel.GetModel(relation.merchantid);
                if (merchant != null)
                {
                    DadaCity city = DadaCityBLL.SingleModel.GetModelName(model.cityname);
                    if (city == null)
                    {
                        msg = "物流到不了城市" + model.cityname;
                        return(msg);
                    }

                    DadaShop shop = DadaShopBLL.SingleModel.GetModelByMId(merchant.id);
                    if (shop == null)
                    {
                        msg = "物流到不了城市" + model.cityname;
                        return(msg);
                    }

                    TransactionModel tran      = new TransactionModel();
                    string           timestamp = _dadaapi.GetTimeStamp();
                    string           callback  = _dadaapi._ordercallback;
                    string           order_id  = model.userid + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string           shopno    = shop.origin_shop_id;
                    float            buyprice  = model.buyprice / 100.0f;

                    DadaOrder data = new DadaOrder(order_id, city.cityCode, shopno, buyprice, model.accepterName, model.accepterTelePhone, model.address, model.lat, model.lnt, model.remark, timestamp, callback);
                    //data.id = Convert.ToInt32(base.Add(data));
                    tran.Add(base.BuildAddSql(data));

                    DadaOrderRelation orderrelation = new DadaOrderRelation();
                    orderrelation.dataid        = model.aid;
                    orderrelation.orderid       = model.orderid;
                    orderrelation.ordertype     = model.temptype;
                    orderrelation.uniqueorderno = order_id;

                    //orderrelation.id = Convert.ToInt32(DadaOrderRelationBLL.SingleModel.Add(orderrelation));
                    tran.Add(DadaOrderRelationBLL.SingleModel.BuildAddSql(orderrelation));

                    if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray))
                    {
                        msg = "添加达达物流出错";
                    }
                }
                else
                {
                    msg = "找不到商户号";
                }
            }
            else
            {
                msg = "找不到管理表";
            }

            return(msg);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 达达订单状态改变回调接口
        /// </summary>
        /// <param name="orderform"></param>
        /// <returns></returns>
        public ActionResult Dadanotis(OrderReponseModel orderform)
        {
            if (orderform == null)
            {
                LogHelper.WriteInfo(this.GetType(), "达达订单回调请求参数为空");
                return(Content("fail"));
            }

            DadaOrder order = _dadaOrderBLL.GetModelByOrderNo(orderform.order_id);

            if (order == null)
            {
                LogHelper.WriteInfo(this.GetType(), $"达达订单回调:找不到订单【{orderform.order_id}】");
            }
            //如果状态一样,说明已发送过一次
            if (order.state == orderform.order_status)
            {
                return(Content("success"));
            }

            order.state         = orderform.order_status;
            order.update_time   = _dadaApi.GetDateTimeByStamp(orderform.update_time);
            order.cancel_from   = orderform.cancel_from;
            order.cancel_reason = orderform.cancel_reason;
            order.dm_id         = orderform.dm_id;
            order.dm_mobile     = orderform.dm_mobile;
            order.dm_name       = orderform.dm_name;

            DadaOrderRelation oRelationModel = DadaOrderRelationBLL.SingleModel.GetModelUOrderNo(order.origin_id);

            if (oRelationModel == null)
            {
                LogHelper.WriteInfo(this.GetType(), "达达配送回调查询达达订单管理数据出错:" + order.origin_id);
                return(Content("fail"));
            }

            XcxAppAccountRelation xcxrelation = _xcxAppAccountRelationBLL.GetModel(oRelationModel.dataid);

            if (xcxrelation == null)
            {
                LogHelper.WriteInfo(this.GetType(), "达达配送回调查询权限表:没有找到ID【" + oRelationModel.dataid + "】数据");
                return(Content("fail"));
            }

            bool isSuccess = false;

            try
            {
                lock (_dadaLock)
                {
                    switch (oRelationModel.ordertype)
                    {
                    case (int)TmpType.小程序餐饮模板:
                        isSuccess = _dadaOrderBLL.DadaToFoodReturn(oRelationModel.orderid, order, xcxrelation.AppId);
                        break;

                    case (int)TmpType.智慧餐厅:
                        isSuccess = _dadaOrderBLL.DadaToMutilFoodReturn(oRelationModel.orderid, order, xcxrelation.AppId);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteInfo(this.GetType(), "达达配送回调异常:" + JsonConvert.SerializeObject(orderform) + ex.Message);
            }

            return(Content("success"));
        }