Exemple #1
0
        /// <summary>
        /// 代下单中转
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public static IResultResponse OrderSubmit(SysParameter para)
        {
            try
            {
                int             sellerId     = para.ToInt("FKId");
                int             dbId         = para.ToInt("DBId");
                string          orderInfo    = para.ToValue("Order");
                int             orderId      = para.ToInt("OrderId");
                string          oddNumber    = para.ToValue("OddNumber");
                decimal         downPayables = para.ToDecimal("Payables");
                IResultResponse result       = null;
                if (String.IsNullOrEmpty(orderInfo) && sellerId != 0)
                {
                    return(ResultResponse.ExceptionResult("订单信息为空"));
                }
                RelationMappingEntity relationMappingEntity = new ProductRelationBusiness(para.dapperFactory).GetUpMappingEntity(sellerId, dbId);
                if (relationMappingEntity.GoodsMapping.Count == 0)
                {
                    return(ResultResponse.ExceptionResult("没有找到商品映射关系"));
                }
                //替换供应商ids
                orderInfo = ReplaceIds(relationMappingEntity.ConnectorMapping, orderInfo, "SupplierIds");
                orderInfo = ReplaceIds(relationMappingEntity.ConnectorMapping, orderInfo, "SupplierId");
                //替换商品ids
                orderInfo = ReplaceIds(relationMappingEntity.ProductMapping, orderInfo, "ProductIds");
                //替换productinfo里面的
                orderInfo = ReplaceIds(relationMappingEntity.ProductMapping, orderInfo, "ProductId");
                orderInfo = ReplaceIds(relationMappingEntity.GoodsMapping, orderInfo, "GoodsId");

                //发送
                result = ApiRequest.GetResponse(relationMappingEntity.ConnectorEntity.Domain, "order.dropshipping.submit", new Dictionary <string, string>()
                {
                    { "StoreId", relationMappingEntity.ConnectorEntity.UpBuyerId.ToString() },
                    { "Order", orderInfo }
                });
                if (result.Success)
                {
                    //入库
                    var orderDic = result.Content as Dictionary <string, object>;
                    if (orderDic != null)
                    {
                        new OrderRelationBusiness(para.dapperFactory).Insert(orderId, oddNumber, downPayables, relationMappingEntity.ConnectorEntity, orderDic);
                    }
                    return(ResultResponse.GetSuccessResult(orderId));
                }
                else
                {
                    return(result);
                }
            }
            catch (Exception ex)
            {
                return(ResultResponse.ExceptionResult(ex, 500));
            }
        }