예제 #1
0
        public void TestSaveBusData_GetOrder2()
        {
            AliOrderHandle order = new AliOrderHandle();
            string         data  = "{\"AppKey\":\"334362\",\"AppSecret\":\"w5v9Xu2sK2y5\",\"TokenKey\":\"aa3cbd3b-de0c-4779-8596-6724864d7a13\",\"OrderId\":\"271523654409255893\"}";

            order.analyseBussdata("GetOrder2", data);
            string   ret = "";
            FileInfo f   = new FileInfo(@"E:\1688云端\json1.json");

            using (FileStream fs = f.OpenRead())
            {
                int n;
                using (MemoryStream ms = new MemoryStream())
                {
                    byte[] cach = new byte[255];
                    while ((n = fs.Read(cach, 0, cach.Length)) > 0)
                    {
                        ms.Write(cach, 0, n);
                    }
                    ret = System.Text.Encoding.Default.GetString(ms.ToArray());
                    ms.Close();
                }

                fs.Close();
            }

            AliDataAccess ada = new AliDataAccess();

            ada.SaveBusData(order, ret);
        }
예제 #2
0
        public void TestApproveOrder()
        {
            AliOrderHandle order = new AliOrderHandle();
            string         data  = "{ \"AppKey\":\"334362\",\"AppSecret\":\"w5v9Xu2sK2y5\",\"TokenKey\":\"9ee0ac93-0aae-45f5-a671-ca7564280a3a\",\"OrderId\":\"88766926\",\"NgPurId\":\"637018103985963096\",\"Status\":\"dismissed\"}";

            order.analyseBussdata("ApproveOrder", data);
            string  ret = order.Post();
            JObject obj = JsonConvert.DeserializeObject <JObject>(ret);

            Assert.IsTrue(obj.Value <bool>("success"), obj.Value <string>("message"));
        }
예제 #3
0
        public void TestQueryOrderDetail()
        {
            AliOrderHandle order = new AliOrderHandle();
            string         data  = "{ \"AppKey\":\"334362\",\"AppSecret\":\"w5v9Xu2sK2y5\",\"TokenKey\":\"9ee0ac93-0aae-45f5-a671-ca7564280a3a\",\"OrderId\":\"89275019\"}"; //89139200

            order.analyseBussdata("QueryOrderDetail", data);
            string  ret = order.Post();
            JObject obj = JsonConvert.DeserializeObject <JObject>(ret);

            Assert.IsTrue(obj.Value <bool>("success"), obj.Value <string>("message"));
        }
예제 #4
0
        public void TestCreateOrderBySourceId()
        {
            AliOrderHandle order = new AliOrderHandle();
            string         data  = CreateTestOrderFromNg();// "{\"AppKey\":\"334362\",\"AppSecret\":\"w5v9Xu2sK2y5\",\"TokenKey\":\"9ee0ac93-0aae-45f5-a671-ca7564280a3a\",\"CompanyCode\":\"1000\",\"NgPurId\":\"318190821000001\",\"NeedSupplierConfirm\":false,\"NeedInvoice\":false,\"OperatorLoginId\":\"dongyl3333:cg000556\",\"QuoteId\":\"1178451390727\",\"Address\":{\"Address\":\"杭州运河\",\"MobilePhone\":\"15478965258\",\"Phone\":\"\",\"Post\":\"\",\"ReceiverName\":\"123\"},\"Details\":[{\"QuoteDetialId\":\"1580108480727\",\"Qty\":12.0,\"DeliveryDate\":null},{\"QuoteDetialId\":\"1580108490727\",\"Qty\":15.0,\"DeliveryDate\":null}]}";//

            order.analyseBussdata("CreateOrderBySourceId", data);
            string  ret = order.Post();
            JObject obj = JsonConvert.DeserializeObject <JObject>(ret);

            //obj = obj.Value<JObject>("result");
            Assert.IsTrue(obj.Value <bool>("success"), obj.Value <string>("message"));
        }
예제 #5
0
        public void TestCreateProcurementOrder()
        {
            AliOrderHandle order = new AliOrderHandle();
            string         data  = CreateTestOrder();

            order.analyseBussdata("CreateProcurementOrder", data);
            string  ret = order.Post();
            JObject obj = JsonConvert.DeserializeObject <JObject>(ret);

            obj = obj.Value <JObject>("result");
            Assert.IsTrue(obj.Value <bool>("success"), obj.Value <string>("message"));
        }
