def post(self): data = request.get_json() db = DBDao() sql = "update goods set order_state='%s' where order_id=%d" % ( data['orderState'], int(data['orderId'])) db.setBySql(sql) return True
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()
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
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'}
def post(self): req = request.get_json() expresscode = req['expressCode'] url = 'http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx' data = get_company(expresscode, EXPRESS_APPID, EXPRESS_APPKEY, url) if not any(data['Shippers']): print "未查到该快递信息,请检查快递单号是否有误!" return False else: print "已查到该", data['Shippers'][0]['ShipperName'] + "(" + data[ 'Shippers'][0]['ShipperCode'] + ")", expresscode # 记录入数据库 db = DBDao() sql = "update goods set express_com ='%s',express_code = '%s' where order_id=%d" % ( data['Shippers'][0]['ShipperCode'], expresscode, int(req['orderId'])) db.setBySql(sql) # trace_data = get_traces(expresscode, data['Shippers'][0]['ShipperCode'], EXPRESS_APPID, EXPRESS_APPKEY, url) # if trace_data['Success'] == "false" or not any(trace_data['Traces']): # print "未查询到该快递物流轨迹!" # else: # str_state = "问题件" # if trace_data['State'] == '2': # str_state = "在途中" # if trace_data['State'] == '3': # str_state = "已签收" # print "目前状态: " + str_state # trace_data = trace_data['Traces'] # item_no = 1 # for item in trace_data: # print str(item_no) + ":", item['AcceptTime'], item['AcceptStation'] # item_no += 1 # print("\n") return { "Shipper": data['Shippers'][0]['ShipperName'], "ShipperCode": data['Shippers'][0]['ShipperCode'], "ExpressCode": expresscode }
def post(self): db = DBDao() data = request.get_json() # raw_remote_addr = request.remote_addr # remote_addr = request.headers # remote_addr = request.headers['remote-user-ip'] params = {} params["spbill_create_ip"] = request.remote_addr params["body"] = data['body'] params["out_trade_no"] = self.getOutTradeNo() params["total_fee"] = data['totalFee'] params["notify_url"] = "mgmt.uzhigou.com/wxpay/pay-bill" params["trade_type"] = "MWEB" params[ "scene_info"] = '{"h5_info": {"type":"Wap","wap_url": "https://uzhigou.com","wap_name": "优值购商品付款"}}' req = UnifiedOrder_pub() req.parameters = params mweb_url = req.getMWEBUrl() # 将商户订单号存入对应商品数据中作为付款标识 sql = "update goods set out_trade_no='%s' where order_id=%d" % ( params["out_trade_no"], int(data['orderId'])) db.setBySql(sql) return mweb_url
def post(self): data = request.get_json() # 如有图片,拷贝到临时文件夹 base_path = path.abspath(path.dirname(__file__)) imgPathList = data['imgsPathArr'].split(',') if imgPathList != [u'']: for item in imgPathList: shutil.copyfile( path.join(base_path, item), path.join(base_path, TEMP_UPLOAD_FOLDER + item[6:])) db = DBDao() sql = "insert into goods(order_time, goods_name_cn,goods_name_en,specifications,goods_num,msg,ref_url," \ + "imgs_id_list,delivery_name,delivery_phone,delivery_addr,delivery_mode,user_id,imgs_path_list) " \ + "values (%f,'%s','%s','%s', %d,'%s','%s','%s','%s','%s','%s','%s',%d,'%s')" \ % (data['generationTime'], data['goodsCNName'], data['goodsEnName'], data['specifications'], data['goodsNum'], data['msg'], data['refUrl'], data['imgsIdArr'], data['userName'], data['userPhone'], data['addr'], data['pickUpMode'], data['workerId'], data['imgsPathArr']) newId = db.setBySql(sql) if newId != -1: Timer(259200, self.cancel_order, ( db, newId, )).start() return True