Beispiel #1
0
 def POST(self):
     try:
         params = toDict(json.loads(web.data()))
         goods = Goods(**params)
         Goods_S.delete(goods)
         return OK_Result()
     except:
         return Error_Result()
Beispiel #2
0
 def POST(self):
     try:
         params = toDict(json.loads(web.data()))
         goods = Goods_S.getById(params)
         newGoods = Goods(**merge(goods, params))
         Goods_S.update(newGoods)
         return OK_Result()
     except:
         return Error_Result()
Beispiel #3
0
 def GET(self):
     try:
         result = OK_Result(
             '', {
                 'list': Goods_S.list(web.input(pageOffset=0,
                                                pageLimit=10)),
                 'total': Goods_S.listCount(web.input())
             })
         return result
     except:
         return Error_Result('查询失败')
Beispiel #4
0
 def POST(self):
     params = toDict(json.loads(web.data()))
     result = Goods_S.add(params)
     if result != -1:
         return OK_Result()
     else:
         return Error_Result()
Beispiel #5
0
def add(paramsArr):
    try:
        newNo = 'S' + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
        for params in paramsArr:
            params = toDict(params)
            tempTime = int(time.time() * 1000)
            goods = Goods_S.getByNo(toDict({'no': params.goods_no}))
            beforeAprice = goods.aprice
            # 更新库存
            goods.quantity = goods.quantity - float(params.quantity)
            goods.money = goods.money - float(params.money)
            if (goods.quantity == 0):
                goods.aprice = 0
            else:
                goods.aprice = goods.money / goods.quantity
            afterAprice = goods.aprice
            sale = Sale(id=next_id(),
                        no=newNo,
                        customer_no=params.customer_no,
                        customer_name=params.customer_name,
                        goods_no=params.goods_no,
                        goods_name=params.goods_name,
                        goods_guige=params.goods_guige,
                        goods_unit=params.goods_unit,
                        quantity=params.quantity,
                        price=params.price,
                        money=params.money,
                        aprice_before=beforeAprice,
                        aprice_after=afterAprice,
                        creater=params.creater,
                        creater_name=params.creater_name,
                        createtime=tempTime)
            # 新增台账
            taizhang = Taizhang(id=next_id(),
                                no=Taizhang_S.getNewNo(),
                                time=tempTime,
                                deal_no=newNo,
                                goods_no=params.goods_no,
                                goods_name=params.goods_name,
                                goods_guige=params.goods_guige,
                                sale_quantity=params.quantity,
                                sale_price=params.price,
                                sale_money=params.money,
                                store_quantity=goods.quantity,
                                store_money=goods.money,
                                store_aprice=goods.aprice,
                                comment=params.comment)
            taizhang.insert()
            goods.update()
            sale.insert()
    except:
        print '购买失败'
Beispiel #6
0
 def GET(self):
     try:
         return OK_Result('', Goods_S.blurQueryByName(web.input()))
     except:
         return Error_Result()
Beispiel #7
0
 def GET(self):
     try:
         return OK_Result('', Goods_S.getById(web.input()))
     except:
         return Error_Result()