示例#1
0
        /// <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");
                    }
                }
            }
        }
示例#2
0
        /// <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 });
        }
示例#3
0
        /// <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 = "发货:操作失败";
            }
        }
示例#4
0
        /// <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;
            }
        }