/// <summary> /// 跟进 退款状态 (退款是否成功) /// </summary> /// <returns></returns> public void StartOutOrderStateServer() { TransactionModel tranModel = new TransactionModel(); string sql = $@"select eo.*,r.result_code as refundcode from QiyeGoodsOrder eo left join citymorders co on eo.orderid = co.id left join ReFundResult r on r.transaction_id = co.trade_no where eo.State in ({(int)QiyeOrderState.退款中}) and eo.RefundTime <= (NOW() - interval 17 second) and eo.BuyMode = 1";//and r.result_code = 'SUCCESS' ,{(int)QiyeOrderState.退款失败} using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sql, null)) { while (dr.Read()) { QiyeGoodsOrder model = base.GetModel(dr); if (dr["refundcode"].ToString() == "SUCCESS") { model.State = (int)QiyeOrderState.退款成功; if (base.Update(model, "state")) { //发给用户退款成功通知 object orderData = TemplateMsg_Miniapp.QiyeGetTemplateMessageData(model, SendTemplateMessageTypeEnum.企业智推版订单退款通知); TemplateMsg_Miniapp.SendTemplateMessage(model.UserId, SendTemplateMessageTypeEnum.企业智推版订单退款通知, TmpType.企业智推版, orderData); } } else { model.State = (int)QiyeOrderState.退款失败; base.Update(model, "state"); } } } }
/// <summary> /// 发起退款 /// </summary> /// <returns></returns> public ActionResult OutOrder() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } var appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel($"id ={appId}"); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } int storeId = Context.GetRequestInt("storeid", -1); if (storeId < 0) { return(Json(new { isok = false, msg = "系统繁忙storeId_null" })); } string storeSqlwhere = $"appid={appId}"; if (storeId > 0) { storeSqlwhere = $"id={storeId}"; } FootBath storeModel = FootBathBLL.SingleModel.GetModel(storeSqlwhere); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } int orderId = Context.GetRequestInt("orderId", 0); if (orderId <= 0) { return(Json(new { isok = false, msg = "系统繁忙orderId_null" })); } EntGoodsOrder orderInfo = EntGoodsOrderBLL.SingleModel.GetModel($"aId={storeModel.appId} and id={orderId}"); if (orderInfo == null) { return(Json(new { isok = false, msg = "系统繁忙order_null" })); } List <EntGoodsCart> goodscarts = EntGoodsCartBLL.SingleModel.GetList($"GoodsOrderId={orderInfo.Id}"); bool isok = EntGoodsOrderBLL.SingleModel.outOrder(goodscarts, storeModel, orderInfo); string msg = "操作失败"; if (isok) { msg = "操作成功"; var data = TemplateMsg_Miniapp.MutilStoreGetTemplateMessageData(orderInfo, SendTemplateMessageTypeEnum.多门店退款通知); TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, SendTemplateMessageTypeEnum.多门店退款通知, TmpType.小程序多门店模板, data); } return(Json(new { isok = isok, msg = msg })); }
/// <summary> /// 订单取消发送订单取消通知模板消息 /// </summary> /// <param name="pinOrder"></param> public void SendTemplateMsg_PayCancel(PinGoodsOrder pinOrder) { PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(pinOrder.aid, pinOrder.storeId); if (store == null && pinOrder.orderType == 0) { log4net.LogHelper.WriteError(GetType(), new Exception($"拼享惠发送订单取消模板消息失败,找不到店铺信息 aid:{pinOrder.aid}, storeid:{pinOrder.storeId}")); return; } //如果未支付,获取预支付码的formid是无效的,要取消 if (pinOrder.payState == (int)PayState.未付款) { C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(pinOrder.userId); if (userInfo == null) { log4net.LogHelper.WriteError(GetType(), new Exception($"拼享惠发送订单取消模板消息失败,找不到用户信息 userid:{pinOrder.userId}")); return; } TemplateMsg_UserParam userParam = TemplateMsg_UserParamBLL.SingleModel.GetModel($" Form_Id is not null and appId = '{userInfo.appId}' and Open_Id = '{userInfo.OpenId}' and State = 1 and LoseDateTime > now() and orderId={pinOrder.id} "); if (userParam != null) { userParam.State = -1; TemplateMsg_UserParamBLL.SingleModel.Update(userParam, "state"); } } //发给用户通知 object orderData = TemplateMsg_Miniapp.PinGetTemplateMessageData(SendTemplateMessageTypeEnum.拼享惠订单取消通知, order: pinOrder, store: store); TemplateMsg_Miniapp.SendTemplateMessage(pinOrder.userId, SendTemplateMessageTypeEnum.拼享惠订单取消通知, TmpType.拼享惠, orderData, $"pages/shopping/orderInfo/orderInfo?orderid={pinOrder.id}&storeid={pinOrder.storeId}"); }
/// <summary> /// 储值支付 /// </summary> /// <param name="orderObj"></param> /// <param name="order"></param> /// <param name="aid"></param> /// <param name="saveMoneyUser"></param> /// <param name="sbUpdateGoodCartSql"></param> /// <param name="reductionCart"></param> /// <param name="orderId"></param> /// <returns></returns> public object PayOrderByChuzhi(object orderObj, int aid, SaveMoneySetUser saveMoneyUser, TransactionModel tran, ref int orderId) { QiyeGoodsOrder order = (QiyeGoodsOrder)orderObj; //储值支付 扣除预存款金额并生成消费记录 //添加储值日志 SaveMoneySetUserLog userLog = new SaveMoneySetUserLog() { AppId = saveMoneyUser.AppId, UserId = order.UserId, MoneySetUserId = saveMoneyUser.Id, Type = -1, BeforeMoney = saveMoneyUser.AccountMoney, AfterMoney = saveMoneyUser.AccountMoney - order.BuyPrice, ChangeMoney = order.BuyPrice, ChangeNote = $" 购买商品,订单号:{order.OrderNum} ", CreateDate = DateTime.Now, State = 1, AId = order.AId, }; tran.Add(Utils.BuildAddSqlS(userLog, "OrderId", "(select LAST_INSERT_ID())", SaveMoneySetUserLogBLL.SingleModel.TableName, SaveMoneySetUserLogBLL.SingleModel.arrProperty)); //储值扣费 tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney - {order.BuyPrice} where id = {saveMoneyUser.Id} ; "); if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)) { log4net.LogHelper.WriteInfo(this.GetType(), "储值支付:操作失败" + Newtonsoft.Json.JsonConvert.SerializeObject(tran)); return(""); } QiyeStore store = QiyeStoreBLL.SingleModel.GetModel(order.StoreId); if (store != null) { //清除商品缓存 QiyeGoodsBLL.SingleModel.RemoveEntGoodListCache(store.Aid); } orderId = 1; order = GetModelByOrderNum(order.OrderNum); if (order == null) { log4net.LogHelper.WriteInfo(this.GetType(), "储值支付:生成订单失败"); return(""); } //发送支付成功通知给用户 object orderData = TemplateMsg_Miniapp.QiyeGetTemplateMessageData(order, SendTemplateMessageTypeEnum.企业智推版订单支付成功通知); TemplateMsg_Miniapp.SendTemplateMessage(order.UserId, SendTemplateMessageTypeEnum.企业智推版订单支付成功通知, TmpType.企业智推版, orderData); //发送支付成功公众号通知给商家 TemplateMsg_Gzh.SendQiyePaySuccessTemplateMessage(order); return(new { postdata = order.OrderNum, orderid = 0, dbOrder = order.Id }); }
/// <summary> /// 发货 /// </summary> /// <param name="order"></param> /// <param name="msg"></param> public void SendGoods(QiyeGoodsOrder order, string attachData, ref string msg) { bool success = false; if (string.IsNullOrWhiteSpace(attachData)) { msg = "发货:物流信息不能为空"; return; } order.State = (int)QiyeOrderState.待收货; order.SendTime = DateTime.Now; //保存物流信息 DeliveryUpdatePost deliveryInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <DeliveryUpdatePost>(attachData); bool isCompleteInfo = (deliveryInfo.SelfDelivery || (!string.IsNullOrWhiteSpace(deliveryInfo.CompanyCode) && !string.IsNullOrWhiteSpace(deliveryInfo.DeliveryNo))) && !string.IsNullOrWhiteSpace(deliveryInfo.ContactName) && !string.IsNullOrWhiteSpace(deliveryInfo.ContactTel) && !string.IsNullOrWhiteSpace(deliveryInfo.Address); //物流配送 if (!deliveryInfo.SelfDelivery) { if (string.IsNullOrWhiteSpace(deliveryInfo.CompanyCode) || string.IsNullOrWhiteSpace(deliveryInfo.DeliveryNo) || string.IsNullOrWhiteSpace(deliveryInfo.ContactName) || string.IsNullOrWhiteSpace(deliveryInfo.ContactTel) || string.IsNullOrWhiteSpace(deliveryInfo.Address)) { msg = "发货:物流信息不完整"; return; } success = DeliveryFeedbackBLL.SingleModel.AddPlatOrderFeed(order.Id, deliveryInfo) && base.Update(order, "state,SendTime"); } else { if (string.IsNullOrWhiteSpace(deliveryInfo.ContactName) || string.IsNullOrWhiteSpace(deliveryInfo.ContactTel) || string.IsNullOrWhiteSpace(deliveryInfo.Address)) { msg = "发货:商家自配信息不完整"; return; } order.AccepterName = deliveryInfo.ContactName; order.AccepterTelePhone = deliveryInfo.ContactTel; order.Address = deliveryInfo.Address; order.Remark = deliveryInfo.Remark; success = base.Update(order, "state,SendTime,AccepterName,AccepterTelePhone,Address,Remark"); } if (success) { //发给用户取消通知 object orderData = TemplateMsg_Miniapp.QiyeGetTemplateMessageData(order, SendTemplateMessageTypeEnum.企业智推版订单发货提醒); TemplateMsg_Miniapp.SendTemplateMessage(order.UserId, SendTemplateMessageTypeEnum.企业智推版订单发货提醒, TmpType.企业智推版, orderData); } else { msg = "发货:操作失败"; } }
/// <summary> /// 发送预约模板消息 /// </summary> /// <param name="reservation"></param> /// <param name="msgState">模板消息状态(接单、退款、取消)</param> /// <param name="tmpType">模板消息类型(专业版、餐饮版)</param> /// <param name="refundOrder">退款订单(仅退款消息需要)</param> /// <param name="refundEntOrder">退款订单(仅退款消息需要)</param> /// <returns></returns> public bool SendReserveMsg(FoodReservation reservation, SendTemplateMessageTypeEnum msgState, TmpType tmpType, EntGoodsOrder refundEntOrder = null, FoodGoodsOrder refundOrder = null) { //发送小程序模板消息给用户 object orderData = TemplateMsg_Miniapp.GetReservationTempMsgData(reservation, msgState, refundOrder: refundOrder, refundEntOrder: refundEntOrder); if (orderData == null) { return(false); } TemplateMsg_Miniapp.SendTemplateMessage(reservation.UserId, msgState, (int)tmpType, orderData); return(true); }
/// <summary> /// 开单 /// </summary> /// <returns></returns> public ActionResult createOrder() { #region 数据验证 int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } int orderId = Context.GetRequestInt("orderId", 0); if (orderId <= 0) { return(Json(new { isok = false, msg = "系统繁忙orderId_null" })); } EntGoodsOrder orderInfo = EntGoodsOrderBLL.SingleModel.GetModelByOrderIdAndAid(orderId, appId, 1); if (orderInfo == null) { return(Json(new { isok = false, msg = "系统繁忙order_null" })); } #endregion if (orderInfo.State == (int)MiniAppEntOrderState.已超时) { orderInfo.State = (int)MiniAppEntOrderState.务中; } orderInfo.OrderType = 0; orderInfo.ConfDate = DateTime.Now; bool isok = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,ordertype,ConfDate") && VipRelationBLL.SingleModel.updatelevel(orderInfo.UserId, "footbath"); #region 预约成功通知 模板消息 if (isok) { object objData = TemplateMsg_Miniapp.FootbathGetTemplateMessageData(orderInfo, SendTemplateMessageTypeEnum.足浴预约成功通知); TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, SendTemplateMessageTypeEnum.足浴预约成功通知, TmpType.小程序足浴模板, objData); } #endregion string msg = isok ? "操作成功" : "操作失败"; return(Json(new { isok = isok, msg = msg })); }
/// <summary> /// 订单配送通知模板消息 /// </summary> /// <param name="pinOrder"></param> public void SendTemplateMsg_Send(PinGoodsOrder pinOrder) { PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(pinOrder.aid, pinOrder.storeId); if (store == null && pinOrder.orderType == 0) { log4net.LogHelper.WriteError(GetType(), new Exception($"拼享惠订单配送模板消息失败,找不到店铺信息 aid:{pinOrder.aid}, storeid:{pinOrder.storeId}")); return; } //发给用户通知 object orderData = TemplateMsg_Miniapp.PinGetTemplateMessageData(SendTemplateMessageTypeEnum.拼享惠订单配送通知, order: pinOrder, store: store); TemplateMsg_Miniapp.SendTemplateMessage(pinOrder.userId, SendTemplateMessageTypeEnum.拼享惠订单配送通知, TmpType.拼享惠, orderData, $"pages/shopping/orderInfo/orderInfo?orderid={pinOrder.id}&storeid={pinOrder.storeId}"); }
/// <summary> /// 指定时间内未支付 取消订单变为已经关闭 /// </summary> /// <param name="timeoutlength"></param> public void updateOrderStateForCancle(int timeoutlength = -1) { TransactionModel tranModel = new TransactionModel(); //找出15分钟内未支付的订单 tranModel = new TransactionModel(); //从参与砍价商品领取记录里筛选已经生成订单并且1小时未支付的的订单 List <BargainUser> orderList = GetList($"(State=0 or State=5) and CreateOrderTime <= (NOW()+INTERVAL {timeoutlength} HOUR) and CreateOrderTime!='0001-01-01 00:00:00'"); if (orderList != null && orderList.Count > 0) { //找出需要增加库存的砍价商品 List <Bargain> goodlist = BargainBLL.SingleModel.GetList($"Id in ({string.Join(",", orderList.Select(s => s.BId).Distinct())})"); if (goodlist != null && goodlist.Count > 0) { foreach (var item in orderList) { BargainUser _BargainUser = item; _BargainUser.State = -1;//订单超过时间未支付 Bargain Bargain = goodlist.Where(x => x.Id == _BargainUser.BId).FirstOrDefault(); Bargain.RemainNum++;//库存加1 tranModel.Add(BuildUpdateSql(_BargainUser, "State")); tranModel.Add(BargainBLL.SingleModel.BuildUpdateSql(Bargain, "RemainNum")); //事务内某行sql执行受影响行数为0,会回滚整个事务 if (ExecuteTransactionDataCorect(tranModel.sqlArray)) { log4net.LogHelper.WriteInfo(GetType(), item.Id + "CityMorders订单超过15分钟未支付取消成功"); } else { log4net.LogHelper.WriteInfo(GetType(), item.Id + "CityMorders订单超过15分钟未支付取消失败"); } #region 发送 砍价订单取消通知 模板消息 => 通知用户 object orderData = TemplateMsg_Miniapp.BargainGetTemplateMessageData(item, SendTemplateMessageTypeEnum.价订单取消通知); TemplateMsg_Miniapp.SendTemplateMessage(item, SendTemplateMessageTypeEnum.价订单取消通知, orderData); #endregion 发送 砍价订单取消通知 模板消息 => 通知用户 } } } }
/// <summary> /// 取消订单 /// </summary> /// <param name="order"></param> /// <param name="msg"></param> public void CancelOrder(QiyeGoodsOrder order, ref string msg) { if (order == null) { msg = "取消订单:找不到订单"; return; } order.State = (int)QiyeOrderState.已取消; TransactionModel tranModel = new TransactionModel(); tranModel.Add($"update QiyeGoodsOrder set state={order.State} where id={order.Id}"); //订单明细 List <QiyeGoodsCart> cartlist = QiyeGoodsCartBLL.SingleModel.GetListByOrderIds(order.Id.ToString()); if (cartlist == null || cartlist.Count <= 0) { msg = "取消订单:找不到订单明细"; return; } //更改库存 UpdateGoodsStock(cartlist, ref tranModel, ref msg, true, true); if (msg.Length > 0) { return; } if (tranModel == null || tranModel.sqlArray.Count() <= 0) { msg = "取消订单:无效执行"; return; } if (ExecuteTransactionDataCorect(tranModel.sqlArray, tranModel.ParameterArray)) { //清除商品缓存 QiyeGoodsBLL.SingleModel.RemoveEntGoodListCache(order.AId); //发给用户取消通知 object orderData = TemplateMsg_Miniapp.QiyeGetTemplateMessageData(order, SendTemplateMessageTypeEnum.企业智推版订单取消通知); TemplateMsg_Miniapp.SendTemplateMessage(order.UserId, SendTemplateMessageTypeEnum.企业智推版订单取消通知, TmpType.企业智推版, orderData); } else { msg = "取消订单:操作失败"; return; } }
public ActionResult SendComplaintResult(int aid, int id = 0, string resultMsg = "") { if (aid <= 0 || id <= 0) { result.msg = "参数错误"; return(Json(result)); } if (string.IsNullOrEmpty(resultMsg)) { result.msg = "处理结果不能为空"; return(Json(result)); } if (resultMsg.Length > 100) { result.msg = "处理结果不能超过100字"; return(Json(result)); } PinComplaint complaint = PinComplaintBLL.SingleModel.GetModelByAid_Id(aid, id); if (complaint == null) { result.msg = "申诉不存在"; return(Json(result)); } complaint.state = (int)ComplaintState.已处理; complaint.result = resultMsg; if (PinComplaintBLL.SingleModel.Update(complaint, "state,result")) { result.code = 1; //发给用户通知 object orderData = TemplateMsg_Miniapp.PinGetTemplateMessageData(SendTemplateMessageTypeEnum.拼享惠发送申诉结果通知, complaint); TemplateMsg_Miniapp.SendTemplateMessage(complaint.userId, SendTemplateMessageTypeEnum.拼享惠发送申诉结果通知, TmpType.拼享惠, orderData); result.msg = "发送成功"; } else { result.msg = "发送失败"; } return(Json(result)); }
public void AddRecordLog(DishVipCard card, double account_money, string account_info) { DishCardAccountLog log = new DishCardAccountLog(); log.account_money = account_money; log.account_info = string.IsNullOrEmpty(account_info) ? "手动充值" : $"手动充值:{account_info}"; log.account_type = 1; log.add_time = DateTime.Now; log.aId = card.aid; log.shop_id = card.shop_id; log.user_id = card.uid; log.state = 1; Add(log); //发 充值成功通知 模板消息 DishStore store = DishStoreBLL.SingleModel.GetModelByAid_Id(card.aid, card.shop_id); object curSortQueue_TemplateMsgObj = TemplateMsg_Miniapp.DishMessageData(store.dish_name, card, log, log.account_money, SendTemplateMessageTypeEnum.充值成功通知); TemplateMsg_Miniapp.SendTemplateMessage(log.user_id, SendTemplateMessageTypeEnum.充值成功通知, (int)TmpType.智慧餐厅, curSortQueue_TemplateMsgObj, $"pages/restaurant/restaurant-card/index?dish_id={log.shop_id}&savemoney=0"); }
public ActionResult SendGoods(int appId, int id, string storeremark) { GroupUser groupuser = GroupUserBLL.SingleModel.GetModel(id); if (groupuser == null) { return(Json(new { isok = -1, msg = "团购信息异常 , 请刷新页面后重试" }, JsonRequestBehavior.AllowGet)); } if (groupuser.State != (int)MiniappPayState.待发货) { return(Json(new { isok = -1, msg = "此团购信息异常,请刷新后重试" }, JsonRequestBehavior.AllowGet)); } groupuser.State = (int)MiniappPayState.已发货; groupuser.SendGoodTime = DateTime.Now; groupuser.StorerRemark = storeremark; if (!GroupUserBLL.SingleModel.Update(groupuser)) { return(Json(new { isok = -1, msg = "发货失败" }, JsonRequestBehavior.AllowGet)); } XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(groupuser.AppId); if (xcx == null) { log4net.LogHelper.WriteError(GetType(), new Exception($"发送模板消息,参数不足,XcxAppAccountRelation_null:appId = {groupuser.AppId}")); return(Json(new { isok = 1, msg = "发货成功" }, JsonRequestBehavior.AllowGet)); } //发给用户发货通知 object groupData = TemplateMsg_Miniapp.GroupGetTemplateMessageData(string.Empty, groupuser, SendTemplateMessageTypeEnum.拼团基础版订单发货提醒); TemplateMsg_Miniapp.SendTemplateMessage(groupuser.ObtainUserId, SendTemplateMessageTypeEnum.拼团基础版订单发货提醒, xcx.Type, groupData); return(Json(new { isok = 1, msg = "发货成功" }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 修改订单状态 /// </summary> /// <returns></returns> public ActionResult updateState() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } var appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel($"id ={appId}"); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } int storeId = Context.GetRequestInt("storeid", -1); if (storeId < 0) { return(Json(new { isok = false, msg = "系统繁忙storeId_null" })); } string storeSqlwhere = $"appid={appId}"; if (storeId > 0) { storeSqlwhere = $"id={storeId}"; } FootBath storeModel = FootBathBLL.SingleModel.GetModel(storeSqlwhere); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } string msg = "操作失败"; bool isok = false; int state = Context.GetRequestInt("state", -999); int orderId = Context.GetRequestInt("id", 0); if (orderId <= 0) { return(Json(new { isok = false, msg = "系统繁忙orderId_null" })); } EntGoodsOrder orderInfo = EntGoodsOrderBLL.SingleModel.GetModel($"aId={appId} and id={orderId}"); if (orderInfo == null) { return(Json(new { isok = false, msg = "系统繁忙order_null" })); } SendTemplateMessageTypeEnum templateType = new SendTemplateMessageTypeEnum(); switch (state) { case (int)MiniAppEntOrderState.已取消: templateType = SendTemplateMessageTypeEnum.多门店订单取消通知; orderInfo.State = (int)MiniAppEntOrderState.已取消; break; case (int)MiniAppEntOrderState.待接单: templateType = SendTemplateMessageTypeEnum.多门店反馈处理结果通知; orderInfo.State = (int)MiniAppEntOrderState.待接单; break; case (int)MiniAppEntOrderState.待配送: templateType = SendTemplateMessageTypeEnum.多门店订单确认通知; orderInfo.State = (int)MiniAppEntOrderState.待配送; break; case (int)MiniAppEntOrderState.待确认送达: templateType = SendTemplateMessageTypeEnum.多门店订单配送通知; orderInfo.State = (int)MiniAppEntOrderState.待确认送达; break; case (int)MiniAppEntOrderState.交易成功: if (orderInfo.GetWay == (int)multiStoreOrderType.城配送) { templateType = SendTemplateMessageTypeEnum.多门店订单配送通知; } orderInfo.AcceptDate = DateTime.Now; orderInfo.State = (int)MiniAppEntOrderState.交易成功; break; case (int)MiniAppEntOrderState.待收货: templateType = SendTemplateMessageTypeEnum.多门店订单发货提醒; orderInfo.State = (int)MiniAppEntOrderState.待收货; break; } isok = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "state,AcceptDate"); if (isok) { if (state == (int)MiniAppEntOrderState.交易成功) { VipRelationBLL.SingleModel.updatelevel(orderInfo.UserId, "multistore"); } msg = "操作成功"; var data = TemplateMsg_Miniapp.MutilStoreGetTemplateMessageData(orderInfo, templateType); TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, templateType, TmpType.小程序多门店模板, data); } return(Json(new { isok = isok, msg = msg })); }
/// <summary> /// 处理餐饮达达配送回调 /// </summary> /// <param name="orderid"></param> /// <param name="state"></param> /// <returns></returns> public bool DadaToFoodReturn(int orderid, DadaOrder order, string appid) { bool isSuccess = false; string updatesql = "state,update_time"; FoodGoodsOrder foodGoodOrder = FoodGoodsOrderBLL.SingleModel.GetModel(orderid);// and OrderType ={(int)miniAppFoodOrderType.店内点餐 } "); if (foodGoodOrder == null) { LogHelper.WriteInfo(this.GetType(), "达达配送:找不到订单"); return(isSuccess); } string msg = string.Empty; switch (order.state) { case (int)DadaOrderEnum.已取消: if (order.state == (int)DadaOrderEnum.已取消) { updatesql += ",cancel_from,cancel_reason"; } isSuccess = base.Update(order, updatesql); if (!isSuccess) { LogHelper.WriteInfo(this.GetType(), "达达配送回调修改系统订单状态出错:" + JsonConvert.SerializeObject(order)); return(isSuccess); } //退款接口 abel //判断是否是取消订单,取消订单则要执行退款 if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.微信支付) { isSuccess = FoodGoodsOrderBLL.SingleModel.outOrder(foodGoodOrder, foodGoodOrder.State); } else if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.储值支付) { var userSaveMoney = SaveMoneySetUserBLL.SingleModel.getModelByUserId(foodGoodOrder.UserId) ?? new SaveMoneySetUser(); isSuccess = FoodGoodsOrderBLL.SingleModel.outOrderBySaveMoneyUser(foodGoodOrder, userSaveMoney, foodGoodOrder.State); } #region 餐饮退款成功通知 模板消息 if (isSuccess) { var postData2 = FoodGoodsOrderBLL.SingleModel.getTemplateMessageData(foodGoodOrder.Id, SendTemplateMessageTypeEnum.餐饮退款成功通知); TemplateMsg_Miniapp.SendTemplateMessage(foodGoodOrder.UserId, SendTemplateMessageTypeEnum.餐饮退款成功通知, (int)TmpType.小程序餐饮模板, postData2); } #endregion return(isSuccess); case (int)DadaOrderEnum.待接单: foodGoodOrder.State = (int)miniAppFoodOrderState.待接单; break; case (int)DadaOrderEnum.待取货: updatesql += ",dm_id,dm_name,dm_mobile"; foodGoodOrder.State = (int)miniAppFoodOrderState.待送餐; //object groupData = TemplateMsg_Miniapp.DadaGetTemplateMessageData(order,foodGoodOrder.PayDate,foodGoodOrder.BuyMode,"", SendTemplateMessageTypeEnum.达达配送接单通知); #region 发送餐饮订单配送通知 模板消息 C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModel(foodGoodOrder.UserId) ?? new C_UserInfo(); object postData = FoodGoodsOrderBLL.SingleModel.getTemplateMessageData(foodGoodOrder.Id, SendTemplateMessageTypeEnum.餐饮订单配送通知); TemplateMsg_Miniapp.SendTemplateMessage(userinfo.Id, SendTemplateMessageTypeEnum.餐饮订单配送通知, (int)TmpType.小程序餐饮模板, postData); #endregion break; case (int)DadaOrderEnum.配送中: foodGoodOrder.State = (int)miniAppFoodOrderState.待确认送达; break; case (int)DadaOrderEnum.已完成: foodGoodOrder.State = (int)miniAppFoodOrderState.已完成; break; case (int)DadaOrderEnum.已过期: case (int)DadaOrderEnum.系统故障订单发布失败: case (int)DadaOrderEnum.妥投异常之物品返回完成: foodGoodOrder.State = (int)miniAppFoodOrderState.退款审核中; updatesql += ",cancel_from,cancel_reason"; break; } isSuccess = base.Update(order, updatesql); if (!isSuccess) { LogHelper.WriteInfo(this.GetType(), "达达配送回调修改系统订单状态出错:" + JsonConvert.SerializeObject(order)); return(isSuccess); } isSuccess = FoodGoodsOrderBLL.SingleModel.Update(foodGoodOrder, "State"); return(isSuccess); }
/// <summary> /// 拼团退款 /// </summary> /// <param name="item"></param> /// <param name="type">0:拼团失败退款,1:店主手动退款</param> /// <returns></returns> public bool GroupReFundQueue(GroupUser item, ref string msg, int type = 0) { //0:微信支付,1:储值卡支付 int paytype = item.PayType; TransactionModel tranmodel = new TransactionModel(); Groups csg = GroupsBLL.SingleModel.GetModel(item.GroupId); if (csg == null) { msg = "小程序拼团商品不存在啦=" + item.GroupId; item.State = (int)MiniappPayState.已失效; GroupUserBLL.SingleModel.Update(item, "State"); return(false); } GroupSponsor gsinfo = GroupSponsorBLL.SingleModel.GetModel(item.GroupSponsorId); if (gsinfo == null && item.IsGroup == 1) { msg = "小程序拼团团购不存在啦=" + item.GroupSponsorId; item.State = (int)MiniappPayState.已失效; GroupUserBLL.SingleModel.Update(item, "State"); return(false); } if (item.BuyPrice <= 0) { msg = "xxxxxxxxxxxxx小程序拼团价格为0不需要退款=" + item.Id; return(false); } if (item.PayState == (int)MiniappPayState.已退款) { msg = "xxxxxxxxxxxxx小程序拼团状态有误,不能退款=" + item.Id + ",paystate=" + item.PayState + "," + (int)MiniappPayState.已退款; return(false); } item.State = (int)MiniappPayState.已退款; //更新用户订单状态 tranmodel.Add($"update GroupUser set State={item.State} where id={item.Id}"); //判断是否是微信支付 if (paytype == 0) { CityMorders order = _cityMordersBLL.GetModel(item.OrderId); if (order == null) { msg = "xxxxxxxxxxxxxxxxxx小程序拼团退款查不到支付订单 ID=" + item.Id; item.State = (int)MiniappPayState.已失效; GroupUserBLL.SingleModel.Update(item, "State"); return(false); } //插入退款队列 ReFundQueue reModel = new ReFundQueue(); reModel.minisnsId = -5; reModel.money = item.BuyPrice; reModel.orderid = item.OrderId; reModel.traid = order.trade_no; reModel.addtime = DateTime.Now; reModel.note = "小程序拼团退款"; reModel.retype = 1; tranmodel.Add(base.BuildAddSql(reModel)); } else if (paytype == 1) { //储值卡退款 tranmodel.Add(SaveMoneySetUserBLL.SingleModel.GetCommandCarPriceSql(item.AppId, item.ObtainUserId, item.BuyPrice, 1, item.OrderId, item.OrderNo).ToArray()); if (tranmodel.sqlArray.Length <= 0) { msg = "xxxxxxxxxxxxxxxxxx拼团储值卡退款失败,ID=" + item.Id; return(false); } } //是店主手动退款不加库存 --统一,只要是退款就加库存 //if (type == 0) { if (gsinfo.State == 2 && item.IsGroup == 1) { msg = "小程序团购成功,不能退款=" + item.GroupSponsorId; return(false); } //退款成功,更新剩余数量 tranmodel.Add($"update groups set RemainNum ={(csg.RemainNum + item.BuyNum)} where id={csg.Id}"); //LogHelper.WriteInfo(GetType(), $"修改拼团失败库存:update groups set RemainNum ={(csg.RemainNum + item.BuyNum)} where id={csg.Id}"); } if (tranmodel.sqlArray.Length <= 0) { msg = "xxxxxxxxxxxxxxxxxx拼团退款失败,ID=" + item.Id; return(false); } if (!ExecuteTransactionDataCorect(tranmodel.sqlArray, tranmodel.ParameterArray)) { msg = "xxxxxxxxxxxxxxxxxx拼团退款事务执行失败,ID=" + item.Id + "sql:" + string.Join(";", tranmodel.sqlArray); return(false); } XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(item.AppId); if (xcx == null) { log4net.LogHelper.WriteError(GetType(), new Exception($"发送模板消息,参数不足,XcxAppAccountRelation_null:appId = {item.AppId}")); return(true); } //发给用户发货通知 object groupData = TemplateMsg_Miniapp.GroupGetTemplateMessageData("商家操作退款", item, SendTemplateMessageTypeEnum.拼团基础版订单退款通知); TemplateMsg_Miniapp.SendTemplateMessage(item.ObtainUserId, SendTemplateMessageTypeEnum.拼团基础版订单退款通知, xcx.Type, groupData); msg = "xxxxxxxxxxxxxxxxxx拼团退款成功,ID=" + item.Id; return(true); }
/// <summary> /// 砍价退款(照搬后台的) /// </summary> /// <param name="bargainUser"></param> /// <param name="bargain"></param> /// <param name="appId"></param> /// <param name="msg"></param> /// <returns></returns> public bool BargainReFundQueue(BargainUser bargainUser, Bargain bargain, string appId, out string msg) { bargainUser.State = 2; bargainUser.outOrderDate = DateTime.Now; if (bargainUser.PayType == (int)miniAppBuyMode.储值支付) { bargainUser.refundFee = bargainUser.CurrentPrice + bargain.GoodsFreight; bargainUser.State = 3; SaveMoneySetUser saveMoneyUser = SaveMoneySetUserBLL.SingleModel.getModelByUserId(appId, bargainUser.UserId); TransactionModel tran = new TransactionModel(); tran.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog() { AppId = appId, UserId = bargainUser.UserId, MoneySetUserId = saveMoneyUser.Id, Type = 1, BeforeMoney = saveMoneyUser.AccountMoney, AfterMoney = saveMoneyUser.AccountMoney + bargainUser.refundFee, ChangeMoney = bargainUser.refundFee, ChangeNote = $"小程序砍价购买商品[{bargainUser.BName}]退款,订单号:{bargainUser.OrderId} ", CreateDate = DateTime.Now, State = 1 })); tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney + {bargainUser.refundFee} where id = {saveMoneyUser.Id} ; "); string updateBargainUser = BargainUserBLL.SingleModel.BuildUpdateSql(bargainUser, "State,outOrderDate,refundFee"); tran.Add(updateBargainUser); bool isok = BargainBLL.SingleModel.ExecuteTransactionDataCorect(tran.sqlArray); if (isok) { object orderData = TemplateMsg_Miniapp.BargainGetTemplateMessageData(bargainUser, SendTemplateMessageTypeEnum.价订单退款通知, "商家操作退款"); TemplateMsg_Miniapp.SendTemplateMessage(bargainUser, SendTemplateMessageTypeEnum.价订单退款通知, orderData); msg = "退款成功,请查看账户余额!"; } else { msg = "退款异常!";//返回订单信息 } return(isok); } else { bool isok = false; CityMorders order = _cityMordersBLL.GetModel(bargainUser.CityMordersId); if (order == null) { msg = "订单信息有误!"; return(isok); } bargainUser.refundFee = bargainUser.CurrentPrice + bargain.GoodsFreight; if (BargainUserBLL.SingleModel.Update(bargainUser, "State,outOrderDate,refundFee")) { ReFundQueue reModel = new ReFundQueue { minisnsId = -5, money = bargainUser.refundFee, orderid = order.Id, traid = order.trade_no, addtime = DateTime.Now, note = "小程序砍价订单退款", retype = 1 }; try { int funid = Convert.ToInt32(base.Add(reModel)); if (funid > 0) { object orderData = TemplateMsg_Miniapp.BargainGetTemplateMessageData(bargainUser, SendTemplateMessageTypeEnum.价订单退款通知, "商家操作退款"); TemplateMsg_Miniapp.SendTemplateMessage(bargainUser, SendTemplateMessageTypeEnum.价订单退款通知, orderData); isok = true; msg = "操作成功,已提交退款申请!"; return(isok); } else { isok = false; msg = "退款异常插入队列小于0!"; return(isok); } } catch (Exception ex) { log4net.LogHelper.WriteInfo(GetType(), $"{ex.Message} xxxxxxxxxxxxxxxx小程序砍价退款订单插入队列失败 ID={order.Id}"); isok = false; msg = "退款异常(插入队列失败)!"; return(isok); } } else { isok = false; msg = "退款异常!"; return(isok); } } }
/// <summary> /// 订单退款 /// </summary> /// <param name="item"></param> /// <param name="oldState"></param> /// <param name="BuyMode">默认微信支付</param> /// <param name="isPartOut">是否部分退款</param> /// <returns></returns> public bool EntReFundQueue(EntGoodsOrder item, int oldState, int BuyMode = (int)miniAppBuyMode.微信支付, int?newState = null, bool isPartOut = false) { //重新加回库存 if (EntGoodsOrderBLL.SingleModel.updateStock(item, oldState)) { int money = isPartOut ? item.refundFee : item.BuyPrice;//兼容多版本,目前只有专业版订单有部分退款 item.refundFee = money; if (BuyMode == (int)miniAppBuyMode.微信支付) { try { item.outOrderDate = DateTime.Now; if (item.BuyPrice == 0) //金额为0时,回滚库存后,默认退款成功 { item.State = (int)MiniAppEntOrderState.退款成功; } else { CityMorders order = _cityMordersBLL.GetModel(item.OrderId); item.State = (int)MiniAppEntOrderState.退款中; if (newState.HasValue) { item.State = newState.Value; } if (order == null) { item.State = (int)MiniAppEntOrderState.退款失败; EntGoodsOrderBLL.SingleModel.Update(item, "State,outOrderDate,Remark,refundFee"); return(false); } //微信支付 ReFundQueue reModel = new ReFundQueue { minisnsId = -5, money = item.refundFee, orderid = order.Id, traid = order.trade_no, addtime = DateTime.Now, note = "小程序行业版退款", retype = 1 }; base.Add(reModel); } bool isSuccess = EntGoodsOrderBLL.SingleModel.Update(item, "State,outOrderDate,Remark,refundFee"); if (isSuccess) { //发给用户退款通知 object orderData = TemplateMsg_Miniapp.EnterpriseGetTemplateMessageData(item, SendTemplateMessageTypeEnum.专业版订单退款通知, "商家操作退款"); TemplateMsg_Miniapp.SendTemplateMessage(item.UserId, SendTemplateMessageTypeEnum.专业版订单退款通知, TmpType.小程序专业模板, orderData); } } catch (Exception ex) { log4net.LogHelper.WriteInfo(GetType(), $"{ex.Message} xxxxxxxxxxxxxxxx小程序餐饮退款订单插入队列失败 ID={item.Id}"); } } else { XcxAppAccountRelation r = XcxAppAccountRelationBLL.SingleModel.GetModel(item.aId); if (r == null) { return(false); } SaveMoneySetUser saveMoneyUser = SaveMoneySetUserBLL.SingleModel.getModelByUserId(r.AppId, item.UserId); TransactionModel tran = new TransactionModel(); tran.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog() { AppId = r.AppId, UserId = item.UserId, MoneySetUserId = saveMoneyUser.Id, Type = 1, BeforeMoney = saveMoneyUser.AccountMoney, AfterMoney = saveMoneyUser.AccountMoney + item.refundFee, ChangeMoney = item.refundFee, ChangeNote = $"专业版购买商品退款,订单号:{item.OrderNum} ", CreateDate = DateTime.Now, State = 1 })); item.State = (int)MiniAppEntOrderState.退款成功; if (newState.HasValue) { item.State = newState.Value; } tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney + {item.refundFee} where id = {saveMoneyUser.Id} ; "); tran.Add($" update EntGoodsOrder set State = {item.State },outOrderDate = '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}',Remark = @Remark where Id = {item.Id} and state <> {item.State} ; ", new MySqlParameter[] { new MySqlParameter("@Remark", item.Remark) });//防止重复退款 //记录订单储值支付退款日志 tran.Add(EntGoodsOrderLogBLL.SingleModel.BuildAddSql(new EntGoodsOrderLog() { GoodsOrderId = item.Id, UserId = item.UserId, LogInfo = $" 储值支付订单退款成功:{item.refundFee * 0.01} 元 ", CreateDate = DateTime.Now })); bool isSuccess = ExecuteTransaction(tran.sqlArray, tran.ParameterArray); if (isSuccess) { //发给用户退款通知 object orderData = TemplateMsg_Miniapp.EnterpriseGetTemplateMessageData(item, SendTemplateMessageTypeEnum.专业版订单退款通知, "商家操作退款"); TemplateMsg_Miniapp.SendTemplateMessage(item.UserId, SendTemplateMessageTypeEnum.专业版订单退款通知, TmpType.小程序专业模板, orderData); } return(isSuccess); } } else { return(false); } return(true); }
/// <summary> /// 足浴版退款 /// </summary> /// <param name="appId"></param> /// <param name="orderInfo"></param> /// <returns></returns> public bool ZYReFundQueue(string appId, EntGoodsOrder orderInfo, ServiceTime serviceTime) { bool result = false; if (orderInfo == null || orderInfo.Id <= 0) { return(result); } orderInfo.outOrderDate = DateTime.Now; if (orderInfo.BuyMode == (int)miniAppBuyMode.储值支付) { var saveMoneyUser = new SaveMoneySetUser(); saveMoneyUser = SaveMoneySetUserBLL.SingleModel.getModelByUserId(appId, orderInfo.UserId); if (saveMoneyUser == null || saveMoneyUser.Id <= 0) { return(result); } TransactionModel tran = new TransactionModel(); tran.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog() { AppId = saveMoneyUser.AppId, UserId = orderInfo.UserId, MoneySetUserId = saveMoneyUser.Id, Type = 1, BeforeMoney = saveMoneyUser.AccountMoney, AfterMoney = saveMoneyUser.AccountMoney + orderInfo.BuyPrice, ChangeMoney = orderInfo.BuyPrice, ChangeNote = $" 购买商品,订单号:{orderInfo.OrderNum} ", CreateDate = DateTime.Now, State = 1 })); saveMoneyUser.AccountMoney += orderInfo.BuyPrice; tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney + {orderInfo.BuyPrice} where id = {saveMoneyUser.Id} ; "); tran.Add($" update EntGoodsOrder set state = {(int)MiniAppEntOrderState.退款成功 },outOrderDate = '{orderInfo.outOrderDate.ToString("yyyy-MM-dd HH:mm:ss")}',Remark = @Remark where Id = {orderInfo.Id} and state <> {(int)MiniAppEntOrderState.退款成功 } ; ", new MySqlParameter[] { new MySqlParameter("@Remark", orderInfo.Remark) });//防止重复退款 if (serviceTime != null) { tran.Add($"update servicetime set time='{serviceTime.time}' where id={serviceTime.Id}");//取消已预订的技师服务时间 } //记录订单退款日志 tran.Add(EntGoodsOrderLogBLL.SingleModel.BuildAddSql(new EntGoodsOrderLog() { GoodsOrderId = orderInfo.Id, UserId = orderInfo.UserId, LogInfo = $" 订单储值支付,退款成功:{orderInfo.BuyPrice * 0.01} 元 ", CreateDate = DateTime.Now })); result = ExecuteTransaction(tran.sqlArray, tran.ParameterArray); if (result) { object objData = TemplateMsg_Miniapp.FootbathGetTemplateMessageData(orderInfo, SendTemplateMessageTypeEnum.足浴退款通知); TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, SendTemplateMessageTypeEnum.足浴退款通知, TmpType.小程序足浴模板, objData); } return(result); } if (orderInfo.BuyMode == (int)miniAppBuyMode.微信支付) { CityMorders order = new CityMordersBLL().GetModel(orderInfo.OrderId); orderInfo.State = (int)MiniAppEntOrderState.退款中; if (order == null) { orderInfo.State = (int)MiniAppEntOrderState.退款失败; EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,outOrderDate,Remark"); return(result); } //微信支付 ReFundQueue reModel = new ReFundQueue { minisnsId = -5, money = orderInfo.BuyPrice, orderid = order.Id, traid = order.trade_no, addtime = DateTime.Now, note = "小程序足浴版退款", retype = 1 }; try { base.Add(reModel); result = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,outOrderDate"); return(result); } catch (Exception ex) { log4net.LogHelper.WriteInfo(GetType(), $"{ex.Message} xxxxxxxxxxxxxxxx小程序足浴退款订单插入队列失败 ID={orderInfo.Id}"); } } return(result); }
/// <summary> /// 处理餐饮UU配送回调 /// </summary> /// <param name="orderid"></param> /// <param name="state"></param> /// <returns></returns> public bool UUToFoodReturn(UUOrder order) { bool isSuccess = false; string updatesql = "State"; FoodGoodsOrder foodGoodOrder = FoodGoodsOrderBLL.SingleModel.GetModel(order.OrderId);// and OrderType ={(int)miniAppFoodOrderType.店内点餐 } "); if (foodGoodOrder == null) { LogHelper.WriteInfo(this.GetType(), "UU配送:找不到餐饮订单"); return(isSuccess); } string msg = string.Empty; switch (order.State) { case (int)UUOrderEnum.订单取消: isSuccess = base.Update(order, updatesql); if (!isSuccess) { LogHelper.WriteInfo(this.GetType(), "UU配送:修改系统订单状态出错," + JsonConvert.SerializeObject(order)); return(isSuccess); } //退款接口 abel //判断是否是取消订单,取消订单则要执行退款 if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.微信支付) { isSuccess = FoodGoodsOrderBLL.SingleModel.outOrder(foodGoodOrder, foodGoodOrder.State); } else if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.储值支付) { SaveMoneySetUser userSaveMoney = SaveMoneySetUserBLL.SingleModel.getModelByUserId(foodGoodOrder.UserId) ?? new SaveMoneySetUser(); isSuccess = FoodGoodsOrderBLL.SingleModel.outOrderBySaveMoneyUser(foodGoodOrder, userSaveMoney, foodGoodOrder.State); } #region 餐饮退款成功通知 模板消息 if (isSuccess) { object postData2 = FoodGoodsOrderBLL.SingleModel.getTemplateMessageData(foodGoodOrder.Id, SendTemplateMessageTypeEnum.餐饮退款成功通知); TemplateMsg_Miniapp.SendTemplateMessage(foodGoodOrder.UserId, SendTemplateMessageTypeEnum.餐饮退款成功通知, (int)TmpType.小程序餐饮模板, postData2); } #endregion return(isSuccess); case (int)UUOrderEnum.单成功: case (int)UUOrderEnum.跑男抢单: case (int)UUOrderEnum.已到达: case (int)UUOrderEnum.已取件: updatesql += ",driver_name,driver_mobile,driver_jobnum"; foodGoodOrder.State = (int)miniAppFoodOrderState.待送餐; if (order.State == (int)UUOrderEnum.已取件) { foodGoodOrder.State = (int)miniAppFoodOrderState.待确认送达; #region 发送餐饮订单配送通知 模板消息 C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModel(foodGoodOrder.UserId) ?? new C_UserInfo(); object postData = FoodGoodsOrderBLL.SingleModel.getTemplateMessageData(foodGoodOrder.Id, SendTemplateMessageTypeEnum.餐饮订单配送通知); TemplateMsg_Miniapp.SendTemplateMessage(userinfo.Id, SendTemplateMessageTypeEnum.餐饮订单配送通知, (int)TmpType.小程序餐饮模板, postData); #endregion } break; case (int)UUOrderEnum.到达目的地: foodGoodOrder.State = (int)miniAppFoodOrderState.待确认送达; break; case (int)UUOrderEnum.收件人已收货: foodGoodOrder.State = (int)miniAppFoodOrderState.已完成; break; } isSuccess = base.Update(order, updatesql); if (!isSuccess) { LogHelper.WriteInfo(this.GetType(), "UU配送:修改系统订单状态出错," + JsonConvert.SerializeObject(order)); return(isSuccess); } isSuccess = FoodGoodsOrderBLL.SingleModel.Update(foodGoodOrder, "State"); return(isSuccess); }
/// <summary> /// 处理餐饮快跑者配送回调 /// </summary> /// <param name="orderid"></param> /// <param name="state"></param> /// <returns></returns> public bool KPZToFoodReturn(KPZOrder order) { bool isSuccess = false; string updatesql = "status"; FoodGoodsOrder foodGoodOrder = FoodGoodsOrderBLL.SingleModel.GetModel(order.OrderId);// and OrderType ={(int)miniAppFoodOrderType.店内点餐 } "); if (foodGoodOrder == null) { LogHelper.WriteInfo(this.GetType(), "快跑者配送:找不到餐饮订单"); return(isSuccess); } string msg = string.Empty; switch (order.status) { case (int)KPZOrderEnum.已撤销: isSuccess = base.Update(order, updatesql); if (!isSuccess) { LogHelper.WriteInfo(this.GetType(), "快跑者配送:修改系统订单状态出错," + JsonConvert.SerializeObject(order)); return(isSuccess); } //退款接口 abel //判断是否是取消订单,取消订单则要执行退款 if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.微信支付) { isSuccess = FoodGoodsOrderBLL.SingleModel.outOrder(foodGoodOrder, foodGoodOrder.State); } else if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.储值支付) { SaveMoneySetUser userSaveMoney = SaveMoneySetUserBLL.SingleModel.getModelByUserId(foodGoodOrder.UserId) ?? new SaveMoneySetUser(); isSuccess = FoodGoodsOrderBLL.SingleModel.outOrderBySaveMoneyUser(foodGoodOrder, userSaveMoney, foodGoodOrder.State); } #region 餐饮退款成功通知 模板消息 if (isSuccess) { object postData2 = FoodGoodsOrderBLL.SingleModel.getTemplateMessageData(foodGoodOrder.Id, SendTemplateMessageTypeEnum.餐饮退款成功通知); TemplateMsg_Miniapp.SendTemplateMessage(foodGoodOrder.UserId, SendTemplateMessageTypeEnum.餐饮退款成功通知, (int)TmpType.小程序餐饮模板, postData2); } #endregion return(isSuccess); case (int)KPZOrderEnum.待发单: case (int)KPZOrderEnum.待抢单: case (int)KPZOrderEnum.待接单: foodGoodOrder.State = (int)miniAppFoodOrderState.待接单; break; case (int)KPZOrderEnum.取单中: updatesql += ",courier,tel"; foodGoodOrder.State = (int)miniAppFoodOrderState.待送餐; #region 发送餐饮订单配送通知 模板消息 C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModel(foodGoodOrder.UserId) ?? new C_UserInfo(); object postData = FoodGoodsOrderBLL.SingleModel.getTemplateMessageData(foodGoodOrder.Id, SendTemplateMessageTypeEnum.餐饮订单配送通知); TemplateMsg_Miniapp.SendTemplateMessage(userinfo.Id, SendTemplateMessageTypeEnum.餐饮订单配送通知, (int)TmpType.小程序餐饮模板, postData); #endregion break; case (int)KPZOrderEnum.送单中: foodGoodOrder.State = (int)miniAppFoodOrderState.待确认送达; break; case (int)KPZOrderEnum.已送达: foodGoodOrder.State = (int)miniAppFoodOrderState.已完成; break; } isSuccess = base.Update(order, updatesql); if (!isSuccess) { LogHelper.WriteInfo(this.GetType(), "快跑者配送:修改系统订单状态出错," + JsonConvert.SerializeObject(order)); return(isSuccess); } isSuccess = FoodGoodsOrderBLL.SingleModel.Update(foodGoodOrder, "State"); return(isSuccess); }
/// <summary> /// 取消预订 /// </summary> /// <returns></returns> public ActionResult UpdateState() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={appId}"); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } int id = Context.GetRequestInt("id", 0); if (id <= 0) { return(Json(new { isok = false, msg = "系统繁忙orderId_null" })); } int state = Context.GetRequestInt("state", -7); if (state <= -7) { return(Json(new { isok = false, msg = "系统繁忙state_null" })); } EntGoodsOrder orderInfo = EntGoodsOrderBLL.SingleModel.GetModelByAidAndId(appId, id, 1); if (orderInfo == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } //是否是要直接取消的订单<未支付的订单取消订单都是直接取消> bool isCanncleOrder = orderInfo.PayDate == Convert.ToDateTime("0001-01-01 00:00:00"); if (isCanncleOrder) { orderInfo.State = (int)MiniAppEntOrderState.已取消; } else { orderInfo.State = state; } EntGoodsCart cart = EntGoodsCartBLL.SingleModel.GetModelByGoodsOrderId(orderInfo.Id); if (cart == null) { return(Json(new { isok = false, msg = "服务项目不存在" })); } ServiceTime serviceTime = ServiceTimeBLL.SingleModel.GetModel(storeModel.appId, cart.technicianId, storeModel.Id, cart.reservationTime.ToShortDateString()); //取消已预订的技师服务时间 if (serviceTime != null && !string.IsNullOrEmpty(serviceTime.time)) { List <string> timeList = serviceTime.time.Split(',').ToList(); timeList.Remove(cart.reservationTime.ToString("HH:mm")); serviceTime.time = string.Join(",", timeList); } bool isok = false; if (isCanncleOrder) { isok = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State"); } else { isok = EntGoodsOrderBLL.SingleModel.outOrder(appAcountRelation.AppId, orderInfo, serviceTime); } #region 取消预约通知 模板消息 if (isok && !isCanncleOrder) { object objData = TemplateMsg_Miniapp.FootbathGetTemplateMessageData(orderInfo, SendTemplateMessageTypeEnum.足浴预约取消通知); TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, SendTemplateMessageTypeEnum.足浴预约取消通知, TmpType.小程序足浴模板, objData); } #endregion string msg = isok ? "操作成功" : "操作失败"; return(Json(new { isok = isok, msg = msg })); }
/// <summary> /// 砍价发货 /// </summary> /// <param name="bargainUser"></param> /// <param name="bargain"></param> /// <param name="appId"></param> /// <param name="msg"></param> /// <returns></returns> public bool SendGoods(BargainUser bargainUser, Bargain bargain, int aid, out string msg, string attachData = "") { bool result = false; bool addExpressResult = false; if (bargainUser.State == 6) { msg = "已经发货了,不能修改!"; return(result); } //if (!string.IsNullOrEmpty(bargainUser.WayBillNo) || !string.IsNullOrEmpty(bargainUser.SendGoodsName)) //{ // msg = "已经发货了,不能修改!"; // return result; //} //if (string.IsNullOrEmpty(WayBillNo) || string.IsNullOrEmpty(SendGoodsName)) //{ // return Json(new { code = -1, msg = "快递单号或者名称不能为空!" }); //} //if (SendGoodsName.Length > 8) //{ // return Json(new { code = -1, msg = "快递名称过长" }); //} if (!string.IsNullOrEmpty(attachData)) { DeliveryUpdatePost DeliveryInfo = System.Web.Helpers.Json.Decode <DeliveryUpdatePost>(attachData); if (DeliveryInfo != null) { addExpressResult = DeliveryFeedbackBLL.SingleModel.AddOrderFeed(bargainUser.Id, DeliveryInfo, DeliveryOrderType.专业版砍价发货); if (!addExpressResult) { msg = "物流信息添加失败,发货失败!"; return(result); } } } bargainUser.State = 6; //bargainUser.WayBillNo = WayBillNo; //bargainUser.SendGoodsName = SendGoodsName; bargainUser.SendGoodsTime = DateTime.Now; if (Update(bargainUser, "SendGoodsTime,State")) { var storeName = ""; if (bargain != null) { switch (bargain.BargainType) { case 0: var store = StoreBLL.SingleModel.GetModel(bargain.StoreId); if (store != null) { var paramslist = ConfParamBLL.SingleModel.GetListByRId(aid) ?? new List <ConfParam>(); storeName = paramslist.Where(w => w.Param == "nparam").FirstOrDefault()?.Value; } break; case 1: storeName = OpenAuthorizerConfigBLL.SingleModel.GetModel($" rid = {aid} ")?.nick_name; break; default: storeName = ""; break; } } #region 模板消息 try { XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (app == null) { throw new Exception($"发送砍价发货模板消息参数错误 app_null :aid = {aid}"); } XcxTemplate xcxTemp = XcxTemplateBLL.SingleModel.GetModel(app.TId); if (xcxTemp == null) { throw new Exception($"发送砍价发货模板消息参数错误 xcxTemp_null :xcxTempId = {app.TId}"); } Account account = AccountBLL.SingleModel.GetModel(app.AccountId); if (account == null) { throw new Exception($"发送砍价发货模板消息参数错误 account_null :accountId = {app.AccountId}"); } //电商为旧做法,兼容电商 switch (xcxTemp.Type) { case (int)TmpType.小程序电商模板: #region 购买者模板消息 var postData = new BargainUserBLL().GetTemplateMessageData_SendGoods(bargainUser.Id, storeName); TemplateMsg_Miniapp.SendTemplateMessage(bargainUser.UserId, SendTemplateMessageTypeEnum.电商订单配送通知, (int)TmpType.小程序电商模板, postData); #endregion 购买者模板消息 break; default: object orderData = TemplateMsg_Miniapp.BargainGetTemplateMessageData(bargainUser, SendTemplateMessageTypeEnum.价订单发货提醒); TemplateMsg_Miniapp.SendTemplateMessage(bargainUser.UserId, SendTemplateMessageTypeEnum.价订单发货提醒, xcxTemp.Type, orderData); break; } } catch (Exception ex) { log4net.LogHelper.WriteError(GetType(), ex); } #endregion 模板消息 result = true; msg = "发货成功!"; return(result); } else { result = false; msg = "发货异常!"; return(result); } }