Exemplo n.º 1
0
    def get_excel_to_py(self, request, objs):
        path = MEDIA_ROOT + 'download_xls/' + request.user.username
        # if not os.path.exists(path):
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))

        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))

        # 写数据
        thelist = []
        for qs in objs:
            batsta = None
            for batbb in getChoices(Choicebatchstatus):
                if batbb[0] == qs.Status:
                    batsta = batbb[1]
                    break

            t_set_warehouse_storage_situation_list_objs = t_set_warehouse_storage_situation_list.objects.filter(Delivery_lot_number = qs.Delivery_lot_number)
            for obj in t_set_warehouse_storage_situation_list_objs:
                remarks = None
                t_stocking_demand_list_objs = t_stocking_demand_list.objects.filter(Stocking_plan_number = obj.Stocking_plan_number)
                if t_stocking_demand_list_objs.exists():
                    remarks = t_stocking_demand_list_objs[0].Remarks
                warehouse = ''
                for ware in getChoices(ChoiceWarehouse):
                    if obj.Destination_warehouse == ware[0]:
                        warehouse = ware[1]

                level = ''
                for lev in getChoices(ChoiceLevel):
                    if obj.level == lev[0]:
                        level = lev[1]

                house = u'浦江集货仓'
                if ('%s'%obj.Purchase_Order_No).find(u'调拨') != -1 or  ('%s'%obj.Purchase_Order_No).find(u'调货') != -1:
                    house = u'浦江仓库'

                thelist.append([obj.ProductSKU,obj.ShopSKU,obj.The_arrival_of_the_number,qs.Warehouse_number,qs.GoodsCategory,qs.The_first_Logistics_cost,
                                qs.LogisticsNumber,qs.Sender,batsta,obj.Price,house,warehouse,obj.ProductName,level,obj.Demand_people,remarks,obj.AccountNum])
        thelist.insert(0,[u'SKU',u'店铺SKU',u'Qty',u'入库单号',u'货物品类',u'头程费用',u'	物流单号',u'发货人',u'本批次发货状态',
                          u'含税单价',u'出库仓',u'入库仓',u'产品名称',u'紧急程度',u'计划需求人',u'备注',u'店铺名(账号)'])
        filename = request.user.username + '_' + dattime.now().strftime('%Y%m%d%H%M%S') + '.xls'

        getexcel = generate_excel(thelist,path + '/' + filename)
        if getexcel['code'] == 0:
            from brick.public.upload_to_oss import upload_to_oss
            os.popen(r'chmod 777 %s' % (path + '/' + filename))
            upload_to_oss_obj = upload_to_oss(BUCKETNAME_XLS)
            myresult = upload_to_oss_obj.upload_to_oss({'path':request.user.username,'name':filename,'byte':open(path + '/' + filename),'del':0})
            if myresult['errorcode'] == 0:
                messages.error(request, myresult['result'] + u':成功导出,可点击Download下载到本地............................。')
        else:
            messages.error(request, u'导出失败。。。。。')
    def block_help(self, context, nodes):
        IP = ''
        ServerIP = os.popen(
            "ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{print $1}' | head -1"
        ).read()
        GetIPs = getChoices(ChoiceIp)
        for GetIP in GetIPs:
            if GetIP[0] == ServerIP.strip():  # (75--测试环境)
                IP = u'%s' % GetIP[1]

        siteIP = u'%s' % (IP)

        help_name = u'帮助'
        history_name = u'最近访问记录'

        #logger = logging.getLogger('sourceDns.webdns.views')
        #logger.error("context=%s ,opts= %s "%(context,context['opts']))

        nodes.append(
            loader.render_to_string(
                't_help.html', {
                    'help_name': help_name,
                    'history_name': history_name,
                    'siteIP': siteIP
                }))
