def create_self_operated_order(cls, count=1, entrepot_id='30', shipment_type='1', receive_street_id='111010507', send_city='1110105', distributor='autoexpress', armoney='47.99', order_type='1', pay_id='1', thread_no='', interval='0.001', producer=None): """ 创建自营运单 :param pay_id: :param order_type: :param count: :param entrepot_id: :param shipment_type: :param receive_street_id: :param distributor: :param armoney: :param thread_no: :param interval: :param producer: :return: """ msg = innerInvokerMessage.create_self_operated_order \ .replace('${entrepot_id}', entrepot_id) \ .replace('${shipment_type}', shipment_type) \ .replace('${receive_street_id}', receive_street_id) \ .replace('${send_city}', send_city) \ .replace('${distributor}', str(BaseInfo.get_distributor_or_subdistributor_id(short_name=distributor))) \ .replace('${armoney}', armoney) \ .replace('${order_type}', order_type)\ .replace('${pay_id}', pay_id) sleep_time = float(interval) init_id = int(thread_no + _generate_order_id()) order_ids = map(lambda i: str(init_id + i), range(int(count))) g = lambda x: producer.produce(msg.replace('${order_id}', x)) if producer is None: print msg.decode('utf-8') client = KafkaClient(hosts=tmsBase.kafka_client) topic = client.topics[KafkaTopics.RAINBOW.value] with topic.get_producer() as producer: map(lambda i: g(i), order_ids) else: for order_id in order_ids: g(order_id) sleep(sleep_time) print order_ids return order_ids, len(order_ids)
def express_confirm_direct_return(cls, account='AUTOEXPRESS', order_ids=[], distributor_short_name=''): """ 快递直退 :param account: :param order_ids: :param distributor_short_name: :return: """ print u'*' * 20 + u'快递直退' ids = '' for order_id in order_ids: ids += order_id ids += '\n' obj = demjson.decode(ExpressUtil.express_get_direct_return_info(account=account, order_ids=order_ids)) if int(obj['total']) != len(order_ids): raise StandardError(u'>>>>>>>>>>有错误的运单号') keys = '' for item in obj['rows']: keys += item['id'] keys += ',' url = tmsBase.base_url + '/tms/goods/expressReturnStraightGoodsController/returnStraight.do' data = dict() data['deliveryDealer'] = BaseInfo.get_distributor(short_name=distributor_short_name) data['ids'] = ids data['returnGoodsExpnumber'] = datetime.now().strftime('%y%m%d%H%M%S') resp = HttpRequest.post_request(TmsLogin.get_session(account), url, data=data) print u'退货快递单号:' + data['returnGoodsExpnumber'] print resp return data['returnGoodsExpnumber'], resp
# reload(sys) # sys.setdefaultencoding('gbk') sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..\\..\\..\\')) from keywords.tms.base.baseInfo import BaseInfo from keywords.tms.express.expressFlow import ExpressFlow from keywords.tms.rainbow import RainbowFlow from parameters.tms import tmsBase if __name__ == '__main__': if len(sys.argv) != 9: print '请输入运单号'.decode('utf-8') sys.exit(-1) if BaseInfo.get_distributor_id(account='ADMIN', distributor_short_name=sys.argv[2].decode('gbk')) == 0: obj = BaseInfo.get_subdistributor_id(subdistributor_short_name=sys.argv[2].decode('gbk')) delivery_dealer = obj[0] + '-' + obj[1] else: delivery_dealer = BaseInfo.get_distributor_id(account='ADMIN', distributor_short_name=sys.argv[2].decode('gbk')) + '-' order_ids = sys.argv[1].split(',') RainbowFlow.sorting_forward_to_delivery_dealer(order_ids=order_ids, delivery_dealer=delivery_dealer, is_merchant=sys.argv[3] == 'True' and True or False, is_packaged=sys.argv[4] == 'True' and True or False, account=sys.argv[7]) target = sys.argv[5] if target != '0': sleep(tmsBase.wait_time)
# -*- encoding:utf-8 -*- import sys # reload(sys) # sys.setdefaultencoding('gbk') import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..\\..\\..\\')) from keywords.tms.base.baseInfo import BaseInfo from keywords.tms.interface.expressInvoker import ExpressInvoker if __name__ == '__main__': distributor_id = str(BaseInfo.get_distributor_or_subdistributor_id(short_name=sys.argv[1].decode('gbk'))) ExpressInvoker.feedback_instorage(distributor_id=distributor_id, order_ids=sys.argv[2].split(','))
from keywords.tms.base.baseInfo import BaseInfo from keywords.tms.rainbow import RainbowFlow, RainbowUtil from keywords.tms.express.expressFlow import ExpressFlow from keywords.tms.express.expressUtil import ExpressUtil from parameters.tms import tmsBase from keywords.tms.interface.posInvoker import PosInvoker __author__ = 'bida' if __name__ == '__main__': order_ids = InnerInvoker.create_self_operated_order(count=2)[0] sleep(tmsBase.wait_time) if BaseInfo.get_distributor_id(account='ADMIN', distributor_short_name='autoexpress') == 0: obj = BaseInfo.get_subdistributor_id(subdistributor_short_name='autoexpress') delivery_dealer = obj[0] + '-' + obj[1] else: delivery_dealer = BaseInfo.get_distributor_id(account='ADMIN', distributor_short_name='autoexpress') + '-' RainbowFlow.sorting_forward_to_delivery_dealer(order_ids=order_ids, delivery_dealer=delivery_dealer, account='TIANJINSORTING') sleep(tmsBase.wait_time) ExpressFlow.express_delivery(target='2', order_ids=order_ids, feedback_result='SUCCESS', account='AUTOEXPRESS') sleep(tmsBase.wait_time)
def create_merchant_order(cls, count=1, items=1, entrepot_id='30', receive_street_id='111010507', send_city='1110105', shipment_type='1', client_order_type='1', distributor='autoexpress', shop_id='0001', pay_id='1', should_receive_payment='56.00', thread_no='', interval='0.001', producer=None): """ 创建招商运单 :param send_city: :param should_receive_payment: :param pay_id: :param shop_id:商户编号 :param distributor: :param client_order_type: :param count:消息数 :param items:每条消息包含运单数 :param entrepot_id:发货仓库 :param receive_street_id:收货街道id :param shipment_type:配送方式 :param thread_no: :param interval: :param producer: :return: """ item_msg = innerInvokerMessage.merchant_order_item \ .replace('${entrepot_id}', entrepot_id) \ .replace('${receive_street_id}', receive_street_id) \ .replace('${send_city}', send_city) \ .replace('${shipment_type}', shipment_type) \ .replace('${client_order_type}', client_order_type) \ .replace('${distributor}', str(BaseInfo.get_distributor_or_subdistributor_id(short_name=distributor))) \ .replace('${shop_id}', shop_id).replace('${pay_id}', pay_id)\ .replace('${should_receive_payment}', should_receive_payment) items_msg = '' order_ids = list() sleep_time = float(interval) if producer is None: print item_msg.decode('utf-8') client = KafkaClient(hosts=tmsBase.kafka_client) topic = client.topics[KafkaTopics.RAINBOW.value] with topic.get_producer() as producer: for j in range(int(count)): init_id = int(thread_no + _generate_order_id()) ids = map(lambda l: str(init_id + l), range(int(items))) for order_id in ids: items_msg += item_msg.replace('${order_id}', order_id) producer.produce(innerInvokerMessage.create_merchant_order.replace('${items_info}', items_msg[:-1])) order_ids += ids sleep(sleep_time * 1000) else: for j in range(int(count)): for i in range(int(items)): order_id = thread_no + _generate_order_id() items_msg += item_msg.replace('${order_id}', order_id) order_ids.append(order_id) sleep(sleep_time) producer.produce(innerInvokerMessage.create_merchant_order.replace('${items_info}', items_msg[:-1])) print order_ids return order_ids, len(order_ids)
def create_change_and_refund_order(cls, count=1, operate_type='3', entrepot_id='30', send_city='1110105', receive_street_id='111010507', distributor='autoexpress', armoney='47.99', pay_id='1', shipment_type='1', thread_no='', interval='0.001', producer=None): """ 创建退换货运单 :param pay_id: :param thread_no: :param count: :param operate_type: 3:退货,4:换货 :param entrepot_id: :param receive_street_id: :param distributor: :param armoney: :param interval: :param producer: :return """ if operate_type == '3': exchange_no = '0' return_no = '1' last_no = '0' if operate_type == '4': exchange_no = '1' return_no = '0' last_no = '1' if operate_type == 'other': operate_type = '10' exchange_no = '5' return_no = '0' last_no = '3' msg = innerInvokerMessage.create_change_and_refund_order \ .replace('${entrepot_id}', entrepot_id) \ .replace('${receive_street_id}', receive_street_id) \ .replace('${send_city}', send_city) \ .replace('${distributor}', str(BaseInfo.get_distributor_or_subdistributor_id(short_name=distributor))) \ .replace('${armoney}', armoney) \ .replace('${order_type}', operate_type) \ .replace('${promise_time}', (datetime.now() + timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S')) \ .replace('${start_time}', datetime.now().strftime('%Y-%m-%d %H:%M:%S'))\ .replace('${pay_id}', pay_id)\ .replace('${shipment_type}', shipment_type)\ .replace('${exchangeNum}', exchange_no)\ .replace('${returnNum}', return_no)\ .replace('${lastNum}', last_no) sleep_time = float(interval) init_id = int(thread_no + _generate_order_id()) order_ids = map(lambda i: str(init_id + i), range(int(count))) g = lambda i: producer.produce(msg.replace('${order_id}', i)) if producer is None: print msg.decode('utf-8') client = KafkaClient(hosts=tmsBase.kafka_client) topic = client.topics[KafkaTopics.RAINBOW.value] with topic.get_producer() as producer: map(lambda x: g(x), order_ids) else: for order_id in order_ids: g(order_id) sleep(sleep_time) print order_ids return order_ids, len(order_ids)