def setBarCode(self):

        barcode = self.barcode_text.GetValue().strip()
        if barcode == RESET_CODE:
            self.out_sid_text.Clear()
            self.barcode_text.Clear()
            self.out_sid_text.SetFocus()
            self.gridpanel.clearTable()
            self.status_bar.SetBackgroundColour('RED')
            return

        if self.trade and barcode:
            checked = self.gridpanel.setBarCode(barcode)
            if barcode == NOTSCAN_CODE or checked:
                if self.gridpanel.isCheckOver():
                    try:
                        serial_data = self.gridpanel.serial_data()
                        WebApi.complete_scan_check(self.trade['package_no'],
                                                   serial_data)
                    except Exception, exc:
                        dial = wx.MessageDialog(
                            None, exc.message, u'扫描出错提示',
                            wx.OK | wx.CANCEL | wx.ICON_EXCLAMATION)
                        dial.ShowModal()
                        dial.Destroy()
                    self.gridpanel.clearTable()
                    self.out_sid_text.Clear()
                    self.barcode_text.Clear()
                    self.out_sid_text.SetFocus()
                else:
                    self.barcode_text.Clear()
                    self.barcode_text.SetFocus()
            else:
                self.barcode_text.Clear()
                self.barcode_text.SetFocus()
Exemple #2
0
def printYUNDAPDF(trade_ids, direct=False, session=None):
    yd_customer = getYDCustomerByTradeId(trade_ids[0], session=session)
    trades = session.query(PackageOrder).filter(
        PackageOrder.pid.in_(trade_ids)).filter_by(is_express_print=True)
    to_yunda_ids = [t.id for t in trades]
    pdfdoc = print_order(to_yunda_ids,
                         partner_id=yd_customer.qr_id,
                         secret=yd_customer.qr_code)

    for fname in os.listdir(TEMP_FILE_ROOT):
        os.remove(os.path.join(TEMP_FILE_ROOT, fname))

    file_name = os.path.join(TEMP_FILE_ROOT, '%d.pdf' % int(time.time()))
    with open(file_name, 'wb') as f:
        f.write(pdfdoc)

    # 更新订单打印状态
    from taobao.dao.webapi import WebApi
    WebApi.print_express(trade_ids)

    if direct:
        conf = getconfig()
        gsprint_exe = conf.get('custom', 'gsprint_exe')
        p = subprocess.Popen([gsprint_exe, file_name],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        p.communicate()
    else:
        webbrowser.open(file_name)
 def save_weight_to_trade(self, trade, weight):
     WebApi.complete_scan_weight(trade['package_no'], weight)
     trade['weight'] = weight
     self.gridpanel.InsertTradeRows(trade)
     self.trade = None
     self.valid_code = ''
     for control in self.control_array:
         control.SetValue('')
def locking_trade(trade_id,operator,session=None):
    """ 锁定交易   """
    from taobao.dao.webapi import WebApi
    if not session:
        session = get_session()
    is_locked = False
    trade = session.query(PackageOrder).filter_by(pid=trade_id).first()
    if not trade.is_locked:
        WebApi.operate_packages([trade.id], operator)
    elif trade.operator == operator:
        is_locked = True
    
    return is_locked
    def onOutsidTextChange(self, evt):
        out_sid = self.getSid()
        if not out_sid:
            return
        try:
            from taobao.dao.dbsession import SessionProvider
            from taobao.dao.models import PackageOrder
            trade = WebApi.begin_scan_weight(out_sid)
            po = SessionProvider.session.query(PackageOrder).filter(
                PackageOrder.out_sid == out_sid,
                PackageOrder.sys_status.in_([
                    cfg.PKG_WAIT_PREPARE_SEND_STATUS,
                    cfg.PKG_WAIT_CHECK_BARCODE_STATUS,
                    cfg.PKG_WAIT_SCAN_WEIGHT_STATUS
                ])).one()

            if po.redo_sign:
                dial = wx.MessageDialog(
                    None, u'此包裹需要重打发货单,确认已经重打了吗', u'发货单重打提示',
                    wx.OK | wx.CANCEL | wx.ICON_EXCLAMATION)
                result = dial.ShowModal()
                dial.Destroy()
                # 如果不继续,则退出
                if result != wx.ID_OK:
                    return False
                elif result == wx.ID_OK:
                    WebApi.clear_redo_sign(po.pid)
            self.trade = trade
            self.setTradeInfoPanel(trade)
            self.weight_text.SetFocus()
            self.error_text.SetLabel('')
            self.error_text.SetForegroundColour('white')
            self.error_text.SetBackgroundColour('black')

        except Exception, exc:
            self.error_text.SetLabel(exc.message)
            self.error_text.SetForegroundColour('black')
            self.error_text.SetBackgroundColour('red')
            self.clearTradeInfoPanel()
            self.weight_text.Clear()
            self.out_sid_text.Clear()
            self.out_sid_text.SetFocus()
            winsound.PlaySound(MEDIA_ROOT + 'wrong.wav', winsound.SND_FILENAME)
    def onOutsidTextChange(self, evt):

        out_sid = self.getSid()
        if not out_sid:
            return

        try:
            from taobao.dao.dbsession import SessionProvider
            from taobao.dao.models import PackageOrder
            trade = WebApi.begin_scan_check(out_sid)
            po = SessionProvider.session.query(PackageOrder).filter(
                PackageOrder.out_sid == out_sid,
                PackageOrder.sys_status.in_([
                    configparams.PKG_WAIT_PREPARE_SEND_STATUS,
                    configparams.PKG_WAIT_CHECK_BARCODE_STATUS,
                    configparams.PKG_WAIT_SCAN_WEIGHT_STATUS
                ])).one()

            if po.redo_sign:
                dial = wx.MessageDialog(
                    None, u'此包裹需要重打发货单,确认已经重打了吗', u'发货单重打提示',
                    wx.OK | wx.CANCEL | wx.ICON_EXCLAMATION)
                result = dial.ShowModal()
                dial.Destroy()
                # 如果不继续,则退出
                if result != wx.ID_OK:
                    return False
                elif result == wx.ID_OK:
                    WebApi.clear_redo_sign(po.pid)
            self.trade = trade
            self.gridpanel.setData(self.trade)

            self.barcode_text.SetFocus()
            self.error_text.SetLabel('')
            self.status_bar.SetBackgroundColour('GREEN')

        except Exception, exc:
            self.error_text.SetLabel('%s' % exc.message)
            self.out_sid_text.Clear()
            self.out_sid_text.SetFocus()
            self.status_bar.SetBackgroundColour('RED')
            print exc.message
Exemple #7
0
 def printPromptOk(self):
     
     with create_session(self.Parent) as session: 
         trades = session.query(PackageOrder).filter(PackageOrder.pid.in_(self.trade_ids)).filter_by(is_picking_print=True)
         rept_num = trades.count()
         if rept_num > 0:
             dial = wx.MessageDialog(None, u'该批订单有(%d)单已打印发货单,还要继续吗?'%rept_num, u'发货单重打提示', 
                                     wx.OK|wx.CANCEL|wx.ICON_EXCLAMATION)
             result = dial.ShowModal()
             dial.Destroy()
             
             #如果不继续,则退出
             if result != wx.ID_OK:
                 return False
         WebApi.print_express(self.trade_ids)
         # session.query(PackageOrder).filter(PackageOrder.pid.in_(self.trade_ids))\
         #     .update({'is_picking_print':True},synchronize_session='fetch')
         self.printed = True
         
         return True
 def onPreview(self, event):
     """"""
     with create_session(self.Parent) as session:
         trades = session.query(PackageOrder).filter(
             PackageOrder.pid.in_(
                 self.trade_ids)).filter_by(is_express_print=True)
         rept_num = trades.count()
         if rept_num > 0:
             dial = wx.MessageDialog(
                 None, u'该批订单有(%d)单已打印快递单,还要继续吗?' % rept_num, u'快递单重打提示',
                 wx.OK | wx.CANCEL | wx.ICON_EXCLAMATION)
             result = dial.ShowModal()
             dial.Destroy()
             # 如果不继续,则退出
             if result != wx.ID_OK:
                 return
         WebApi.print_express(self.trade_ids)
         self.printed = True
     updatePageSetupRegedit(self.getPageSetup())
     self.html.PrintPreview()
     event.Skip()
 def onPrint(self, event):
     WebApi.print_express(self.trade_ids)
     self.html.Print(True)
     event.Skip()
Exemple #10
0
 def onPrint(self, event):
     WebApi.print_picking(self.trade_ids)
     self.html.Print(True)
     event.Skip()