def yidaozhan(merchantToken, generateFenBoDan, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId, pzdRollOutPoint, pzdRollInPoint, pzdId, fbdId, fbdRollOutPoint, fbdRollInPoint, fbdToken, pzdToken): # 定义接口的返回值 yiDaoZhanResult = {"status": 0, "message": '', "tydId": ''} #创建已发车状态的配载单 yunShuZhongResult = yunShuZhong.yunshuzhong( merchantToken, generateFenBoDan, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId, pzdRollOutPoint, pzdRollInPoint, pzdId, fbdId, fbdRollOutPoint, fbdRollInPoint, fbdToken, pzdToken) if yunShuZhongResult['status'] == 200: #配载单到货确认 tydbId = mysql.getTydbId(yunShuZhongResult['tydId']) pzdDaoZhanResult = createPeiZaiDan.pzd_yiDaoZhan( merchantToken, pzdId, tydbId, pzdToken) if pzdDaoZhanResult['status'] == 200: yiDaoZhanResult['status'] = pzdDaoZhanResult['status'] yiDaoZhanResult['message'] = pzdDaoZhanResult['message'] yiDaoZhanResult['tydId'] = yunShuZhongResult['tydId'] print("已到站状态的托运单创建成功") else: yiDaoZhanResult['status'] = pzdDaoZhanResult['status'] yiDaoZhanResult['message'] = pzdDaoZhanResult['message'] print("配载单到货确认失败") else: yiDaoZhanResult['status'] = yunShuZhongResult['status'] yiDaoZhanResult['message'] = yunShuZhongResult['message'] print("已到站状态的托运单创建失败") return yiDaoZhanResult
def yiPeiSongWaitTransport( merchantToken, generateFenBoDan, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId, pzdRollOutPoint, pzdRollInPoint, pzdId, fbdId, fbdRollOutPoint, fbdRollInPoint, fbdToken, pzdToken, psdId, deliveryPoint): deliveryPointId = mysql.getStationId(deliveryPoint) # 定义接口的返回值 yiPeiSongWaitTransportResult = {"status": 0, "message": '', "tydId": ''} #创建已到货确认的托运单(已到站状态) yiDaoZhanResult = yiDaoZhan.yidaozhan( merchantToken, generateFenBoDan, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId, pzdRollOutPoint, pzdRollInPoint, pzdId, fbdId, fbdRollOutPoint, fbdRollInPoint, fbdToken, pzdToken) if yiDaoZhanResult['status'] == 200: #创建配送单 tydbId = mysql.getTydbId(yiDaoZhanResult['tydId']) createPeiSongDanResult = createPeiSongDan.createPeiSongDan( merchantToken, fbdToken, psdId, tydbId, createrName, createrId, deliveryPointId) if createPeiSongDanResult['status'] == 200: yiPeiSongWaitTransportResult['status'] = createPeiSongDanResult[ 'status'] yiPeiSongWaitTransportResult['message'] = createPeiSongDanResult[ 'message'] yiPeiSongWaitTransportResult['tydId'] = yiDaoZhanResult['tydId'] print("已配送状态的托运单创建成功(配送单待运输)") else: yiPeiSongWaitTransportResult['status'] = createPeiSongDanResult[ 'status'] yiPeiSongWaitTransportResult['message'] = createPeiSongDanResult[ 'message'] print("配送单创建失败!") else: yiPeiSongWaitTransportResult['status'] = yiDaoZhanResult['status'] yiPeiSongWaitTransportResult['message'] = yiDaoZhanResult['message'] print("已配送状态的托运单创建失败(配送单待运输)") return yiPeiSongWaitTransportResult
def yiQianShou(merchantToken, generateFenBoDan, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId, pzdRollOutPoint, pzdRollInPoint, pzdId, fbdId, fbdRollOutPoint, fbdRollInPoint, fbdToken, pzdToken, psdId, deliveryPoint, createPeiSongDan): # 定义接口的返回值 yiQianShouResult = {"status": 0, "message": '', "tydId": ''} if createPeiSongDan == "是": yiPeiSongTransportingResult = yiPeiSongTransporting.yiPeiSongTransporting( merchantToken, generateFenBoDan, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId, pzdRollOutPoint, pzdRollInPoint, pzdId, fbdId, fbdRollOutPoint, fbdRollInPoint, fbdToken, pzdToken, psdId, deliveryPoint) if yiPeiSongTransportingResult['status'] == 200: tydId = yiPeiSongTransportingResult['tydId'] tydbId = mysql.getTydbId(tydId) #签收单签收 qianShouResult = qianShouDanSave(merchantToken, pzdToken, tydbId, goodsName, tydId, sendStationId, receiveStationId) if qianShouResult['status'] == 200: yiQianShouResult['status'] = qianShouResult['status'] yiQianShouResult['message'] = qianShouResult['message'] yiQianShouResult['tydId'] = yiPeiSongTransportingResult[ 'tydId'] print("已签收状态的托运单创建成功") else: yiQianShouResult['status'] = qianShouResult['status'] yiQianShouResult['message'] = qianShouResult['message'] print("签收单签收失败!") else: yiQianShouResult['status'] = yiPeiSongTransportingResult['status'] yiQianShouResult['message'] = yiPeiSongTransportingResult[ 'message'] print("已签收状态的托运单创建失败") else: yiDaoZhanResult = yiDaoZhan.yidaozhan( merchantToken, generateFenBoDan, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId, pzdRollOutPoint, pzdRollInPoint, pzdId, fbdId, fbdRollOutPoint, fbdRollInPoint, fbdToken, pzdToken) if yiDaoZhanResult['status'] == 200: tydId = yiDaoZhanResult['tydId'] tydbId = mysql.getTydbId(tydId) #签收单签收 qianShouResult = qianShouDanSave(merchantToken, pzdToken, tydbId, goodsName, tydId, sendStationId, receiveStationId) if qianShouResult['status'] == 200: yiQianShouResult['status'] = qianShouResult['status'] yiQianShouResult['message'] = qianShouResult['message'] yiQianShouResult['tydId'] = yiDaoZhanResult['tydId'] print("已签收状态的托运单创建成功") else: yiQianShouResult['status'] = qianShouResult['status'] yiQianShouResult['message'] = qianShouResult['message'] print("签收单签收失败!") else: yiQianShouResult['status'] = yiDaoZhanResult['status'] yiQianShouResult['message'] = yiDaoZhanResult['message'] print("已签收状态的托运单创建失败") return yiQianShouResult
def yunshuzhong(merchantToken, generateFenBoDan, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId, pzdRollOutPoint, pzdRollInPoint, pzdId, fbdId, fbdRollOutPoint, fbdRollInPoint, fbdToken, pzdToken): pzdRollOutId = mysql.getStationId(pzdRollOutPoint) pzdRollInPointId = mysql.getStationId(pzdRollInPoint) if generateFenBoDan == "否": if pickGoodsWay == "自送上门": #不创建分拨单,不创建提货单 tyd_id = new_YiRuKu.yiruku(merchantToken, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName) tydbId = mysql.getTydbId(tyd_id) #创建配载单 createPeiZaiDan.createPeiZaiDan(merchantToken, pzdId, tydbId, createrName, createrId, pzdRollOutId, pzdRollOutPoint, pzdRollInPointId, pzdRollInPoint) #配载单发车 createPeiZaiDan.pzd_yiFaChe(merchantToken, pzdId, pzdToken) print("不创建分拨单,不创建提货单") else: #不创建分拨单,要创建提货单 tyd_id = yiRuKu.yiruku(merchantToken, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId) tydbId = mysql.getTydbId(tyd_id) # 创建配载单 createPeiZaiDan.createPeiZaiDan(merchantToken, pzdId, tydbId, createrName, createrId, pzdRollOutId, pzdRollOutPoint, pzdRollInPointId, pzdRollInPoint) # 配载单发车 createPeiZaiDan.pzd_yiFaChe(merchantToken, pzdId, pzdToken) print("不创建分拨单,要创建提货单,再创建配载单") if generateFenBoDan == "是": fbdRollOutPointId = mysql.getStationId(fbdRollOutPoint) fbdRollInPointId = mysql.getStationId(fbdRollInPoint) if pickGoodsWay == "自送上门": # 不创建提货单,直接创建已入库的托运单 tyd_id = new_YiRuKu.yiruku(merchantToken, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName) tydbId = mysql.getTydbId(tyd_id) # 创建分拨单 createFenBoDan.createFenBoDan(merchantToken, fbdToken, fbdId, tydbId, createrName, createrId, fbdRollOutPointId, fbdRollOutPoint, fbdRollInPointId, fbdRollInPoint) # 创建配载单 createPeiZaiDan.createPeiZaiDan(merchantToken, pzdId, tydbId, createrName, createrId, pzdRollOutId, pzdRollOutPoint, pzdRollInPointId, pzdRollInPoint) # 配载单发车 createPeiZaiDan.pzd_yiFaChe(merchantToken, pzdId, pzdToken) print("创建分拨单,不创建提货单") else: # 创建提货单,再创建已入库的托运单 tyd_id = yiRuKu.yiruku(merchantToken, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId) tydbId = mysql.getTydbId(tyd_id) # 创建分拨单 createFenBoDan.createFenBoDan(merchantToken, fbdToken, fbdId, tydbId, createrName, createrId, fbdRollOutPointId, fbdRollOutPoint, fbdRollInPointId, fbdRollInPoint) # 创建配载单 createPeiZaiDan.createPeiZaiDan(merchantToken, pzdId, tydbId, createrName, createrId, pzdRollOutId, pzdRollOutPoint, pzdRollInPointId, pzdRollInPoint) # 配载单发车 createPeiZaiDan.pzd_yiFaChe(merchantToken, pzdId, pzdToken) print("创建分拨单,要创建提货单") return tyd_id
def yipeizai(merchantToken,generateFenBoDan,createrName,createrId,pickGoodsWay,sendStationId, sendStationName,receiveStationId,receiveStationName,goodsName,thdId,takeGoodsStation,takeGoodsStationId, pzdRollOutPoint,pzdRollInPoint,pzdId,fbdId,fbdRollOutPoint,fbdRollInPoint,fbdToken) : pzdRollOutId = mysql.getStationId(pzdRollOutPoint) pzdRollInPointId = mysql.getStationId(pzdRollInPoint) # 定义接口的返回值 peiZaiResult = {"status": 0, "message": '', "tydId": ''} if generateFenBoDan == "否": if pickGoodsWay == "自送上门": #不创建分拨单,不创建提货单,创建托运单 ruKuResult = new_YiRuKu.yiruku(merchantToken, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName) if ruKuResult['status'] == 200: tydbId = mysql.getTydbId(ruKuResult['tydId']) #创建配载单 createPeiZaiDanResult = createPeiZaiDan.createPeiZaiDan(merchantToken,pzdId,tydbId,createrName,createrId,pzdRollOutId,pzdRollOutPoint ,pzdRollInPointId,pzdRollInPoint) if createPeiZaiDanResult['status'] == 200: peiZaiResult['status'] = createPeiZaiDanResult['status'] peiZaiResult['message'] = createPeiZaiDanResult['message'] peiZaiResult['tydId'] = ruKuResult['tydId'] print("不创建分拨单,不创建提货单,已配载状态的托运单创建成功") else: peiZaiResult['status'] = createPeiZaiDanResult['status'] peiZaiResult['message'] = createPeiZaiDanResult['message'] print("不创建分拨单,不创建提货单,已配载状态的托运单创建失败") else: peiZaiResult['status'] = ruKuResult['status'] peiZaiResult['message'] = ruKuResult['message'] print("创建已配载状态的托运单时,托运单创建失败") else : #不创建分拨单,要创建提货单,创建托运单 ruKuResult = yiRuKu.yiruku(merchantToken, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId) if ruKuResult['status'] == 200: tydbId = mysql.getTydbId(ruKuResult['tydId']) # 创建配载单 createPeiZaiDanResult = createPeiZaiDan.createPeiZaiDan(merchantToken, pzdId, tydbId, createrName, createrId, pzdRollOutId, pzdRollOutPoint,pzdRollInPointId, pzdRollInPoint) if createPeiZaiDanResult['status'] == 200: peiZaiResult['status'] = createPeiZaiDanResult['status'] peiZaiResult['message'] = createPeiZaiDanResult['message'] peiZaiResult['tydId'] = ruKuResult['tydId'] print("不创建分拨单,要创建提货单,已配载状态的托运单创建成功") else: peiZaiResult['status'] = createPeiZaiDanResult['status'] peiZaiResult['message'] = createPeiZaiDanResult['message'] print("不创建分拨单,要创建提货单,已配载状态的托运单创建失败") if generateFenBoDan == "是" : fbdRollOutPointId = mysql.getStationId(fbdRollOutPoint) fbdRollInPointId = mysql.getStationId(fbdRollInPoint) if pickGoodsWay == "自送上门": # 不创建提货单,直接创建已入库的托运单 ruKuResult = new_YiRuKu.yiruku(merchantToken, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName) if ruKuResult['status'] == 200: tydbId = mysql.getTydbId(ruKuResult['tydId']) # 创建分拨单 createFenBoDanResult = createFenBoDan.createFenBoDan(merchantToken,fbdToken, fbdId, tydbId, createrName, createrId, fbdRollOutPointId, fbdRollOutPoint,fbdRollInPointId, fbdRollInPoint) if createFenBoDanResult['status'] == 200: # 创建配载单 createPeiZaiDanResult = createPeiZaiDan.createPeiZaiDan(merchantToken, pzdId, tydbId, createrName, createrId, pzdRollOutId,pzdRollOutPoint, pzdRollInPointId,pzdRollInPoint) if createPeiZaiDanResult['status'] == 200: peiZaiResult['status'] = createPeiZaiDanResult['status'] peiZaiResult['message'] = createPeiZaiDanResult['message'] peiZaiResult['tydId'] = ruKuResult['tydId'] print("创建分拨单,不创建提货单,已配载状态的托运单创建成功") else: peiZaiResult['status'] = createPeiZaiDanResult['status'] peiZaiResult['message'] = createPeiZaiDanResult['message'] print("创建分拨单,不创建提货单,已配载状态的托运单创建失败") else: peiZaiResult['status'] = createFenBoDanResult['status'] peiZaiResult['message'] = createFenBoDanResult['message'] print("分拨单创建失败,已配载状态的托运单创建失败") else: peiZaiResult['status'] = ruKuResult['status'] peiZaiResult['message'] = ruKuResult['message'] print("托运单创建失败,已配载状态的托运单创建失败") else: # 创建提货单,再创建已入库的托运单 ruKuResult = yiRuKu.yiruku(merchantToken, createrName, createrId, pickGoodsWay, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId) #print "ruKuResult:%s" if ruKuResult['status'] == 200: tydbId = mysql.getTydbId(ruKuResult['tydId']) # 创建分拨单 createFenBoDanResult = createFenBoDan.createFenBoDan(merchantToken, fbdToken, fbdId, tydbId, createrName, createrId, fbdRollOutPointId, fbdRollOutPoint, fbdRollInPointId, fbdRollInPoint) if createFenBoDanResult['status'] == 200: # 创建配载单 createPeiZaiDanResult = createPeiZaiDan.createPeiZaiDan(merchantToken, pzdId, tydbId, createrName, createrId, pzdRollOutId, pzdRollOutPoint, pzdRollInPointId, pzdRollInPoint) if createPeiZaiDanResult['status'] == 200: peiZaiResult['status'] = createPeiZaiDanResult['status'] peiZaiResult['message'] = createPeiZaiDanResult['message'] peiZaiResult['tydId'] = ruKuResult['tydId'] print("创建分拨单,要创建提货单,已配载状态的托运单创建成功") else: peiZaiResult['status'] = createPeiZaiDanResult['status'] peiZaiResult['message'] = createPeiZaiDanResult['message'] print("创建分拨单,要创建提货单,已配载状态的托运单创建失败") else: peiZaiResult['status'] = createFenBoDanResult['status'] peiZaiResult['message'] = createFenBoDanResult['message'] print("分拨单创建失败,已配载状态的托运单创建失败") else: peiZaiResult['status'] = ruKuResult['status'] peiZaiResult['message'] = ruKuResult['message'] print("托运单创建失败,已配载状态的托运单创建失败") return peiZaiResult
def yiruku(merchantToken, createrName, createrId, takeGoodsMethod, sendStationId, sendStationName, receiveStationId, receiveStationName, goodsName, thdId, takeGoodsStation, takeGoodsStationId): '''获取托运单号及货号''' tyd_id = get_id.getTYD_id(merchantToken, sendStationId) tyh_id = get_id.getTYH_id(merchantToken, sendStationId) # 定义接口的返回值 ruKuResult = {"status": 0, "message": '', "tydId": ''} date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) '''创建运单''' url = "http://192.168.173.152/api/operator/consign/add?token=" + merchantToken consignBaseVo = { "gmtOrder": date, "consignNo": tyd_id, "createrName": createrName, "createrId": createrId, "consignGoodsNo": tyh_id, "sender": "啦啦啦", "receiver": "南湖", "senderPhone": "15912121212", "receiverPhone": "19912345678", "sendRegionId": "360828", "sendRegionSpell": "江西省吉安万安县", "sendDetailAddress": "你就1231231232", "receiveRegionId": "230881", "receiveRegionSpell": "黑龙江省佳木斯同江市", "receiveDetailAddress": "你就", "sendStationId": sendStationId, "sendStationName": sendStationName, "receiveStationId": receiveStationId, "receiveStationName": receiveStationName, "takeGoodsMethod": takeGoodsMethod, "receiveGoodsMethod": "DTD_DELIVERY", "receiptRequire": "回单签字", "transportFee": 65, "infoFee": 10, "spotTransportFee": 10, "supportValueFee": 10, "collectionGoodsFee": 0, "collectionTransportFee": 0, "spotGoodsFee": 0, "takeGoodsFee": 40, "sendGoodsFee": 0, "otherFee": 0, "handlingFee": 50, "packingFee": 0, "upstairsFee": 10, "totalFee": "195.00", "payType": "现付", "cashPay": 0, "collectPay": 0, "receiptPay": 195, "monthPay": 0, "remark": "", "senderId": "CUS18060400081009A000", "receiverId": "CUS18060400081011A000", "remarkShort": " 易碎;防潮;", "consignSource": "BACKSTAGE_ADD", "id": "TYDB18060600428010A000" } consignGoodsInfoVoList = [{ "id": "TYDH18060600254026A000", "consignBaseId": "TYDB18060600428010A000", "merchantId": "USER18050400072030A000", "goodsNo": "HH2018060400000049", "goodsName": goodsName, "goodsAmount": 9, "goodsAmountUnit": "件", "goodsWeight": 4, "goodsWeightUnit": "KG", "goodsVolume": 3, "goodsVolumeUnit": "MMM", "goodsType": "生活用品", "goodsPrice": 0, "goodsPriceUnit": "件", "goodsLoss": 0, "packageMethods": "木箱", "goodsAttribute": "抛货", "goodsImage": " ", "gmtCreate": date, "gmtModified": date, "visible": False }] values = { "consignBaseVo": consignBaseVo, "consignGoodsInfoVoList": consignGoodsInfoVoList } #创建托运单 r = interface.requestInterfacePost_Json(url, values) '''创建提货单''' tydb_id = mysql.getTydbId(tyd_id) createThdUrl = "http://192.168.173.152/api/operator/takeGoods/save?token=" + merchantToken params = { "gmtTakeGoods": date, "gmtSendCar": date, "takeGoodsNo": thdId, "currentStationId": "", "driverId": "SJ18051700046002A000", "driverName": "邹元司机2", "driverPhone": "13003641778", "trunkId": "TRUCK18051000044001A000", "trunkNo": "浙B11123", "totalFee": "23.98", "chargeUnit": "", "createrName": createrName, "createrId": createrId, "remark": "", "relationVoList": [{ "consignBaseId": tydb_id, "amount": 9, "stockStationId": takeGoodsStationId, "stockStationName": takeGoodsStation }], "takeGoodsStationId": takeGoodsStationId, "remarkShort": " 易碎;防潮;" } '''提货单收货''' thdConfirmUrl = "http://192.168.173.152/api/operator/takeGoods/inStock?token=" + merchantToken # 先判断托运单是否成功创建,如果创建成功,就创建提货单 createTydResult = json.loads(r.decode()) if createTydResult['status'] == 200: print "创建已入库状态的托运单(需要创建提货单),托运单创建成功!" # 创建提货单 thdResult = interface.requestInterfacePost_Json(createThdUrl, params) createThdResult = json.loads(thdResult.decode()) if createThdResult['status'] == 200: print "提货单创建成功!" #提货单收货 data = {"id": mysql.getThdbId(thdId)} thdConfirmResult = json.loads( (interface.requestInterfacePut_Json(thdConfirmUrl, data)).decode()) if thdConfirmResult['status'] == 200: ruKuResult['status'] = thdConfirmResult['status'] ruKuResult['message'] = thdConfirmResult['message'] ruKuResult['tydId'] = tyd_id print "提货单收货成功!" else: ruKuResult['status'] = thdConfirmResult['status'] ruKuResult['message'] = thdConfirmResult['message'] print "提货单收货失败!" else: ruKuResult['status'] = createThdResult['status'] ruKuResult['message'] = createThdResult['message'] print "提货单创建失败!" else: ruKuResult['status'] = createTydResult['status'] ruKuResult['message'] = createTydResult['message'] print "托运单创建失败!" return ruKuResult