コード例 #1
0
 def post(self):
     data = self.get_args(['order_num', 'reason', 'other_reason'],
                          {'reason': (int, -1)})
     if data.reason > -1:
         # 订单状态置为3(申请退款),并写入取消理由
         order_query = {"order_num": data.order_num}
         self.db.Order.update(
             order_query, {
                 "$set": {
                     "status": "3",
                     "reason": data.reason,
                     "other_reason": data.other_reason
                 }
             })
         # 推送消息
         seller_id = self.db.Order.find_one(order_query)['seller_id']
         push_msg(self.user_id, u"您取消订单申请提交成功,正在审核中")
         push_msg(seller_id,
                  u"您有一笔订单被买家申请取消,请到我的订单查看",
                  extra={
                      "extra": "extra_my_order_buy",
                      "order_num": data.order_num
                  })
         return self.write_success()
     else:
         return self.write_err('miss arg reason')
コード例 #2
0
ファイル: report_handler.py プロジェクト: xiaolong321/backend
 def post(self):
     goods_id = self.get_argument("id")
     query = {"goods_id": goods_id, "user_id": self.user_id}
     if goods_id: # and not self.db.Goods_report.find_one(query)
         self.db.Goods_report.update(query, query, True)
         goods = Goods.byid(self, goods_id)
         push_msg(goods.seller_id, u'您的商品%s被用户举报' % goods.goods_name, extra={'extra': 'extra_my_publish'})
         #self.push_all(u'商品%s被用户举报' % goods.goods_name, extra={'extra': 'extra_my_publish'})
     return self.write_success()
コード例 #3
0
 def post(self):
     # alipay 支付宝帐号
     data = self.get_args(['photo', 'fullname', 'phone', 'address', 'alipay'])
     query = {"_id": ObjectId(self.user_id)}
     data.status = "0"
     self.db.User.update(query, {'$set': {"verify_status": "1"}})
     # 清除用户缓存信息
     self.clear_cache("UserInfo:%s" % self.user_id)
     self.db.User_verify.update(query, {"$set": data}, True)
     push_msg(self.user_id, u"您的身份验证已提交,正在审核中")
     self.write_success()
コード例 #4
0
ファイル: user_handler.py プロジェクト: xiaolong321/backend
    def post(self):
        withdraw_id = self.get_argument('id')
        query = {'_id': ObjectId(withdraw_id)}
        action = self.get_argument('action')
        if action == "1":
            info = self.db.Withdraw.find_one(query)
            self.db.Withdraw.update(query, {'$set': {'status': "2"}})
            money = info['money']

            push_msg(info['user_id'],
                     u"您申请的%d元提现已成功,手续费为%s元" % (money, get_service_fee(money)))
        else:
            pass
        return self.write_success()
コード例 #5
0
ファイル: goods_handler.py プロジェクト: xiaolong321/backend
 def post(self):
     dead_day = 3
     now = time.time()
     deadline = 3600 * 24 * dead_day  # 3天
     for goods in self.db.Goods.find({}, {
             'goods_name': 1,
             'seller_id': 1,
             'last_update_at': 1
     }):
         if now - goods['last_update_at'] > deadline:
             self.db.Goods.update({'_id': goods['_id']},
                                  {'$set': {
                                      'status': '1'
                                  }})
             # 推送消息
             push_msg(
                 goods['seller_id'],
                 '您的商品%s发布超过%d,已自动下架' % (goods['goods_name'], dead_day))
コード例 #6
0
 def post(self):
     '''填写邀请码'''
     code = self.get_argument('code')
     query = {"_id": ObjectId(self.user_id)}
     # 用户只能填一次邀请码,_id就是user_id
     if not self.db.Invitation.find_one(query):
         inviter = self.db.User.find_one({"invitation_code": code},
                                         {"_id": 1})
         if inviter:
             inviter_id = str(inviter["_id"])
             if inviter_id != self.user_id:
                 query["inviter"] = inviter_id
                 self.db.Invitation.insert(query)
                 push_msg(
                     inviter_id, u"你已邀请了" +
                     self.get_user_info(keys=('nickname', ))['nickname'])
                 return self.write_success()
     return self.write_err()
コード例 #7
0
 def post(self):
     order_num = self.get_argument('order_num')
     # 订单状态置为2
     query = {"order_num": order_num}
     order = self.db.Order.find_one(query)
     self.db.Order.update(query, {"$set": {"status": "2"}})
     # 同步卖家余额
     money = float(order['goods_info']['price'])
     self.db.User.update({"_id": ObjectId(order['seller_id'])},
                         {'$inc': {
                             'balance': money
                         }})
     # 清除缓存
     self.clear_cache("UserInfo:%s" % order['seller_id'])
     # 推送消息
     goods_name = order['goods_info']['goods_name']
     push_msg(order['seller_id'],
              u'商品%s已确认收货,货款已到账' % goods_name,
              extra="extra_my_account")
     return self.write_success()
コード例 #8
0
ファイル: user_handler.py プロジェクト: xiaolong321/backend
 def post(self):
     user_id = self.get_argument('user_id')
     action = self.get_argument('action')
     query = {'_id': ObjectId(user_id)}
     if action == "0":
         self.db.User.update(query, {'$set': {'verify_status': "0"}})
         push_msg(user_id, u"您的身份验证未通过,信息不符合要求", extra="extra_mine")
     else:
         info = self.db.User_verify.find_one(query)
         self.db.User.update(
             query, {
                 '$set': {
                     'verify_status': "2",
                     'phone': info['phone'],
                     'alipay': info['alipay']
                 }
             })
         self.db.User_verify.update(query, {'$set': {'status': "1"}})
         push_msg(user_id, u"您的身份验证已通过", extra="extra_mine")
     # self.db.User_verify.remove(query)
     return self.write_success()
コード例 #9
0
    def addItem(self, type, **kwargs):
        '''交易成功、提现时会调用'''
        # param type  提现: 0, 交易: 1
        # kwargs 'order_num', 'money'

        # 要插入UserAccount的数据字典
        now = int(time.time())
        if type > 0:
            # 若为交易
            # 先取出订单对象看自己是买家还是卖家
            order_num = kwargs['order_num']
            order = self.db.Order.find_one({'order_num': order_num})
            if not order:
                return False
            # 生成我的账户记录
            if self.db.User_account.find({"order_id": str(order['_id'])}).count():
                return
            data = {"order_id": str(order['_id']), "time": now}
            data2 = {"order_id": str(order['_id']), "time": now}
            data['user_id'] = order['custom_id']
            data['type'] = 1
            self.db.User_account.insert(data)
            data2['user_id'] = order['seller_id']
            data2['type'] = 2
            self.db.User_account.insert(data2)
            # 商品下架
            self.db.Goods.update({"_id": ObjectId(order['goods_id'])}, {"$set": {'status': '1'}})
            # 清除缓存
            self.clear_cache("GoodsInfo:%s" % order['goods_id'])
            # 推送消息
            goods_name = order['goods_info']['goods_name']
            push_msg(order['seller_id'], u'请尽快联系买家完成交易并让TA确认收货', u'趣淘上的商品被购买')
            # push_msg(order['custom_id'], u'成功支付购买%s,请联系卖家完成交易 ' % goods_name)
        else:
            data = {"user_id": self.user_id, "money": float(kwargs['money']), "type": type, "time": now}
            return self.db.User_account.insert(data)