Esempio n. 1
0
        public async Task <BaseResult <bool> > UpdateShopCoupon(ShopCouponEntity entity)
        {
            string minShopSkuMoney = (from n in await shopSkuRepository.GetAllAsync(c => c.shop_id.Equals(entity.shop_id))
                                      select n.shopsku_currentprice).Min();

            if (string.IsNullOrEmpty(minShopSkuMoney))
            {
                return(new BaseResult <bool>(3006, false));
            }
            if (Convert.ToDouble(minShopSkuMoney) < entity.shopcoupon_money)
            {
                return(new BaseResult <bool>(3007, false));
            }

            var isTrue = await shopCouponRepository.UpdateAsync(entity, false, true, c => c.shopcoupon_type, c => c.shopcoupon_name, c => c.shopcoupon_money, c => c.endtime, c => c.disable);

            if (entity.disable == 1)
            {
                var isUpdate = await shopRepository.UpdateAsync(new ShopEntity { shop_id = entity.shop_id, shop_isdiscount = false }, false, true, c => c.shop_isdiscount);
            }
            else
            {
                var isUpdate = await shopRepository.UpdateAsync(new ShopEntity { shop_id = entity.shop_id, shop_isdiscount = true }, false, true, c => c.shop_isdiscount);
            }
            if (unitOfWork.SaveCommit())
            {
                return(new BaseResult <bool>(200, true));
            }
            return(new BaseResult <bool>(201, false));
        }
Esempio n. 2
0
        public async Task <BaseResult <bool> > AddShopCoupon(ShopCouponEntity entity)
        {
            //1.判断优惠只能包含1个,2.判断优惠金额必须低于商品SKU的最低金额,2.同步添加商品优惠表和修改商品表的优惠状态3.
            var count = shopCouponRepository.Count(c => c.shop_id.Equals(entity.shop_id));

            if (count >= 1)
            {
                return(new BaseResult <bool>(3003, false));
            }
            string minShopSkuMoney = (from n in await shopSkuRepository.GetAllAsync(c => c.shop_id.Equals(entity.shop_id))
                                      select n.shopsku_currentprice).Min();

            if (string.IsNullOrEmpty(minShopSkuMoney))
            {
                return(new BaseResult <bool>(3006, false));
            }
            if (Convert.ToDouble(minShopSkuMoney) < entity.shopcoupon_money)
            {
                return(new BaseResult <bool>(3007, false));
            }

            var isTrue = await shopCouponRepository.AddAsync(entity, false);

            var isUpdate = await shopRepository.UpdateAsync(new ShopEntity { shop_id = entity.shop_id, shop_isdiscount = true }, false, true, c => c.shop_isdiscount);

            if (unitOfWork.SaveCommit())
            {
                return(new BaseResult <bool>(200, true));
            }
            return(new BaseResult <bool>(201, false));
        }
Esempio n. 3
0
        public async Task <IActionResult> UpdateShopCoupon(ShopCouponEntity entity)
        {
            if (ModelState.IsValid)
            {
                var data = await shopService.UpdateShopCoupon(entity);

                return(Json(data));
            }
            return(Json(ParrNoPass()));
        }