예제 #6
0
        public object DoBusinessWork(string useServer, object busData, CloudBaseData cloudData)
        {
            object       result = null;
            AliPubHandle handle = null;

            switch (useServer)
            {
            case "GetSubAccountBindingList": //取1688账号与i6p账号绑定清单
            case "BindSubAccount":           //绑定或解绑i6p账号
            case "GetMemberIdsByLoginIds":   //通过列表loginIds查询对应的memberId,批量最大数不要超过110个
            case "GetLoginIdsByMemberIds":   //通过列表memberId查询对应的loginIds,批量最大数不要超过110个
            case "CreateSubAccount":
                handle = new AliAccountHandle();
                break;

            case "GetSupplier":        //取1688供应商信息
            case "UpdateSupplierCode": //更新供应商外部编码,用于将i8系统的编码同步到1688
            case "ImportSuppliers":    //批量导入1688供应商 添加后供应商需完成账号注册并与公司名绑定才能与买家进行线上采购合作
                handle = new AliSupplierHandle();
                break;

            case "PostBuyoffer":   //发布询价单
            case "CloseBuyOffer":  //关闭询价单
            case "GetBuyoffer":    //取1688询价单信息
                handle = new AliBuyofferHandle();
                break;

            case "GetQuotationListByBuyOfferId":    //根据询价id获取询价单的报价信息
                handle = new AliQuotationHandle();
                break;

            case "GetOrder":               //根据订单id获取订单的信息
            case "GetOrder2":
            case "QueryOrderDetail":       //查询采购订单详情
            case "CreateOrder":            //创建询价流程采购单(交易)  需要报价单主键
            case "CreateOrderPayment":     //根据订单创建付款单
            case "CreateProcurementOrder": //创建履约订单
            case "ApproveOrder":           //采购订单审批
            case "CancelOrder":            //取消订单
            case "CreateOrderBySourceId":  //根据来源单据创建订单
                handle = new AliOrderHandle();
                break;

            case "ReceiveOrder":        //确认订单生成收货单
            case "GetOpBulkSettlement": //获取收货单信息
            case "ReceiveGoods":        //履约采购订单创建收货单
            case "QueryReceiveGoods":   ///查询履约采购的收货单
                handle = new AliOpBulkSettlementHandle();
                break;

            case "CreateBulkSettlementImpl": //根据收货单子单id创建结算单
            case "CreateSettlementNote":     //履约采购的结算
            case "QuerySettlementNote":      //履约采购查询结算单
            case "CreatePayNote":            //履约采购通过结算创建付款单
                handle = new AliBulkSettlementImplHandle();
                break;

            case "AddCategory":      //创建1688资源分类
            case "ModifyCategory":   //修改1688资源分类
            case "DelCategory":      //删除1688资源分类
            case "GetCategoryById":  //通过1688主键查找单个资源分类
            case "QueryAllCategory": //查询所有1688资源分类
                handle = new AliCategoryHandle();
                break;

            case "AddProduct":             //创建1688物料
            case "DelProduct":             //根据id删除1688物料
            case "ModifyProduct":          //修改1688物料
            case "QueryProduct":           //分页查询1688物料
            case "QueryProductById":       //根据1688主键查找物料
            case "QueryProductByCodeList": //精确查询产品列表
                handle = new AliProductHandle();
                break;

            case "TestCouldService":
                return(string.Format("云服务通畅;AppKey:{0},Book:{1},IP:{2},Loginer:{3},Rule:{4},TimeStamp:{5}", cloudData.AppKey, cloudData.Book, cloudData.IP, cloudData.Loginer, cloudData.Rule, cloudData.TimeStamp));

            default:
                throw new Exception(string.Format("'{0}' is invalid", useServer));
            }
            string        data = busData.ToString();
            AliDataLog    adl  = new AliDataLog();
            AliDataAccess ada  = new AliDataAccess();

            try
            {
                handle.analyseBussdata(useServer, data);
                result = handle.doPost();
                adl.LogForAliApi(handle, result.ToString(), true);
                ada.SaveBusData(handle, result.ToString());
            }
            catch (Exception e)
            {
                adl.LogForAliApi(handle, "", false, e);
                throw e;
            }

            return(result);
        }