Exemplo n.º 3
0
 def show_status(self, obj):
     try:
         rt = ""
         strStatus = ""
         for status in getChoices(Choicebatchstatus):
             if status[0] == obj.Status:
                 strStatus = status[1]
                 break
         if  obj.Status == 'notyet':
             flag = 1 if ((obj.OplogTime is not None) and (str(dattime.now()) > str(obj.OplogTime + datetime.timedelta(days=2)))) else 0
             diffDate = (dattime.now() - obj.OplogTime).days if obj.OplogTime is not None else 0
             if flag == 1:
                 rt = '<div class="box" style="width: 150px;height: 120px;background-color: red;text-align: center;line-height: 20px;border-radius: 4px"><br>%s<br>超期%s天<br>上一步处理时间:%s' % (strStatus,diffDate,obj.OplogTime)
             else:
                 rt = '<div class="box" style="width: 150px;height: 120px;text-align: center;line-height: 20px;border-radius: 4px"><br>%s<br>超期%s天<br>上一步处理时间:%s</div>' % (strStatus,diffDate,obj.OplogTime)
         else:
             rt = strStatus
     except Exception, ex:
         messages.info(self.request,"采购状态加载错误,请联系IT解决:%s"%(str(ex)))
         rt = ""
    def show_status(self, obj):
        try:

            from skuapp.table.t_stocking_demand_fba import t_stocking_demand_fba
            t_stocking_demand_fba_obj = t_stocking_demand_fba.objects.filter(
                Delivery_lot_number=obj.Delivery_lot_number)
            # t_stocking_demand_fba_obj = t_stocking_demand_fba.objects.filter(Delivery_lot_number=obj.Delivery_lot_number).first()
            genBatchMan = ''
            for row in t_stocking_demand_fba_obj:
                genBatchMan = row.genBatchMan

            rt = ""
            strStatus = ""
            for status in getChoices(ChoiceFBAPlanStatus):
                if status[0] == obj.Status:
                    strStatus = status[1]
                    break
            if obj.Status == 'deliver':
                flag = 1 if (
                    (obj.OplogTime is not None) and
                    (str(dattime.now()) >
                     str(obj.OplogTime + datetime.timedelta(days=2)))) else 0
                diffDate = (
                    dattime.now() -
                    obj.OplogTime).days if obj.OplogTime is not None else 0
                if flag == 1:
                    rt = '<div class="box" style="width: 150px;height: 120px;background-color: red;text-align: center;line-height: 20px;border-radius: 4px">%s<br>超期%s天<br>上一步处理人:%s<br>上一步处理时间:%s</div>' % (
                        strStatus, diffDate, genBatchMan, obj.OplogTime)

                else:

                    rt = '<div class="box" style="width: 150px;height: 120px;text-align: center;line-height: 20px;border-radius: 4px">%s<br>超期%s天<br>上一步处理人:%s<br>上一步处理时间:%s</div>' % (
                        strStatus, diffDate, genBatchMan, obj.OplogTime)
            else:
                rt = strStatus
        except Exception, ex:
            messages.info(self.request, "采购状态加载错误,请联系IT解决:%s" % (str(ex)))
            rt = ""
