Пример #1
0
        /// <summary>
        /// 帮他砍一刀
        /// </summary>
        /// <param name="openid"></param>
        /// <param name="classid"></param>
        /// <returns></returns>
        public ActionResult BargainClass(string ownOpenid, string openid, string classid)
        {
            try
            {
                OrderBC bc     = new OrderBC();
                var     result = "success";
                LogHelp.WriteLog("ownOpenid:::" + ownOpenid + "openid::: " + openid + "classid::: " + classid);
                //获取砍价上下限
                var     config     = bc.GetBargainConfigByClassId(classid);
                var     top        = config.BargainTop;
                var     floor      = config.BargainFloor;
                decimal cutPrce    = Convert.ToDecimal(CommonHelper.GetRandNum(floor * 100, top * 100) * 0.01);
                var     floorPrice = config.FloorPrice;
                //更新最新价格,插入砍价记录表
                var bargainEntity = bc.GetBargainByOpenIdAndClassId(classid, ownOpenid);
                var nowPrice      = bargainEntity.NowPrice;
                if (nowPrice - floorPrice < cutPrce)
                {
                    cutPrce = nowPrice - floorPrice;
                }
                nowPrice = nowPrice - cutPrce;
                bc.UpdateBargainNowPrice(bargainEntity.BargainId, nowPrice);
                BargainLogEntity log = new BargainLogEntity()
                {
                    BargainId    = bargainEntity.BargainId,
                    OpenId       = openid,
                    BargainPrice = cutPrce,
                };
                bc.AddBargainLog(log, openid);

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelp.WriteLog(ex.Message);
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }