Beispiel #1
0
 def buy_product(self, itemid, fuzzy_id):
     pro: Product = ProductDao.product_by_pro_no(itemid)
     if pro:
         user_id = decrypt_user_id(fuzzy_id)
         acc_auth = AuthDao.query_account_auth(user_id)
         if acc_auth:
             a = ProductDao.new_order_assets(acc_auth, pro)
             return a
     return None
Beispiel #2
0
 def tag_product(self, ref_id, itemid, layer, p_price) -> Product:
     es_rs = es_dao_local().es_get(
         itemid, {
             "_source":
             ",".join([
                 'isdir', 'fs_id', 'size', 'account', 'tags', 'filename',
                 'parent', 'sourceid'
             ])
         })
     logger.info("es_rs:{},layer:{},price:{}".format(es_rs, layer, p_price))
     if es_rs and "_source" in es_rs:
         source = es_rs["_source"]
         isdir = source["isdir"]
         size = source["size"]
         # format_size = scale_size(size)
         tags = source["tags"]
         if not tags:
             tags = []
         if PRODUCT_TAG not in tags:
             tags.append(PRODUCT_TAG)
             es_dao_local().update_field(itemid, 'tags', tags)
         pro: Product = ProductDao.product_by_pro_no(itemid)
         if not pro:
             pro = ProductDao.new_product(
                 itemid, ref_id, {
                     'isdir': isdir,
                     'name': source['filename'],
                     'fs_id': source['fs_id'],
                     'size': size,
                     'price': int(p_price * 100)
                 })
         else:
             ProductDao.update_product(itemid, {
                 'pin': 0,
                 'price': int(p_price * 100)
             })
         return pro