Ejemplo n.º 1
0
 def post(self):
     data = request.get_json()
     db = DBDao()
     sql = "select * from goods where order_id = %d" % (int(
         data['orderId']))
     res = db.getOneBySql(sql)
     resp = {"expressCom": res[16], "expressCode": res[17]}
     return resp
Ejemplo n.º 2
0
 def post(self):
     order_id = request.get_json()['orderId']
     db = DBDao()
     sql = "select single_price from purchasefinal where order_id = %d" % (
         int(order_id))
     price = db.getOneBySql(sql)
     # 对价格进行分类处理
     if price:
         final_price = self.getFinalPrice(price[0])
         return {'price': final_price}
     else:
         return {'price': -1}
Ejemplo n.º 3
0
    def post(self):
        db = DBDao()
        data = request.get_json()

        return_code_ = data['return_code']
        params = {}

        if return_code_ == 'SUCCESS':
            params['sign'] = data['sign']
            params['result_code'] = data['result_code']
            params['openid'] = data['openid']
            params['total_fee'] = data['total_fee']
            params['settlement_total_fee'] = data['settlement_total_fee']
            params['time_end'] = data['time_end']
            params['out_trade_no'] = data['out_trade_no']

            # 用户成功付款后,改变订单状态并通知相应采购发货 TODO 验证付款金额
            sql = "update goods set order_state='%s' where out_trade_no='%s'" % (
                '已接单已付款', data['out_trade_no'])
            db.setBySql(sql)
            sql = "select order_id,user_id where out_trade_no = '%s'" % (
                data['out_trade_no'])
            queryGoods = db.getOneBySql(sql)
            sql = "select user_name,user_phone where user_id = %d" % (int(
                queryGoods[1]))
            queryUser = db.getOneBySql(sql)

            single_sender = SmsSender.SmsSingleSender(SMS_APPID, SMS_APPKEY)
            result = single_sender.send_with_param(
                "86", queryUser[1], 94155, [queryUser[0], queryGoods[0]],
                "优值购平台", "", "")
            print result
        else:
            params['result_code'] = data['result_code']
            params['result_msg'] = data['return_msg']

        print params
        return {'return_code': 'SUCCESS'}
Ejemplo n.º 4
0
 def post(self):
     data = request.get_json()
     db = DBDao()
     # 1.往采购状态表中加入订单记录
     sql = "insert into purchasestate(order_id, user_id,is_receive,price_offer) " \
           + "values (%d,%d,'%s',%f)" % (
         int(data['orderId']), int(data['userId']), data['isReceive'], data['priceOffer'])
     db.setBySql(sql)
     # 2.查询是否已经有人接了此单,如果没有则为首次接单,则开始计时,1天后竞价
     sql = "select count(*) from purchasestate where order_id=%d and is_receive='%s' and user_id !=%d" % (
         int(data['orderId']), data['isReceive'], int(data['userId']))
     cnt = db.getOneBySql(sql)
     # 3.如果第一次接单,则定时1天后结束竞价 TODO
     if cnt == (0L, ):
         Timer(86400, self.find_lowest_price, (db, data)).start()
Ejemplo n.º 5
0
    def post(self):
        data = request.get_json()
        db = DBDao()
        sql = "select * from user where user_phone = '%s' and user_psd = '%s'" % (
            data['username'], data['password'])
        user = db.getOneBySql(sql)
        if user:
            res_data = {
                'userId': user[0],
                'userName': user[1],
                'userPhone': user[2],
                'userIdentification': user[3],
                'msg': True
            }
        else:
            res_data = {'msg': False}

        return res_data
Ejemplo n.º 6
0
 def post(self):
     data = request.get_json()
     db = DBDao()
     sql = "select user_id from goods where order_id = %d" % (
         data['orderId'])
     userId = db.getOneBySql(sql)
     if userId == (0, ):
         sql = "update goods set order_time=%f, goods_name_cn='%s',goods_name_en='%s',specifications='%s',goods_num=%d," \
               "msg='%s',ref_url='%s',imgs_id_list='%s',delivery_name='%s',delivery_phone='%s',delivery_addr='%s'," \
               "delivery_mode='%s',user_id=%d,imgs_path_list='%s' where order_id=%d" \
               % (data['generationTime'], data['goodsCNName'], data['goodsEnName'], data['specifications'],
                  data['goodsNum'], data['msg'], data['refUrl'], data['imgsIdArr'], data['userName'],
                  data['userPhone'], data['addr'], data['pickUpMode'], int(data['workerId']), data['imgsPathArr'],
                  data['orderId'])
         db.setBySql(sql)
         return True
     else:
         return False
