Esempio n. 1
0
        /// <summary>
        /// 勾选商品
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string Do_ChoseGoods(BaseApi baseApi)
        {
            MsgResult       msg             = new MsgResult();
            ChoseGoodsParam choseGoodsParam = JsonConvert.DeserializeObject <ChoseGoodsParam>(baseApi.param.ToString());

            if (choseGoodsParam.goodsId == "" || choseGoodsParam.goodsId == null)
            {
                throw new ApiException(CodeMessage.InvalidGoodsIdCode, "InvalidGoodsIdCode");
            }

            string    shopId    = Util.GetUserShopId(baseApi.token);
            ActiveDao activeDao = new ActiveDao();

            if (choseGoodsParam.type)
            {
                if (!activeDao.InsertActiveGoods(shopId, choseGoodsParam))
                {
                    throw new ApiException(CodeMessage.DBAddError, "DBAddError");
                }
            }
            else
            {
                if (!activeDao.DeleteActiveGoods(shopId, choseGoodsParam))
                {
                    throw new ApiException(CodeMessage.DBDelError, "DBDelError");
                }
            }
            return("");
        }
Esempio n. 2
0
        /// <summary>
        /// 商品列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public PageResult Do_GoodsList(BaseApi baseApi)
        {
            PageResult     pageResult     = new PageResult();
            ActiveDao      activeDao      = new ActiveDao();
            string         shopId         = Util.GetUserShopId(baseApi.token);
            GoodsListParam goodsListParam = JsonConvert.DeserializeObject <GoodsListParam>(baseApi.param.ToString());

            if (goodsListParam.current == 0)
            {
                goodsListParam.current = 1;
            }
            if (goodsListParam.pageSize == 0)
            {
                activeDao.DeleteActiveGoods(shopId);
                goodsListParam.pageSize = 10;
            }
            if (goodsListParam.goodsName != null && goodsListParam.goodsName != "")
            {
                goodsListParam.goodsName = " and goods_name  like '%" + goodsListParam.goodsName + "%'";
            }
            else
            {
                goodsListParam.goodsName = "";
            }
            pageResult = activeDao.SelectGoods(goodsListParam, shopId);
            return(pageResult);
        }
Esempio n. 3
0
        /// <summary>
        /// 删除勾选商品
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string Do_DeleteActiveGoods(BaseApi baseApi)
        {
            string    shopId    = Util.GetUserShopId(baseApi.token);
            ActiveDao activeDao = new ActiveDao();

            if (!activeDao.DeleteActiveGoods(shopId))
            {
                throw new ApiException(CodeMessage.DBDelError, "DBDelError");
            }
            return("");
        }