Exemplo n.º 5
0
    def to_exort_ed_enter_ing(self, request, queryset):
        from xlwt import *
        from skuapp.table.public import getChoices, ChoiceCategory2, ChoiceStorehouse
        from skuapp.table.t_base import getChoicesuser

        Category2 = getChoices(ChoiceCategory2)

        all_storehouse = getChoices(ChoiceStorehouse)

        path = MEDIA_ROOT + 'download_xls/' + request.user.username
        #if not os.path.exists(path):
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))

        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))

        w = Workbook()
        sheet = w.add_sheet('sku')

        for index, item in enumerate(XLS_FIELDS):
            sheet.write(0, index, item)

        #写数据
        row = 0

        for qs in queryset:
            shouse = qs.Storehouse
            for storehouse in all_storehouse:
                if qs.Storehouse == storehouse[0]:
                    shouse = storehouse[1]
            #根据主SKU查找子sku
            t_product_mainsku_sku_objs = t_product_mainsku_sku.objects.filter(
                pid=qs.id)

            for mainsku_sku_obj in t_product_mainsku_sku_objs:
                row = row + 1
                column = 0
                sheet.write(row, column, u'add')  #A 操作类型

                column = column + 1
                if qs.MainSKU == mainsku_sku_obj.SKU:
                    sheet.write(row, column, '%s' % (qs.MainSKU))  #B 商品编码
                else:
                    sheet.write(row, column, '%s%s' %
                                (qs.MainSKU, mainsku_sku_obj.SKU))  #B 商品编码

                column = column + 1
                if qs.MainSKU == mainsku_sku_obj.SKU:
                    sheet.write(row, column, '%s' % (qs.MainSKU))  #C SKU
                else:
                    sheet.write(row, column, '%s%s' %
                                (qs.MainSKU, mainsku_sku_obj.SKU))  #C SKU

                column = column + 1
                sheet.write(row, column, u'否')  #D 多款式

                column = column + 1
                sheet.write(row, column, u'否')  #E 是否有样品

                column = column + 1
                #sheet.write(row,column,1) #F 样品数量

                column = column + 1
                sheet.write(row, column, qs.LargeCategory)  #G 大类名称

                column = column + 1
                catt = None
                for cate in Category2:
                    if cate[0] == qs.SmallCategory:
                        catt = cate[1]
                        break
                if catt is None:
                    catt = qs.SmallCategory
                sheet.write(row, column, catt)  # H 小类名称

                column = column + 1
                #sheet.write(row,column,qs.Name) #I 商品名称
                wjp = ''
                if qs.ContrabandAttribute and qs.ContrabandAttribute != u'普货':
                    if qs.SmallCategory != u'手表':  #手表特殊
                        wjp = u'-违禁品'
                PrepackMark = qs.PrepackMark
                if PrepackMark is None:
                    PrepackMark = ''
                sheet.write(row, column, u'%s%s-%s%s' %
                            (PrepackMark, qs.Name2, mainsku_sku_obj.SKUATTRS,
                             wjp))  #I 商品名称

                column = column + 1
                sheet.write(row, column, u'正常')  #J 当前状态

                column = column + 1
                sheet.write(row, column, qs.Material)  #K 材质

                column = column + 1
                #sheet.write(row,column,'%s'%(qs.LWH) ) #L 规格

                column = column + 1
                sheet.write(row, column, '%s' % (qs.SupplierArtNO))  #M 型号

                column = column + 1
                #sheet.write(row,column, u'款式' ) #N 款式

                column = column + 1
                sheet.write(row, column, 'fancyqube')  #O 品牌

                column = column + 1
                sheet.write(row, column, qs.Unit)  #P 单位

                column = column + 1
                #zxbzs = 1
                #if qs.Unit ==u'对':
                #    zxbzs = 2
                #sheet.write(row,column, zxbzs ) #Q 最小包装数
                sheet.write(row, column, mainsku_sku_obj.MinPackNum)

                column = column + 1

                weight = 0
                if qs.Weight is not None and qs.Weight > 0:
                    weight = qs.Weight
                if mainsku_sku_obj.Weight is not None and mainsku_sku_obj.Weight > 0:
                    weight = mainsku_sku_obj.Weight

                PackNID = mainsku_sku_obj.PackNID
                if PackNID <= 0:
                    PackNID = qs.PackNID

                B_PackInfo_obj = B_PackInfo.objects.filter(id__exact=PackNID)
                if B_PackInfo_obj.exists():
                    weight = weight + int(B_PackInfo_obj[0].Weight)

                sheet.write(row, column, u'%s' % (weight))  #R 重量(G)
                """
                t_sys_packing_obj = None
                t_sys_packing2_obj = None
                if qs.PackingID_id is not None :
                    t_sys_packing_obj  = t_sys_packing.objects.get(id__exact = qs.PackingID_id)
                    if  t_sys_packing_obj is not None and t_sys_packing_obj.Weight is not None  :
                        weight = weight + t_sys_packing_obj.Weight

                #附加包装
                if qs.PackingID2Num is not None and qs.PackingID2Num > 0 and qs.PackingID2_id is not None:
                    t_sys_packing2_obj  = t_sys_packing2.objects.get(id__exact = qs.PackingID2_id)
                    if  t_sys_packing2_obj is not None  and t_sys_packing2_obj.Weight is not None and qs.PackingID2Num is not None :
                        weight = weight + t_sys_packing2_obj.Weight * qs.PackingID2Num
                sheet.write(row,column,u'%s'%(weight)) #R 重量(G)
                """

                column = column + 1
                #sheet.write(row,column, ) #S 采购渠道

                column = column + 1
                sheet.write(row, column, qs.SupplierID)  #T 供应商名称

                column = column + 1
                #先找子sku有没有
                dj = qs.UnitPrice
                if mainsku_sku_obj.UnitPrice is not None and mainsku_sku_obj.UnitPrice > 0:
                    dj = mainsku_sku_obj.UnitPrice
                sheet.write(row, column, dj)  #U 成本单价(元)  就是单价 子SKU简单覆盖

                column = column + 1
                #sheet.write(row,column,qs.UnitPrice ) #V 批发价格(美元)

                column = column + 1
                #sheet.write(row,column,qs.UnitPrice ) #W 零售价格(美元)

                column = column + 1
                #sheet.write(row,column,qs.UnitPrice ) #X 最低售价(美元)

                column = column + 1
                #sheet.write(row,column,qs.UnitPrice ) #Y 最高售价(美元)

                column = column + 1
                #sheet.write(row,column,qs.UnitPrice ) #Z 市场参考价(美元)

                column = column + 1
                sheet.write(
                    row, column, u'%s \n %s \n %s ' %
                    (mainsku_sku_obj.DressInfo, qs.Remark, qs.LWH))  #AA 备注

                column = column + 1
                sheet.write(row, column, qs.ReportName2)  #AB 中文申报名

                column = column + 1
                sheet.write(row, column, qs.ReportName)  #AC 英文申报名

                column = column + 1
                if dj is None:
                    dj = 0  # math.ceil(2.3)
                sheet.write(row, column,
                            int(math.ceil(float(dj) / SBBL)))  #AD 申报价值(美元)

                column = column + 1
                sheet.write(row, column, 'CN')  #AE 原产国代码

                column = column + 1
                sheet.write(row, column, 'China')  #AF 原产国

                column = column + 1
                #sheet.write(row,column,100 ) #AG 库存上限

                column = column + 1
                #sheet.write(row,column,5 ) #AH 库存下限

                column = column + 1
                #sheet.write(row,column,qs.StaffID ) #AI 业绩归属人1
                t_product_oplog_obj1 = t_product_oplog.objects.filter(
                    pid=qs.id, StepID='KF')[0:1]

                t_product_oplog_obj2 = t_product_oplog.objects.filter(
                    pid=qs.id, StepID='JZL')[0:1]
                # mdf by wangzy 20180402 任务-503 保留调研员为业绩归属人
                #修改相同的业绩归属人1和2
                '''
                if  t_product_oplog_obj1.exists() and t_product_oplog_obj2.exists() and t_product_oplog_obj1[0].OpName != t_product_oplog_obj2[0].OpName:
                    sheet.write(row,column,t_product_oplog_obj1[0].OpName)
                            #AI 业绩归属人1
                '''
                sheet.write(row, column, qs.DYStaffName)  # AJ 业绩归属人2
                column = column + 1
                #sheet.write(row,column,qs.StaffID )
                #mdf by wangzy 20180308
                #if t_product_oplog_obj2.exists() :
                #    sheet.write(row,column,t_product_oplog_obj2[0].OpName) #AJ 业绩归属人2
                if qs.YJGS2StaffName != '' and qs.YJGS2StaffName is not None:
                    sheet.write(row, column,
                                getChoicesuser(qs.YJGS2StaffName))  # AJ 业绩归属人2
                elif t_product_oplog_obj2.exists():
                    sheet.write(row, column,
                                t_product_oplog_obj2[0].OpName)  # AJ 业绩归属人2

                column = column + 1
                gg = ''
                if B_PackInfo_obj.exists():
                    gg = B_PackInfo_obj[0].PackName
                sheet.write(row, column, gg)  #AK 包装规格
                """
                #包装1 14*14快递袋2g+3层起泡沫6g
                if t_sys_packing_obj is not None :
                    if t_sys_packing_obj.PackName == u'共济膜信封':
                        gg = gg + u'%s%s%sg'%(t_sys_packing_obj.PackStandard,t_sys_packing_obj.PackName,round(t_sys_packing_obj.Weight,1))
                    else:
                        gg = gg + u'%s%s%dg'%(t_sys_packing_obj.PackStandard,t_sys_packing_obj.PackName,round(t_sys_packing_obj.Weight))

               #附加包装
                if t_sys_packing2_obj is not None :
                    if t_sys_packing2_obj.Unit == u'层':
                        gg = gg + u'+%s%s%s%dg'%(qs.PackingID2Num,t_sys_packing2_obj.Unit,t_sys_packing2_obj.PackName,round(qs.PackingID2Num*t_sys_packing2_obj.Weight))
                    else:
                        gg = gg + u'+%s%s%s%s%dg'%(t_sys_packing2_obj.PackStandard,t_sys_packing2_obj.PackName,qs.PackingID2Num,t_sys_packing2_obj.Unit,round(qs.PackingID2Num*t_sys_packing2_obj.Weight))

                sheet.write(row,column,gg ) #AK 包装规格
                """
                column = column + 1
                sheet.write(row, column,
                            qs.UpdateTime.strftime('%Y-%m-%d'))  #AL 开发日期

                column = column + 1
                #sheet.write(row,column,qs.UpdateTime ) #AM SKU款式1

                column = column + 1
                #sheet.write(row,column,qs.UpdateTime ) #AN SKU款式2

                column = column + 1
                #sheet.write(row,column,qs.UpdateTime ) #AO SKU款式3

                column = column + 1
                #sheet.write(row,column,qs.UpdateTime ) #AP SKU描述

                column = column + 1
                #sheet.write(row,column,qs.UpdateTime ) #AQ 图片URL

                column = column + 1
                sheet.write(row, column, qs.Buyer)  #AR 采购员

                column = column + 1
                sheet.write(row, column, shouse)  #AS 发货仓库

                column = column + 1
                sheet.write(row, column, qs.OrderDays)  #AT 采购到货天数

                column = column + 1
                #计算内包装成本
                cb = 0
                if B_PackInfo_obj.exists():
                    cb = cb + B_PackInfo_obj[0].CostPrice
                sheet.write(row, column, u'%s' % (cb))  #AU 内包装成本
                """
                #包装1
                if t_sys_packing_obj is not None and t_sys_packing_obj.Price is not None:
                    cb = cb + t_sys_packing_obj.Price
                #附加包装
                if t_sys_packing2_obj is not None and t_sys_packing2_obj.Price is not None and  qs.PackingID2Num is not None:
                    cb = cb + t_sys_packing2_obj.Price * qs.PackingID2Num

                sheet.write(row,column,u'%s'%(cb) ) #AU 内包装成本
                """
                #任务:411-网页URL1只提取主链接  mdf by wangzy 20180307
                column = column + 1
                #sheet.write(row,column, u'%s;%s;'%(qs.SupplierPUrl1,qs.SupplierPUrl2)) #AV 网页URL 填写 供应商URL
                sheet.write(row, column,
                            u'%s;' % (qs.SupplierPUrl1))  # AV 网页URL 填写 供应商URL

                column = column + 1
                # sheet.write(row,column,'') #AW 网页URL2

                column = column + 1
                #sheet.write(row,column, qs.SupplierPUrl2 ) #AX 网页URL3

                column = column + 1
                #sheet.write(row,column,u'待定' ) #AY 最低采购价格

                column = column + 1
                #sheet.write(row,column,u'待定' ) #AZ 海关编码

                column = column + 1
                sheet.write(row, column, qs.StockAlarmDays)  #BA 库存预警销售周期

                column = column + 1
                sheet.write(row, column, qs.MinOrder)  #BB 采购最小订货量

                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BC 内盒长
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BD 内盒宽
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BE 内盒高
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BF 内盒毛重
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BG 内盒净重
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BH 外箱长
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BI 外箱宽
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BJ 外箱高
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BK 外箱毛重
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BL 外箱净重
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BM 商品URL
                column = column + 1
                #sheet.write(row,column,qs.MinOrder ) #BN 包装事项

                column = column + 1
                #sheet.write(row,column,qs.Electrification ) #BO 是否带电

                column = column + 1
                sheet.write(row, column, u'正常')  #BP 商品SKU状态

                column = column + 1
                #sheet.write(row,column,u'正常' ) #BQ 工号权限

                column = column + 1
                #sheet.write(row,column,u'正常' ) #BR 季节

                column = column + 1
                #sheet.write(row,column,qs.Powder ) #BS 是否粉末

                column = column + 1
                #sheet.write(row,column,qs.Liquid ) #BT 是否液体

                column = column + 1
                #sheet.write(row,column,u'正常' ) #BU 责任归属人1

                column = column + 1
                sheet.write(row, column, qs.possessMan2)  #BV 责任归属人2

                column = column + 1  #BW 商品属性

                sheet.write(
                    row, column,
                    qs.ContrabandAttribute if qs.ContrabandAttribute else '')
                # if qs.ContrabandAttribute == '普货':
                #     sheet.write(row, column, u'普货')
                # elif qs.ContrabandAttribute == '一类特货':
                #     sheet.write(row, column, u'一类特货')
                # elif qs.ContrabandAttribute == '二类特货':
                #     sheet.write(row, column, u'二类特货')
                # elif qs.ContrabandAttribute == '三类特货':
                #     sheet.write(row, column, u'三类特货')
                # elif qs.ContrabandAttribute == '四类特货':
                #     sheet.write(row, column, u'四类特货')
                # elif qs.ContrabandAttribute == '五类特货':
                #     sheet.write(row, column, u'五类特货')
                # elif qs.ContrabandAttribute == '六类特货':
                #     sheet.write(row, column, u'六类特货')
                # elif qs.ContrabandAttribute == '七类特货':
                #     sheet.write(row, column, u'七类特货')

                column = column + 1
                #sheet.write(row,column, ) #BX 包装难度系数

                column = column + 1
                #sheet.write(row,column,u'正常' ) #BY 店铺名称
                column = column + 1
                #sheet.write(row,column,u'正常' ) #BZ UPC码
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CA ASIN码
                # 任务:411-网页URL1只提取主链接  mdf by wangzy 20180308
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CB 网页URL4
                sheet.write(
                    row, column, u'%s;%s;' %
                    (qs.SupplierPUrl1, qs.SupplierPUrl2))  #AV 网页URL 填写 供应商URL
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CC 网页URL5
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CD 网页URL6
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CE 店铺运费
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CF 包装材料重量
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CG 汇率
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CH 物流公司价格
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CI 交易费
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CJ 毛利率
                column = column + 1
                #sheet.write(row,column,u'正常' ) #CK 计算售价

        filename = request.user.username + '_' + datetime.now().strftime(
            '%Y%m%d%H%M%S') + '.xls'
        w.save(path + '/' + filename)
        os.popen(r'chmod 777 %s' % (path + '/' + filename))

        #上传oss对象
        auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
        bucket = oss2.Bucket(auth, ENDPOINT, BUCKETNAME_XLS)
        bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ)
        #删除现有的
        for object_info in oss2.ObjectIterator(
                bucket,
                prefix='%s/%s_' %
            (request.user.username, request.user.username)):
            bucket.delete_object(object_info.key)
        bucket.put_object(u'%s/%s' % (request.user.username, filename),
                          open(path + '/' + filename))

        messages.error(
            request, u'%s%s.%s/%s/%s' % (PREFIX, BUCKETNAME_XLS, ENDPOINT_OUT,
                                         request.user.username, filename) +
            u':成功导出,可点击Download下载到本地............................。')