Ejemplo n.º 7
0
    def post(self):
        order_id = request.get_json()['orderId']
        if order_id:
            db = DBDao()
            # 从商品表中找到该订单
            try:
                sql = "select * from goods where order_id = %d" % (
                    int(order_id))
                goods = db.getOneBySql(sql)

                if goods:
                    res_data = {
                        'orderId': goods[0],
                        'orderTime': goods[1],
                        'goodsNameCN': goods[2],
                        'goodsNameEN': goods[3],
                        'specifications': goods[4],
                        'goodsNum': goods[5],
                        'msg': goods[6],
                        'refUrl': goods[7],
                        'imgIdList': goods[8],
                        'imgPathList': goods[15],
                        'deliveryName': goods[9],
                        'deliveryPhone': goods[10],
                        'deliveryAddr': goods[11],
                        'deliveryMode': goods[12],
                        'userId': goods[13],
                        'orderState': goods[14]
                    }
                else:
                    res_data = {'msg': False}
            except:
                res_data = {'msg': 'Error'}
                traceback.print_exc()
        else:
            res_data = {'msg': False}
        return res_data
Ejemplo n.º 8
0
 def get(self, identification, user_id, state):
     db = DBDao()
     sql = ""
     # 根据人员身份和订单状态查找数据
     if identification == u'管理员':
         if state == 'wait':
             order_state = '未接单'
         elif state == 'underway':
             order_state = '已接单'
         elif state == 'completed':
             order_state = '已完成'
         sql = "select * from goods where substr(order_state,1,3) = '%s'" % (
             order_state)
         orders = db.getAllBySql(sql)
     elif identification == u'采购':
         if state == 'wait':
             order_state = '未接单'
             # 1.先去查找该员工处理过的订单编号
             sql = "select order_id from purchasestate where user_id = %d" % (
                 int(user_id))
             orderIdList = list(db.getAllBySql(sql))
             # 2.排除拒接订单
             sql = "select * from goods where order_state ='%s' and user_id != 0" % (
                 order_state)
             tempOrders = list(db.getAllBySql(sql))
             orders = copy.deepcopy(tempOrders)
             for key, value in enumerate(tempOrders):
                 # 判断(id,)这种格式表示的id是否在list中
                 if (value[0], ) in orderIdList:
                     # 排除该订单
                     orders.remove(value)
         elif state == 'underway':
             order_state = '已接单'
             # 1.去最终确定的采购表中找自己id下的订单编号
             sql = "select order_id from purchasefinal where user_id = %d" % (
                 int(user_id))
             orderIdList = list(db.getAllBySql(sql))
             # 2.根据编号去商品表中查找订单详情
             orders = []
             for key, value in enumerate(orderIdList):
                 # python中的占位符碰到like匹配时,应在占位符外包裹%%
                 sql = "select * from goods where substr(order_state,1,3) = '%s' and order_id= %d " % (
                     order_state, value[0])
                 order = db.getOneBySql(sql)
                 # 如果为空说明订单已完成或被取消
                 if order != None:
                     orders.append(db.getOneBySql(sql))
         elif state == 'completed':
             order_state = '已完成'
             sql = "select * from goods where order_state ='%s' and user_id=%d" % (
                 order_state, int(user_id))
             orders = db.getAllBySql(sql)
     elif identification == u'客服':
         if state == 'wait':
             # 只出现未经完善的订单
             sql = "select * from goods where user_id = 0"
         elif state == 'underway':
             # 所有正在进行的订单都可以查看,方便客服管理
             order_state = '接单'
             sql = "select * from goods where substr(order_state,2,2) = '%s' and user_id != 0" % (
                 order_state)
         elif state == 'completed':
             order_state = '已完成'
             sql = "select * from goods where order_state ='%s'" % (
                 order_state)
         orders = db.getAllBySql(sql)
     # 未知问题,必须转为list而不能直接返回tuple
     return list(orders)