Esempio n. 4
0
        /// <summary>
        /// 添加活动
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string Do_AddActive(BaseApi baseApi)
        {
            AddActiveParam addActiveParam = JsonConvert.DeserializeObject <AddActiveParam>(baseApi.param.ToString());

            if (addActiveParam.activeRemark == "" || addActiveParam.activeRemark == null)
            {
                throw new ApiException(CodeMessage.InvalidRemark, "InvalidRemark");
            }
            if (addActiveParam.date == null || addActiveParam.date.Length != 2)
            {
                throw new ApiException(CodeMessage.InvalidTime, "InvalidTime");
            }
            else
            {
                addActiveParam.date[0] = addActiveParam.date[0] + " 00:00:00";
                addActiveParam.date[1] = addActiveParam.date[1] + " 23:59:59";
            }
            if (addActiveParam.activeType == "" || addActiveParam.activeType == null)
            {
                throw new ApiException(CodeMessage.InvalidActiveType, "InvalidActiveType");
            }
            else if (addActiveParam.activeType == "0")
            {
                if (addActiveParam.consume == "" || addActiveParam.consume == null || !double.TryParse(addActiveParam.consume, out double d))
                {
                    throw new ApiException(CodeMessage.InvalidConsume, "InvalidConsume");
                }
            }
            int mistake = 0;

            if (addActiveParam.heartItemValue != null && addActiveParam.heartItemValue != "" && addActiveParam.heartItemValue != "0")
            {
                if (!double.TryParse(addActiveParam.heartItemValue, out double h))
                {
                    throw new ApiException(CodeMessage.ErrorHeartItemValue, "ErrorHeartItemValue");
                }
            }
            else
            {
                mistake += 1;
            }
            if (addActiveParam.limitItemValue != null && addActiveParam.limitItemValue != "" && addActiveParam.limitItemValue != "0")
            {
                if (!double.TryParse(addActiveParam.limitItemValue, out double h))
                {
                    throw new ApiException(CodeMessage.ErrorLimitItemValue, "ErrorLimitItemValue");
                }
            }
            else
            {
                mistake += 1;
            }
            if (addActiveParam.list == null || addActiveParam.list.Count == 0)
            {
                mistake += 1;
                if (mistake == 3)
                {
                    throw new ApiException(CodeMessage.InvalidGift, "InvalidGift");
                }
            }
            if (addActiveParam.list != null)
            {
                for (int i = 0; i < addActiveParam.list.Count; i++)
                {
                    if (addActiveParam.list[i].goodsId == null || addActiveParam.list[i].goodsId == "")
                    {
                        throw new ApiException(CodeMessage.InvalidGoodsIdCode, "InvalidGoodsIdCode");
                    }
                    if (addActiveParam.list[i].goodsNums == null || addActiveParam.list[i].goodsNums == "")
                    {
                        throw new ApiException(CodeMessage.InvalidGoodsNumCode, "InvalidGoodsNumCode");
                    }
                }
            }
            string    shopId    = Util.GetUserShopId(baseApi.token);
            ActiveDao activeDao = new ActiveDao();

            if (activeDao.InsertAddActive(addActiveParam, shopId))
            {
                string id = activeDao.SelectAddActive(addActiveParam, shopId);

                if (addActiveParam.activeType == "0")
                {
                    if (addActiveParam.heartItemValue != null && addActiveParam.heartItemValue != "" && addActiveParam.heartItemValue != "0")
                    {
                        addActiveParam.itemNums  = "1";
                        addActiveParam.ItemValue = addActiveParam.heartItemValue;
                        addActiveParam.valueType = "1";
                        if (!activeDao.InsertActiveConsume(addActiveParam, id))
                        {
                            throw new ApiException(CodeMessage.DBAddError, "DBAddError");
                        }
                    }
                    if (addActiveParam.limitItemValue != null && addActiveParam.limitItemValue != "" && addActiveParam.limitItemValue != "0")
                    {
                        addActiveParam.itemNums  = "1";
                        addActiveParam.ItemValue = addActiveParam.limitItemValue;
                        addActiveParam.valueType = "2";
                        if (!activeDao.InsertActiveConsume(addActiveParam, id))
                        {
                            throw new ApiException(CodeMessage.DBAddError, "DBAddError");
                        }
                    }
                    if (addActiveParam.list != null && addActiveParam.list.Count > 0)
                    {
                        addActiveParam.valueType = "0";
                        for (int i = 0; i < addActiveParam.list.Count; i++)
                        {
                            addActiveParam.itemNums  = addActiveParam.list[i].goodsNums;
                            addActiveParam.ItemValue = addActiveParam.list[i].goodsId;
                            if (!activeDao.InsertActiveConsume(addActiveParam, id))
                            {
                                throw new ApiException(CodeMessage.DBAddError, "DBAddError");
                            }
                        }
                    }
                }
                else
                {
                    if (addActiveParam.heartItemValue != null && addActiveParam.heartItemValue != "")
                    {
                        addActiveParam.itemNums  = "1";
                        addActiveParam.ItemValue = addActiveParam.heartItemValue;
                        addActiveParam.valueType = "1";
                        if (!activeDao.InsertActiveCheck(addActiveParam, id))
                        {
                            throw new ApiException(CodeMessage.DBAddError, "DBAddError");
                        }
                    }
                    if (addActiveParam.limitItemValue != null && addActiveParam.limitItemValue != "")
                    {
                        addActiveParam.itemNums  = "1";
                        addActiveParam.ItemValue = addActiveParam.limitItemValue;
                        addActiveParam.valueType = "2";
                        if (!activeDao.InsertActiveCheck(addActiveParam, id))
                        {
                            throw new ApiException(CodeMessage.DBAddError, "DBAddError");
                        }
                    }
                    if (addActiveParam.list != null && addActiveParam.list.Count > 0)
                    {
                        addActiveParam.valueType = "0";
                        for (int i = 0; i < addActiveParam.list.Count; i++)
                        {
                            addActiveParam.itemNums  = addActiveParam.list[i].goodsNums;
                            addActiveParam.ItemValue = addActiveParam.list[i].goodsId;
                            if (!activeDao.InsertActiveCheck(addActiveParam, id))
                            {
                                throw new ApiException(CodeMessage.DBAddError, "DBAddError");
                            }
                        }
                    }
                }
            }
            else
            {
                throw new ApiException(CodeMessage.DBAddError, "DBAddError");
            }
            activeDao.DeleteActiveGoods(shopId);
            return("");
        }