Exemplo n.º 6
0
class t_online_info_wish_store(models.Model):
    PlatformName = models.CharField(u'平台名称',
                                    max_length=16,
                                    blank=True,
                                    null=True)
    ProductID = models.CharField(u'产品ID', max_length=32, blank=True, null=True)
    ShopIP = models.CharField(u'店铺IP', max_length=32, blank=True, null=True)
    ShopName = models.CharField(u'店铺名称', max_length=32, blank=True, null=True)
    Title = models.TextField(u'标题', blank=True, null=True)
    SKU = models.CharField(u'子SKU', max_length=32, blank=True, null=True)
    ShopSKU = models.CharField(u'店铺SKU', max_length=128, blank=True, null=True)
    Price = models.CharField(u'价格', max_length=32, blank=True, null=True)
    Quantity = models.PositiveSmallIntegerField(u'库存量', blank=True, null=True)
    Orders7Days = models.PositiveSmallIntegerField(u'7天order数',
                                                   blank=True,
                                                   null=True)
    SoldYesterday = models.PositiveSmallIntegerField(u'昨日售出量',
                                                     blank=True,
                                                     null=True)
    SoldTheDay = models.PositiveSmallIntegerField(u'当日售出量',
                                                  blank=True,
                                                  null=True)
    SoldXXX = models.PositiveSmallIntegerField(u'销售差值', blank=True, null=True)
    DateOfOrder = models.CharField(u'出单日期 ',
                                   max_length=32,
                                   blank=True,
                                   null=True)
    Remarks = models.TextField(u'操作备注', blank=True, null=True)
    RefreshTime = models.DateTimeField(u'刷新时间', blank=True, null=True)
    Image = models.CharField(u'图片', max_length=200, blank=True, null=True)
    Status = models.CharField(u'状态',
                              choices=getChoices(ChoiceStatus_wish),
                              max_length=16,
                              blank=True,
                              null=True)
    ReviewState = models.CharField(u'Wish查看状态',
                                   choices=getChoices(ChoiceReviewState),
                                   max_length=16,
                                   blank=True,
                                   null=True)
    BeforeReviewState = models.CharField(u'拒绝前状态',
                                         choices=getChoices(ChoiceReviewState),
                                         max_length=16,
                                         blank=True,
                                         null=True)
    DateUploaded = models.DateTimeField(u'上架日期/UTC', blank=True, null=True)
    LastUpdated = models.DateTimeField(u'最近更新日期/UTC', blank=True, null=True)
    OfSales = models.PositiveSmallIntegerField(u'总销量', blank=True, null=True)
    ParentSKU = models.CharField(u'父SKU', max_length=32, blank=True, null=True)
    Seller = models.CharField(u'店长/销售员', max_length=32, blank=True, null=True)
    TortInfo = models.CharField(u'侵权状态',
                                choices=getChoices(ChoiceTortYN),
                                max_length=16,
                                blank=True,
                                null=True)
    MainSKU = models.CharField(u'MainSKU',
                               max_length=32,
                               blank=True,
                               null=True)
    DataSources = models.CharField(u'数据来源',
                                   max_length=15,
                                   blank=True,
                                   null=True)
    OperationState = models.CharField(u'下架状态',
                                      choices=getChoices(ChoiceOperationState),
                                      max_length=15,
                                      blank=True,
                                      null=True)
    Published = models.CharField(u'刊登人', max_length=32, blank=True, null=True)
    is_promoted = models.CharField(u'是否加钻',
                                   max_length=32,
                                   blank=True,
                                   null=True)
    WishExpress = models.CharField(u'海外仓标记',
                                   max_length=64,
                                   blank=True,
                                   null=True)
    AdStatus = models.CharField(u'Listing刷新状态',
                                max_length=64,
                                blank=True,
                                null=True)  # 原为广告状态标记
    market_time = models.DateTimeField(u'营销时间', blank=True, null=True)
    GoodsFlag = models.PositiveSmallIntegerField(u'商品SKU状态',
                                                 blank=True,
                                                 null=True)
    ShopsFlag = models.PositiveSmallIntegerField(u'店铺SKU状态',
                                                 blank=True,
                                                 null=True)
    BindingFlag = models.PositiveSmallIntegerField(u'绑定状态标记',
                                                   blank=True,
                                                   null=True)
    SName = models.CharField(u'店铺状态', max_length=64, blank=True, null=True)  #
    WishExpressType = models.CharField(
        u'海外仓类型',
        choices=getChoices(ChioceWishExpressType),
        max_length=32,
        blank=True,
        null=True)  # 海外仓类型
    MainSKULargeCate = models.CharField(u'大类名称',
                                        max_length=32,
                                        blank=True,
                                        null=True)
    MainSKUSmallCate = models.CharField(u'小类名称',
                                        max_length=32,
                                        blank=True,
                                        null=True)

    ADShow = models.PositiveSmallIntegerField(u'是否有广告', blank=True, null=True)
    SalesTrend = models.PositiveSmallIntegerField(u'周销售情况',
                                                  blank=True,
                                                  null=True)
    Rating = models.PositiveSmallIntegerField(u'评分', blank=True, null=True)

    Order7daysDE = models.PositiveSmallIntegerField(u'7天order数(德国仓)',
                                                    blank=True,
                                                    null=True)
    OfsalesDE = models.PositiveSmallIntegerField(u'总订单量(德国仓)',
                                                 blank=True,
                                                 null=True)
    Order7daysGB = models.PositiveSmallIntegerField(u'7天order数(英国仓)',
                                                    blank=True,
                                                    null=True)
    OfsalesGB = models.PositiveSmallIntegerField(u'总订单量(英国仓)',
                                                 blank=True,
                                                 null=True)
    Order7daysUS = models.PositiveSmallIntegerField(u'7天order数(美国仓)',
                                                    blank=True,
                                                    null=True)
    OfsalesUS = models.PositiveSmallIntegerField(u'总订单量(美国仓)',
                                                 blank=True,
                                                 null=True)

    Order7daysFBW = models.PositiveSmallIntegerField(u'7天order数(FBW)',
                                                     blank=True,
                                                     null=True)
    OfsalesFBW = models.PositiveSmallIntegerField(u'总订单量(FBW)',
                                                  blank=True,
                                                  null=True)
    FBW_Flag = models.CharField(u'FBW标记', max_length=16, blank=True, null=True)

    TortFlag = models.PositiveSmallIntegerField(
        u'标题关键词侵权标记', blank=True, null=True)  # 0 不侵权, 1 侵权 未处理, 2 侵权 已处理
    RiskGrade = models.PositiveSmallIntegerField(
        u'侵权风险等级', blank=True, null=True)  # 0 不侵权, 1 侵权 未处理, 2 侵权 已处理

    class Meta:
        verbose_name = u'Wish 店铺管理'
        verbose_name_plural = verbose_name
        db_table = 't_online_info_wish'

    def __unicode__(self):
        return u'ShopName:%s;id:%s' % (self.ShopName, self.ProductID)
