/// <summary> /// 生成UU配送订单 /// </summary> /// <returns></returns> public string AddUUOrder(DistributionApiModel model) { string msg = ""; UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(model.aid, model.storeid, 0); if (customerRelation == null) { msg = "请先配置UU配送"; return(msg); } UUOrderFee feeResult = GetUUFee(model.storeid, model.aid, model.address, ref msg); if (msg.Length > 0) { return(msg); } string orderNum = CommonCore.GetOrderNumByUserId(model.userid.ToString()); string appid = UUApi._appid; string timestamp = UUApi.GetTimestamp(); //店铺信息 ShopInfo shopInfo = GetStoreAddressPoint(customerRelation.AId, customerRelation.StoreId, model.temptype); //生成订单实体类对象 UUOrder data = new UUOrder(appid, timestamp, customerRelation.OpenId, feeResult.price_token, feeResult.total_money, feeResult.need_paymoney, model.accepterName, model.accepterTelePhone, model.remark, UUApi._notisUrl, customerRelation.AId, customerRelation.StoreId, model.temptype, model.ordertype, model.orderid, orderNum); TransactionModel tran = new TransactionModel(); tran.Add(base.BuildAddSql(data)); if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)) { msg = "添加UU配送订单出错"; } return(msg); }
/// <summary> /// 生成快跑者配送订单 /// </summary> /// <param name="rid">权限表ID</param> /// <param name="userinfo">用户信息</param> /// <param name="orderid">订单ID</param> /// <param name="price">订单价格</param> /// <param name="receviename">收货人姓名</param> /// <param name="receviephone">收货人电话</param> /// <param name="address">收货人地址</param> /// <param name="lat">纬度</param> /// <param name="lnt">经度</param> /// <param name="ordertype">看枚举TmpType</param> /// <returns></returns> public string AddKPZOrder(DistributionApiModel model) { string msg = ""; KPZStoreRelation storerelation = KPZStoreRelationBLL.SingleModel.GetModelBySidAndAid(model.aid, model.storeid); if (storerelation == null) { msg = "请先配置快跑者配送"; return(msg); } //再请求一次腾讯地图,获取准确的坐标 AddressApi addressModel = AddressHelper.GetLngAndLatByAddress(model.address); if (addressModel != null && addressModel.result != null && addressModel.result.location != null) { model.lnt = addressModel.result.location.lng; model.lat = addressModel.result.location.lat; } TransactionModel tran = new TransactionModel(); string orderno = CommonCore.GetOrderNumByUserId(model.userid.ToString()); float buyprice = model.buyprice / 100.0f; float payfee = model.fee / 100.0f; int paystatus = 0; //店铺信息 ShopInfo shopinfo = GetStoreAddressPoint(storerelation.AId, storerelation.StoreId, model.temptype); //生成订单实体类对象 KPZOrder data = new KPZOrder(storerelation.Id, shopinfo.ShopName, storerelation.TelePhone, shopinfo.ShopAddress, shopinfo.ShopTag, model.ordercontent, model.remark, orderno, model.accepterName, model.accepterTelePhone, model.address, model.lnt + "," + model.lat, buyprice, buyprice, paystatus, payfee, model.orderid, model.aid, model.temptype, model.storeid); tran.Add(base.BuildAddSql(data)); if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)) { msg = "添加快跑者配送订单出错"; } return(msg); }
public static KPZResult <T> KPZRequest <T>(string apiUrl, Dictionary <string, string> param, string type = "post") { KPZResult <T> dataResult = new KPZResult <T>(); string url = _host + apiUrl; string result = ""; try { switch (type) { case "post": string json = SortParamString(param); result = CommonCore.HttpPost(url, json); break; case "get": url += SortParamString(param); result = HttpHelper.GetData(url); break; } KPZResult <object> tempResult = JsonConvert.DeserializeObject <KPZResult <object> >(result); if (tempResult.code == 200) { dataResult = JsonConvert.DeserializeObject <KPZResult <T> >(result); } else { dataResult.code = tempResult.code; dataResult.message = tempResult.message; } } catch (Exception ex) { log4net.LogHelper.WriteInfo(typeof(KPZApi), $"快跑者接口请求异常:{ex.Message},result={result}"); } return(dataResult); }
/// <summary> /// 小程序登陆通过个人获取sessionkey /// </summary> /// <param name="js_code"></param> /// <param name="appid"></param> /// <param name="msg"></param> /// <returns></returns> public UserSession GetAppSessionInfoByAppsr(string js_code, string appid, ref string msg) { UserSession session = new UserSession(); UserXcxTemplate userXcxModel = UserXcxTemplateBLL.SingleModel.GetModelByAppId(appid); if (userXcxModel == null || string.IsNullOrEmpty(userXcxModel.Appsr)) { msg = "密钥不能为空"; return(session); } string url = Jscode2sessionUrl(appid, js_code, userXcxModel.Appsr); string resultJson = CommonCore.HttpGet(url); if (string.IsNullOrEmpty(resultJson)) { msg = "获取小程序sessionkey返回值为空"; return(session); } session = JsonConvert.DeserializeObject <UserSession>(resultJson); if (session.errcode == "40029") { msg = "不可用的code,原因是开发工具添加项目时填写的appid跟app.js里的appid不一致"; return(session); } if (session.errcode == "40125") { msg = "不可用的秘钥,原因是手动发布的小程序后台没有保存秘钥,或者秘钥被重置过不可"; return(session); } if (string.IsNullOrEmpty(session.session_key)) { msg = "登陆失败,获取sessionkey失败"; } return(session); }
/// <summary> /// 生成订单 /// </summary> /// <param name="appid"></param> /// <param name="openid"></param> /// <param name="goodCarIdStr">购物车ID集合字符串:格式为(id1,id2)</param> /// <param name="order"></param> /// <returns></returns> public string AddOrder(int userId, string jsonData, ref TransactionModel tran, ref object orderObj, int orderType) { string msg = ""; //基本验证 QiyeGoodsOrder postData = new QiyeGoodsOrder(); C_UserInfo userInfo = new C_UserInfo(); List <QiyeGoodsCart> cartList = new List <QiyeGoodsCart>(); XcxAppAccountRelation xcxRelation = new XcxAppAccountRelation(); WxAddress address = new WxAddress(); QiyeStore store = new QiyeStore(); CheckBaseData(jsonData, userId, ref postData, ref userInfo, ref cartList, ref xcxRelation, ref address, ref store, ref msg, orderType); if (msg.Length > 0) { return(msg); } //检测库存 CheckGoods(cartList, ref msg); if (msg.Length > 0) { return(msg); } //优惠价格处理 int afterDiscountPrice = 0; int beforeDiscountPrice = 0; int vipDiscountPrice = 0; int couponPrice = 0; DiscountPrice(postData.CouponLogId, ref cartList, userInfo.Id, ref beforeDiscountPrice, ref afterDiscountPrice, ref vipDiscountPrice, ref couponPrice, ref msg); if (msg.Length > 0) { return(msg); } if (afterDiscountPrice > 999999999) { return("商品价格有误"); } //运费 int friPrice = GetFreight(store, cartList, postData.GetWay, postData.CartIds, store.Aid, address, ref msg); if (msg.Length > 0) { return(msg); } //订单 QiyeGoodsOrder order = new QiyeGoodsOrder(); order.AccepterName = postData.AccepterName; order.AccepterTelePhone = postData.AccepterTelePhone; order.ZipCode = address.postalCode; order.Address = postData.Address; order.Message = postData.Message; order.TemplateType = (int)TmpType.企业智推版; order.StoreId = store.Id; order.UserId = userInfo.Id; order.AddTime = DateTime.Now; order.AId = xcxRelation.Id; order.QtyCount = cartList.Sum(x => x.Count); order.BuyMode = postData.BuyMode; order.GetWay = postData.GetWay; order.AppId = userInfo.appId; order.SumPrice = beforeDiscountPrice; order.VipReducedPrice = vipDiscountPrice; order.ReducedPrice = beforeDiscountPrice - afterDiscountPrice; order.FreightPrice = friPrice; order.CouponPrice = couponPrice; order.BuyPrice = afterDiscountPrice + friPrice; order.BuyPrice = order.BuyPrice <= 0 ? 0 : order.BuyPrice; order.OrderNum = CommonCore.CreateOrderNum(cartList[0].Id.ToString()); if (order.BuyMode == (int)miniAppBuyMode.微信支付) { order.State = (int)QiyeOrderState.待付款; switch (order.GetWay) { case (int)miniAppOrderGetWay.到店自取: //4位随机取物码 System.Random Random = new System.Random(); order.LadingCode = Random.Next(0, 9999).ToString("0000"); break; } } else if (order.BuyMode == (int)miniAppBuyMode.储值支付) { order.PayTime = DateTime.Now; switch (order.GetWay) { case (int)miniAppOrderGetWay.到店自取: order.State = (int)QiyeOrderState.待自取; //4位随机取物码 System.Random Random = new System.Random(); order.LadingCode = Random.Next(0, 9999).ToString("0000"); break; case (int)miniAppOrderGetWay.商家配送: order.State = (int)QiyeOrderState.待发货; break; } } //新增订单sql tran.Add(Utils.BuildAddSqlS(order, "OrderId", "(select LAST_INSERT_ID())", base.TableName, base.arrProperty)); //修改优惠券状态 if (postData.CouponLogId > 0) { tran.Add($" update CouponLog set OrderId = (select last_insert_id()),State = 1 where id ={postData.CouponLogId}"); } //tran.Add(base.BuildAddSql(order)); //修改购物车订单 foreach (QiyeGoodsCart cartitem in cartList) { tran.Add($" update QiyeGoodsCart set OrderId = (select last_insert_id()),State = 1,Discount = {cartitem.Discount},price={cartitem.Price},OriginalPrice={cartitem.OriginalPrice} where id ={cartitem.Id} and state = 0; "); } //修改库存 UpdateGoodsStock(cartList, ref tran, ref msg, true); orderObj = order; return(msg); }