from skuapp.table.t_product_oplog import t_product_oplog
from skuapp.table.t_product_enter_ed import t_product_enter_ed
from skuapp.table.t_product_pic_completion import t_product_pic_completion
from skuapp.table.public import getChoices, ChoiceCategory2
from skuapp.table.t_base import getChoicesuser
from Project.settings import SBBL
from skuapp.views import end_t_product_oplog
from brick.pydata.py_syn.public import public
from brick.table.t_operation_log_online_syn_py import t_operation_log_online_syn_py as operation_log
from django.db import connection
from skuapp.table.t_product_enter_ing import t_product_enter_ing
from skuapp.table.t_sku_weight_examine import t_sku_weight_examine
from brick.pydata.py_syn.py_conn import py_conn
pyconn_obj = py_conn()

Category2 = getChoices(ChoiceCategory2)


def get_mainsku_sku(qs_id, main_sku):
    """获取mainsku_sku表信息"""
    mainsku_sku_infos = []
    objs = t_product_mainsku_sku.objects.filter(pid=qs_id, MainSKU=main_sku)
    if objs.exists():
        for obj in objs:
            temp_dict = {
                'product_sku': obj.ProductSKU.strip(),
                'sku_attrs': obj.SKUATTRS,
                'min_pack_num': obj.MinPackNum,
                'weight': obj.Weight,
                'pack_nid': obj.PackNID,
                'unit_price': obj.UnitPrice,