Пример #1
0
def update_first_variant_img(imgparam, id, pid):
    uResult = cwishapi().update_vinfo(imgparam)
    # uResult = {'errorcode': 1, 'errortext': 'ggggggggggggggggggg'}
    if uResult['errorcode'] == 1:
        return uResult
    else:
        # update_RetryNum(pid)
        raise Exception(u'Error modifying the first variant map. ProductID: {}; {} Instead of returning to repost, you can go to store management and change the first variant.'.format(id, uResult['errortext']))
Пример #2
0
def create_product(fristparam, pid):
    fResult = cwishapi().wish_goods_upload_api(fristparam)
    # fResult = {'errorcode': 1, 'errortext': 'wwwwwwwwwwwwwwwwww', 'productid': '123123123123123123'}
    if fResult['errorcode'] == 1:
        return fResult
    else:
        # update_RetryNum(pid)
        raise Exception(u'An error occurred while creating the product: {}'.format(fResult['errortext']))
Пример #3
0
def create_variant(secondparam, id, pid):
    sResult = cwishapi().wish_variant_goods_add_api(secondparam)
    # sResult = {'errorcode': 0, 'errortext': 'eeeeeeeeeeeeeeeeeeeeee'}
    if sResult['errorcode'] == 1:
        return sResult
    # elif sResult.get('apicode') == 1000:  # code = 1000 店铺SKU已经存在   可能是刊登已经成功,只是wish返回失败
    #     return sResult
    else:
        update_RetryNum(pid)
        raise Exception(u'An error occurred while creating the variant: {}; Please remove the exception link:{}, regenerate the ShopSKU and ParentSKU , and published again!'.format(sResult['errortext'], id))
def get_accesstoken(auth_info,ShopName,conn):
    cwishapi_obj = cwishapi()

    data = {
        'client_id': auth_info['client_id'],
        'client_secret': auth_info['client_secret'],
        'refresh_token': auth_info['refresh_token'],
        'grant_type': 'refresh_token',
    }

    aResult = cwishapi_obj.refresh_token(data, conn, ShopName,auth_info,timeout=30)
    assert aResult['errorcode'] == 1, aResult['errortext']

    return aResult
Пример #5
0
def to_pub(data, pid):
    try:
        param = json.loads(data)

        fristurl   = param['first']['url']
        fristparam = param['first']['product']

        mainimage = param['main_image']
        fristvpic = param['first']['product']['main_image']

        fristparam['main_image'] = mainimage  # 先将主图替换了,创建产品是 第一个变体图替换

        fResult = create_product(fristparam, pid)

        secondurl = param['second']['url']
        if param['second']['product']:
            for secondparam in param['second']['product']:
                try:
                    sResult = create_variant(secondparam, fResult['productid'], pid)
                except Exception as e:
                # if sResult and sResult['errorcode'] != 1:
                    try:  # 如果创建变体时出现错误,则执行该链接的下架操作
                        dis_param = {
                            'access_token': param['first']['product']['access_token'],
                            'format': 'json',
                            'ProductID': fResult['productid'],
                            'ParentSKU': ''
                        }
                        r = cwishapi().disable_by_wish_api(dis_param)
                    except Exception as ex:
                        print u'%s:%s' % (Exception, ex)
                    # 不管下架操作执行是否成功,都抛出异常
                    raise Exception(e)

        if fristvpic:  # 如果 第一变体 有图片
            imgparam = {  # 如果有其他变体,在将第一个变体的图片 修改回来
                'access_token': param['first']['product']['access_token'],
                'format': 'json',
                'sku': param['first']['product']['sku'],
                'main_image': fristvpic,
                "update_product_image": "False",   #  不改变主产品的图片  这个是关键
            }
            # logger.error("imgparam===%s" % (imgparam,))
            uResult = update_first_variant_img(imgparam, fResult['productid'], pid)

        return {'errorcode':1, 'errortext': '', 'productid': fResult['productid']}
    except Exception, e:
        print u'%s:%s' % (Exception, e)
        return {'errorcode': -1, 'errortext': u'%s:%s' % (Exception, e)}
def upload_img_retry(data):
    uresult = cwishapi().upload_image_wish(data)
    if uresult['errorcode'] == 1:
        return uresult
    else:
        raise Exception(u'An error occurred while uploading the image. Upload failed! Please try again later. errortext: %s' % uresult['errortext'])
Пример #7
0
def F_EXE_SHOP_ONLINE_INFO(db_conn, OneCmdRecoreDict, flag):

    from django_redis import get_redis_connection  # get_redis_connection(alias='product')

    t_api_scheduleImp = t_api_schedule(None, db_conn,
                                       get_redis_connection(alias='product'))

    print '--------------------------------------------------------------------OneCmdRecoreDict=%s' % OneCmdRecoreDict
    if not OneCmdRecoreDict.has_key(
            'CMDID'
    ) or OneCmdRecoreDict is None or OneCmdRecoreDict['CMDID'] is None:
        print 'OneCmdRecoreDict=%s' % OneCmdRecoreDict
        #time.sleep(30)
        # redis_conn.client_kill('r-uf6206e9df36e854.redis.rds.aliyuncs.com:6379')
        return
    for cmdid in OneCmdRecoreDict['CMDID']:
        print 'cmdid=================', cmdid
        newOneCmdRecoreDict = copy.deepcopy(OneCmdRecoreDict)
        newOneCmdRecoreDict['CMDID'] = cmdid
        print 'newOneCmdRecoreDict=================', newOneCmdRecoreDict
        record = {}
        try:
            auth_info = t_api_scheduleImp.getauthByShopName(
                newOneCmdRecoreDict['ShopName'])

            cwishapi_obj = cwishapi()
            cResult = cwishapi_obj.warehouseid(auth_info['access_token'])
            assert cResult['errorcode'] == 1, cResult['errortext']

            warehouse_obj = t_wish_shopcode_warehouse(db_conn)
            wReault = warehouse_obj.update_shopcode_waregouse(
                newOneCmdRecoreDict['ShopName'], cResult['data'])
            assert wReault['errorcode'] == 1, wReault['errortext']

            ShopOnlineInfoImp = ShopOnlineInfo(t_api_scheduleImp,
                                               newOneCmdRecoreDict, flag,
                                               db_conn)
            print '0000000000000000000000'
            myresult = ShopOnlineInfoImp.do()
            print '1111111111111111111111'

            params = {}
            params['ShopName'] = myresult['ShopName']
            params['ProductID'] = ''
            params['dbcnxn'] = db_conn
            for productid in set(myresult['ProductID']):
                params['ProductID'] = productid
                if myresult['CMDID'] == 'GetListOrders':
                    refreshordersale.run(params)
                elif myresult['CMDID'] == 'GetShopSKUInfo':
                    refreshwishlisting.run(params)

            record = myresult['record']

        except Exception, ex:
            record = {}
            newOneCmdRecoreDict['Status'] = 'Exception'
            newOneCmdRecoreDict['ActualEndTime'] = datetime.datetime.now()
            newOneCmdRecoreDict[
                'errorinfo'] = '%s  f_GetShopSKUInfo except Exception= %s ex=%s  __LINE__=%s;%s' % (
                    time.strftime('%Y-%m-%d %H:%M:%S',
                                  time.localtime(time.time())), Exception, ex,
                    sys._getframe().f_lineno, traceback.format_exc())
            #t_api_scheduleImp.refreshScheduleTimeAndTimedelta(newOneCmdRecoreDict)
            #t_api_scheduleImp.updateOneCmd(newOneCmdRecoreDict)
            t_api_scheduleImp.moveOneCmd(newOneCmdRecoreDict)
            print '%s  f_GetShopSKUInfo except Exception= %s ex=%s  __LINE__=%s;%s' % (
                time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(
                    time.time())), Exception, ex, sys._getframe().f_lineno,
                traceback.print_exc())
            #print traceback.print_exc()
            time.sleep(1)

        if record:
            # {'start':start,'end':end,'type':type}
            get_wish_product_order_updatetime_obj = get_wish_product_order_updatetime(
                db_conn, newOneCmdRecoreDict['ShopName'])
            get_wish_product_order_updatetime_obj.update_time_or_insert(
                record['start'], record['end'], record['type'])
Пример #8
0
def Wish_Data_Syn(list, synname=''):
    sresult = {'Code': 0, 'messages': ''}
    try:
        shopname = list[0]
        productid = list[1]
        parentsku = list[2]

        upstatus = 'over'  # 日志 状态 更新
        uptext = None

        t_store_configuration_file_obj = t_store_configuration_file(connection)
        t_wish_store_oplogs_obj = t_wish_store_oplogs(connection)
        t_online_info_wish_obj = t_online_info_wish(connection)

        store_status = t_store_configuration_file_obj.getshopStatusbyshopcode(
            shopname)  # 获取店铺状态
        assert store_status['errorcode'] == 0, store_status['errortext']

        if store_status['status'] == '0':  # 店铺状态正常的
            snstatus = '0'  # listing 店铺状态标记
            cwishapi_obj = cwishapi()
            classlisting_obj = classlisting(db_conn=connection,
                                            redis_conn=redis_coon)
            t_online_info_obj = t_online_info(shopname, connection, redis_coon)

            params = CreateParam(shopname, productid, parentsku)

            result = cwishapi_obj.update_wish_goods_data(param=params,
                                                         timeout=30)
            _content = eval(result._content)

            if result.status_code == 200 and _content['code'] == 0:  # api 调用成功
                t_online_info_obj.insertWishV2([_content.get('data', [])
                                                ])  # 更新到t_online_info

                toResult = ToCalculateADS(productid, shopname, connection)
                assert toResult in [
                    '0', '1'
                ], toResult['errortext']  # 获取该product的在线不在线的状态

                sresult['messages'] = u'%s:同步成功' % (productid, )
            else:  # 调用失败
                if _content.get('code') in [1000, 1028, 1006, 1031]:  #
                    toResult = ToCalculateADS(productid, shopname, connection)
                    assert toResult in [
                        '0', '1'
                    ], toResult['errortext']  # 获取该product的在线不在线的状态
                else:
                    toResult = '-1'

                upstatus = 'error'
                uptext = business_Terms(_content)

                # 更新下 redis中shopskulist
                classlisting_db = classlisting(db_conn=connection)
                all_shopsku = classlisting_db.getShopSKUList(productid)
                classlisting_obj.setShopSKUList(productid,
                                                '|'.join(all_shopsku))
                sresult['messages'] = u'%s:%s' % (productid,
                                                  business_Terms(_content))

            refreshwishlisting.run({
                'ShopName': shopname,
                'dbcnxn': connection,
                'ProductID': productid
            })  # Wish数据更新操作

            adResult = t_online_info_wish_obj.UpdateWishStatusAD(
                productid, toResult)  # listing
            assert adResult['errorcode'] == 1, adResult['errortext']
        else:
            upstatus = 'error'
            snstatus = '-1'  # listing 店铺状态标记
            uptext = u'店铺状态被标记为异常'
            sresult['messages'] = u'%s:%s' % (productid, uptext)

        SNResult = t_online_info_wish_obj.UpdateWishSNameByShopName(
            shopname, snstatus)  # listing
        assert SNResult['errorcode'] == 1, SNResult['errortext']

        uResult = t_wish_store_oplogs_obj.updateStatusP(
            synname, productid, upstatus, uptext)  # 更新日志表状态
        assert uResult['errorcode'] == 0, uResult['errortext']

        sresult['Code'] = 1
    except Exception, e:
        sresult['Code'] = -1
        sresult['messages'] = '%s:%s;%s' % (Exception, e,
                                            traceback.format_exc())
Пример #9
0
def MainBatchUpdateShipping(paramlsit, synname, warehouse):
    try:
        shippingDataList = eval(paramlsit[2])

        auth_info = verb_token(shopname=paramlsit[0], conn=connection)
        assert auth_info['errorcode'] == 1, auth_info['errortext']

        warehouse_obj = t_wish_shopcode_warehouse(connection)
        wResult = warehouse_obj.get_warehouse(paramlsit[0])
        assert wResult['errorcode'] == 1, wResult['errortext']
        if not wResult['warehouse'].has_key(warehouse):
            raise Exception(u'该店铺没有相应的仓库:%s,店铺所有仓库:%s' %
                            (warehouse, wResult['warehouse']))

        cwishapi_obj = cwishapi()
        t_wish_store_oplogs_obj = t_wish_store_oplogs(connection)

        show_log_text = ''
        for shippingData in shippingDataList:
            shippingData['id'] = paramlsit[1]
            shippingData['format'] = 'json'
            shippingData['access_token'] = auth_info['access_token']
            shippingData['warehouse_name'] = wResult['warehouse'][warehouse]

            if shippingData.get('_add') and int(
                    shippingData.get('_add').strip()) != 0:  # 原有基础上增加 运费
                rsp = cwishapi().Get_Shipping_Prices_of_a_Product({
                    'access_token':
                    auth_info['access_token'],
                    'product_id':
                    paramlsit[1],
                    'country':
                    shippingData['country']
                })
                _add = shippingData.pop('_add')
                if rsp['errorcode'] == 1:
                    if rsp['shiping_infors']['ProductCountryShipping'][
                            'use_product_shipping'] == 'True':
                        shippinglist = all_shipping_list(paramlsit)
                        shippingData['price'] = str(
                            max(shippinglist) + float(_add))
                    else:
                        shippingData['price'] = str(
                            float(rsp['shiping_infors']
                                  ['ProductCountryShipping']['shipping_price'])
                            + float(_add))
                else:
                    raise Exception(rsp['errortext'])

            elif shippingData.get('_add') and int(
                    shippingData.get('_add').strip()) == 0:
                shippinglist = all_shipping_list(paramlsit)
                shippingData['price'] = str(max(shippinglist))

            edit_result = cwishapi_obj.edit_shipping_price_of_a_product(
                shippingData)
            # edit_result = {'errorcode': -1, 'errortext': json.dumps(shippingData)}
            keyone = '{}_{}'.format(paramlsit[1], shippingData['country'])
            if edit_result['errorcode'] == 1:
                uPResult = t_wish_store_oplogs_obj.updateStatusP(
                    synname, keyone, 'over', '')
                utext = uPResult['errortext'] if uPResult[
                    'errorcode'] == -1 else ''
                show_log_text += u'ProductID: {},国家: {}; 修改成功!{}\n'.format(
                    paramlsit[1], shippingData['country'], utext)
            else:
                uPResult = t_wish_store_oplogs_obj.updateStatusP(
                    synname, keyone, 'error', edit_result['errortext'])
                utext = uPResult['errortext'] if uPResult[
                    'errorcode'] == -1 else ''
                show_log_text += u'ProductID: {},国家: {}; 修改失败!错误原因: {}, {} \n'.format(
                    paramlsit[1], shippingData['country'],
                    edit_result['errortext'], utext)
        return {'Code': 1, 'messages': ''}
    except Exception as error:
        return {'Code': -1, 'messages': '%s:%s' % (synname, error)}
Пример #10
0
def edit_GoodsInformation_by_ID(datadict, ShopName, flagname):
    myresult = {'Code': 0, 'messages': ''}
    try:
        uptext = None
        upstatus = 'over'  # 日志

        t_wish_store_oplogs_obj = t_wish_store_oplogs(connection)
        t_store_configuration_file_obj = t_store_configuration_file(connection)
        t_online_info_wish_obj = t_online_info_wish(connection)

        store_status = t_store_configuration_file_obj.getshopStatusbyshopcode(
            ShopName)  # 获取店铺状态
        assert store_status['errorcode'] == 0, store_status['errortext']

        if store_status['status'] == '0':  # 店铺状态正常的
            snstatus = '0'

            cwishapi_obj = cwishapi()

            auth_info = verb_token(ShopName, connection)
            assert auth_info['errorcode'] == 1, auth_info['errortext']

            datadict['access_token'] = auth_info.get('access_token', '')
            datadict['format'] = 'json'

            if datadict.get('main_image'):  # 主图发生改变
                mainimage = datadict['main_image'].keys()[0]
                if datadict['main_image'][mainimage] == '1':  # 本地上传图片
                    mResult = wish_image_upload(mainimage, auth_info)
                    assert mResult['errorcode'] == 1, mResult['errortext']
                    datadict['main_image'] = mResult['image_url']
                else:
                    datadict['main_image'] = mainimage.replace(
                        '-medium.', '-original.')

            eImage_list = []
            for eImage in datadict.get('extra_images', []):
                e_pic = eImage.keys()[0]
                if eImage[e_pic] == '1':
                    evResult = wish_image_upload(e_pic, auth_info)
                    assert evResult['errorcode'] == 1, evResult['errortext']
                    eImage_list.append(evResult['image_url'])
                else:
                    eImage_list.append(e_pic.replace('-medium.', '-original.'))

            if eImage_list:
                datadict['extra_images'] = '|'.join(eImage_list)

            logger.info('datadict===============%s' % datadict)
            rtresult = cwishapi_obj.update_goods_info_by_wish_api(datadict,
                                                                  timeout=30)
            _content = eval(rtresult._content)

            if rtresult.status_code == 200 and _content['code'] == 0:

                toResult = ToCalculateADS(datadict['id'], ShopName, connection)
                assert toResult in [
                    '0', '1'
                ], toResult['errortext']  # 获取该product的在线不在线的状态

                myresult['messages'] = u'%s:链接信息修改成功' % (datadict['id'], )
            else:
                if _content.get('code') in [1000, 1028, 1006,
                                            1031]:  # 平台禁止修改加钻产品标题
                    toResult = ToCalculateADS(datadict['id'], ShopName,
                                              connection)
                    assert toResult in [
                        '0', '1'
                    ], toResult['errortext']  # 获取该product的在线不在线的状态

                else:
                    toResult = '-1'
                upstatus = 'error'  # 日志
                uptext = business_Terms(_content)

                myresult['messages'] = u'%s:链接信息修改失败,%s' % (datadict['id'],
                                                            uptext)

            dResult = Wish_Data_Syn([ShopName, datadict['id'], ''], 'syn')
            assert dResult['Code'] == 1, dResult['messages']

            adResult = t_online_info_wish_obj.UpdateWishStatusAD(
                datadict['id'], toResult)
            assert adResult['errorcode'] == 1, adResult['errortext']

            myresult['_content'] = _content
        else:
            upstatus = 'error'
            snstatus = '-1'  # listing 店铺状态标记
            uptext = u'店铺状态被标记为异常'
            myresult['_content'] = uptext
            myresult['messages'] = u'%s:链接信息修改失败,%s' % (datadict['id'], uptext)

        uResult = t_wish_store_oplogs_obj.updateStatusP(
            flagname, datadict['id'], upstatus, uptext)
        assert uResult['errorcode'] == 0, uResult['errortext']

        SNResult = t_online_info_wish_obj.UpdateWishSNameByShopName(
            ShopName, snstatus)  # shopname
        assert SNResult['errorcode'] == 1, SNResult['errortext']

        myresult['Code'] = 1
    except Exception, e:
        myresult['Code'] = -1
        myresult['messages'] = '%s:%s:%s' % (datadict['id'], Exception, e)
Пример #11
0
def OnTheShelf_OR_LowerFrame_BY_ShopSKU(shopsku, shopname, flag, flagname=''):
    myresult = {'Code': 0, 'messages': ''}
    try:
        upstatus = 'over'  # 日志
        uptext = None

        t_wish_store_oplogs_obj = t_wish_store_oplogs(connection)
        t_store_configuration_file_obj = t_store_configuration_file(connection)
        t_online_info_wish_obj = t_online_info_wish(connection)

        store_status = t_store_configuration_file_obj.getshopStatusbyshopcode(
            shopname)  # 获取店铺状态
        assert store_status['errorcode'] == 0, store_status['errortext']

        if store_status['status'] == '0':  # 店铺状态正常的
            snstatus = '0'  # 店铺状态
            classshopsku_obj = classshopsku(redis_conn=redis_coon,
                                            shopname=shopname)
            cwishapi_obj = cwishapi()
            t_online_info_obj = t_online_info(shopname, connection)

            auth_info = verb_token(shopname, connection)
            assert auth_info['errorcode'] == 1, auth_info['errortext']

            data = {}
            data['access_token'] = auth_info.get('access_token', '')
            data['ShopSKU'] = shopsku

            proinfo = t_online_info_obj.get_listingid_by_shopname_shopsku(
                shopsku)
            assert proinfo[
                'errorcode'] == 0, 'EDGetProductIDSuccess:%s' % proinfo[
                    'errortext']

            if flag == 'enshopsku':  # ShopSKU上架
                sstatus = 'Enabled'
                result = cwishapi_obj.update_to_enable(data, timeout=30)
            else:
                sstatus = 'Disabled'
                result = cwishapi_obj.update_to_disable(data, timeout=30)

            _content = eval(result._content)

            if result.status_code == 200 and _content['code'] == 0:
                uResult = t_online_info_obj.update_status_by_shopsku(
                    sstatus, shopsku)  # 更新shopsku状态数据
                assert uResult[
                    'errorcode'] == 0, 'EDSuccess:%s' % uResult['errortext']

                classshopsku_obj.setStatus(shopsku, sstatus)  # 修改redis数据

                toResult = ToCalculateADS(proinfo['productid'], shopname,
                                          connection)
                assert toResult in [
                    '0', '1'
                ], toResult['errortext']  # 获取该product的在线不在线的状态

                if flag == 'enshopsku':  # ShopSKU上架
                    myresult['messages'] = u'%s:上架成功' % (shopsku, )
                else:
                    myresult['messages'] = u'%s:下架成功' % (shopsku, )
            else:
                if _content.get('code') in [1000, 1028, 1006,
                                            1031]:  # 平台禁止修改加钻产品标题
                    toResult = ToCalculateADS(proinfo['productid'], shopname,
                                              connection)
                    assert toResult in [
                        '0', '1'
                    ], toResult['errortext']  # 获取该product的在线不在线的状态
                else:
                    toResult = '-1'

                upstatus = 'error'  # 日志
                uptext = business_Terms(_content)
                myresult['messages'] = u'%s:上下架操作失败!%s' % (
                    shopsku, business_Terms(_content))

            refreshwishlisting.run({
                'ShopName': shopname,
                'dbcnxn': connection,
                'ProductID': proinfo['productid']
            })  # Wish数据更新操作

            adResult = t_online_info_wish_obj.UpdateWishStatusAD(
                proinfo['productid'], toResult)
            assert adResult['errorcode'] == 1, adResult['errortext']

            myresult['_content'] = _content
        else:
            upstatus = 'error'
            snstatus = '-1'  # listing 店铺状态标记
            uptext = u'店铺状态被标记为异常'
            myresult['_content'] = uptext
            myresult['messages'] = u'%s:上下架操作失败!%s' % (shopsku, uptext)

        uPResult = t_wish_store_oplogs_obj.updateStatusP(
            flagname, shopsku, upstatus, uptext)
        assert uPResult['errorcode'] == 0, uPResult['errortext']

        SNResult = t_online_info_wish_obj.UpdateWishSNameByShopName(
            shopname, snstatus)  # shopname
        assert SNResult['errorcode'] == 1, SNResult['errortext']

        myresult['Code'] = 1
    except Exception, e:
        myresult['Code'] = -1
        myresult['messages'] = '%s:%s:%s' % (shopsku, Exception, e)
Пример #12
0
def OnTheShelf_OR_LowerFrame(list, flag, synname):
    sresult = {'Code': 0, 'messages': ''}
    try:
        shopname = list[0]
        productid = list[1]
        parentsku = list[2]

        upstatus = 'over'  # 日志
        uptext = None

        t_store_configuration_file_obj = t_store_configuration_file(connection)
        t_wish_store_oplogs_obj = t_wish_store_oplogs(connection)
        t_online_info_wish_obj = t_online_info_wish(connection)

        store_status = t_store_configuration_file_obj.getshopStatusbyshopcode(
            shopname)  # 获取店铺状态
        assert store_status['errorcode'] == 0, store_status['errortext']

        if store_status['status'] == '0':  # 店铺状态正常的
            snstatus = '0'  # listing 店铺状态标记

            classlisting_obj = classlisting(db_conn=connection,
                                            redis_conn=redis_coon)
            cwishapi_obj = cwishapi()
            classshopsku_obj = classshopsku(redis_conn=redis_coon,
                                            shopname=shopname)

            t_online_info_obj = t_online_info(shopname, connection, redis_coon)

            params = CreateParam(shopname, productid, parentsku)

            if flag == 'enable':
                Status = 'Enabled'
                result = cwishapi_obj.enable_by_wish_api(params, timeout=30)
            else:
                Status = 'Disabled'
                result = cwishapi_obj.disable_by_wish_api(params, timeout=30)

            _content = eval(result._content)

            if result.status_code == 200 and _content['code'] == 0:
                aResult = t_online_info_wish_obj.UpdateWishStatus(
                    productid, Status)
                assert aResult['errorcode'] == 1, aResult['errortext']

                iResult = t_online_info_obj.update_status_by_productid(
                    Status, productid)
                assert iResult[
                    'errorcode'] == 0, "SynSuccess:%s" % iResult['errortext']

                shopskulist = classlisting_obj.getShopSKUList(productid)
                if shopskulist is None:
                    shopskulist = []
                for shopsku in shopskulist:
                    classshopsku_obj.setStatus(shopsku, Status)

                toResult = ToCalculateADS(productid, shopname, connection)
                assert toResult in [
                    '0', '1'
                ], toResult['errortext']  # 获取该product的在线不在线的状态

                if flag == 'enable':
                    sresult['messages'] = u'%s:上架成功' % (productid, )
                else:
                    sresult['messages'] = u'%s:下架成功' % (productid, )
            else:
                if _content.get('code') in [1000, 1028, 1006,
                                            1031]:  # 平台禁止修改加钻产品标题
                    toResult = ToCalculateADS(productid, shopname, connection)
                    assert toResult in [
                        '0', '1'
                    ], toResult['errortext']  # 获取该product的在线不在线的状态

                else:
                    toResult = '-1'  # 单链接操作状态

                upstatus = 'error'
                uptext = business_Terms(_content)
                sresult['messages'] = u'%s:%s' % (productid,
                                                  business_Terms(_content))

            refreshwishlisting.run({
                'ShopName': shopname,
                'dbcnxn': connection,
                'ProductID': productid
            })  # Wish数据更新操作

            adResult = t_online_info_wish_obj.UpdateWishStatusAD(
                productid, toResult)
            assert adResult['errorcode'] == 1, adResult['errortext']
        else:
            upstatus = 'error'
            snstatus = '-1'  # listing 店铺状态标记
            uptext = u'店铺状态被标记为异常'
            sresult['messages'] = u'%s:%s' % (productid, uptext)

        uResult = t_wish_store_oplogs_obj.updateStatusP(
            synname, productid, upstatus, uptext)
        assert uResult['errorcode'] == 0, uResult['errortext']

        SNResult = t_online_info_wish_obj.UpdateWishSNameByShopName(
            shopname, snstatus)  # listing
        assert SNResult['errorcode'] == 1, SNResult['errortext']

        sresult['Code'] = 1
    except Exception, e:
        sresult['Code'] = -1
        sresult['messages'] = '%s:%s' % (Exception, e)
Пример #13
0
    def insertWishV2(self, data):
        refreshdict = {}
        refreshdict['ShopName'] = ''
        prolist = []
        #cnxn = MySQLdb.connect(DATABASES['HOST'],DATABASES['USER'],DATABASES['PASSWORD'],DATABASES['NAME'] )
        cursor = self.cnxn.cursor()
        #ShopIP = socket.gethostbyname(socket.gethostname())
        #sql_delete = 'delete from t_online_info where ShopName =\'%s\' '%self.ShopName.strip()
        #cursor.execute(sql_delete)

        classlisting_obj = classlisting.classlisting(self.cnxn,
                                                     self.redis_conn)

        classshopsku_obj = classshopsku.classshopsku(self.cnxn,
                                                     self.redis_conn,
                                                     self.ShopName)

        # classshopname_obj = classshopname.classshopname(db_conn = self.cnxn)
        t_store_configuration_file_obj = t_store_configuration_file(self.cnxn)

        classsku_obj = classsku.classsku(self.cnxn, self.redis_conn)
        t_event_class_obj = t_event_class()

        cwishapi_obj = cwishapi()
        insert_product = []
        delete_product = []
        update_product = []
        # logger = logging.getLogger('sourceDns.webdns.views')
        for row in data:
            #print(row)
            ProductID = row['Product']['id']
            # logger.error("ProductID===%s" % (ProductID, ))
            prolist.append(ProductID)

            is_promoted = row['Product'].get('is_promoted', '')
            classlisting_obj.set_is_promoted_listingid(ProductID, is_promoted)

            WishExpress = '%s' % row['Product'].get(
                'wish_express_country_codes', '[]')

            classlisting_obj.set_WishExpress_listingid(ProductID, WishExpress)

            ProductName = row['Product']['name']
            if '\u' in ProductName:
                try:
                    ProductName = ProductName.decode("unicode_escape")
                except:
                    pass

            OfWishes = row['Product']['number_saves']
            OfSales = row['Product']['number_sold']
            ParentSKU = row['Product']['parent_sku'].replace(
                '&lt;', '<').replace('&gt;',
                                     '>').replace("&#39;",
                                                  "'").replace('\\/', '/')

            if '\u' in ParentSKU:
                try:
                    ParentSKU = ParentSKU.decode("unicode_escape")
                except:
                    pass

            ReviewState = row['Product']['review_status']  #当前 wish查看状态
            be_sql = "select DISTINCT ReviewState,BeforeReviewState from t_online_info WHERE ProductID=%s LIMIT 1;"
            cursor.execute(be_sql, (ProductID, ))
            beforers = cursor.fetchone()
            BeforeReviewState = None  # 上一个wish查看状态
            if beforers and len(beforers) == 2:
                if ReviewState == 'rejected' and beforers[
                        0] == 'rejected' and beforers[1]:
                    BeforeReviewState = beforers[1]
                elif beforers[0]:
                    BeforeReviewState = beforers[0]

            ImageURL = row['Product']['main_image'].replace('\\', '')
            DateUploaded = time.strftime(
                "%Y-%m-%d",
                time.strptime(
                    row['Product']['date_uploaded'],
                    "%m-%d-%Y"))  # row['Product']['date_uploaded'] 07-01-2017
            LastUpdated = time.strftime(
                "%Y-%m-%dT%H:%M:%S",
                time.strptime(row['Product']['last_updated'],
                              "%m-%d-%YT%H:%M:%S")
            )  # row['Product']['last_updated']  08-03-2017T10:21:09
            ExtraImages = row['Product']['extra_images'].replace('\\', '')
            Description = row['Product']['description']
            if '\u' in Description:
                try:
                    Description = Description.decode("unicode_escape")
                except:
                    pass

            ShopName = self.ShopName.strip()
            refreshdict['ShopName'] = ShopName
            PlatformName = 'Wish'
            Tags_dict = row['Product']['tags']
            Title = ProductName

            DepartmentID = t_store_configuration_file_obj.getDepartmentbyshopcode(
                ShopName)  # 获取该店铺的部门编号
            seller = t_store_configuration_file_obj.getsellerbyshopcode(
                ShopName)  # 获取该店铺的 销售员 目前没有走redis
            Published = t_store_configuration_file_obj.getPublishedbyshopcode(
                ShopName)  # 获取该店铺的 刊登人 目前没有走redis
            if seller is None or seller.strip() == '':
                seller = Published

            SKU = ''
            RefreshTime = datetime.datetime.now()
            #print RefreshTime
            Tags = ''
            for Tag_dict in Tags_dict:
                if Tags == '':
                    Tags = Tag_dict['Tag']['name']
                else:
                    Tags = '%s,%s' % (Tags, Tag_dict['Tag']['name'])

            # cursor.execute('Delete from t_online_info where  ProductID= %s ; ',(ProductID,))

            shopskulist = []  # 定义ShopSKU列表

            filterdict = {}  # 用于 存放 需要修改的 商品SKU
            vidlist = []
            fbw_flag_list = []  # fbw标记列表
            for variant in row['Product']['variants']:
                VariationID = variant['Variant']['id']  # 平台唯一ID
                vidlist.append(VariationID)

                shopskutmp = variant['Variant']['sku'].replace(
                    '&lt;', '<').replace('&gt;',
                                         '>').replace('&amp;', '&').replace(
                                             "&#39;", "'").replace('\\/', '/')
                # logger.error("shopskutmp===%s" % (shopskutmp, ))

                if '\u' in shopskutmp:
                    try:
                        shopskutmp = shopskutmp.decode('unicode-escape')
                    except:
                        pass

                eshopsku = shopskutmp

                # 刷新fbw标记
                fbw_flag = refresh_fbw_flag(product_id=ProductID,
                                            shopsku=eshopsku,
                                            shopname=ShopName,
                                            connection=self.cnxn)
                fbw_flag_list.append(fbw_flag)

                SKU = classshopsku_obj.getSKU(eshopsku)  # 商品SKU get

                sku_goodsstatus = None
                if SKU is not None and SKU.strip() != '':
                    sku_goodsstatus = classsku_obj.get_goodsstatus_by_sku(
                        SKU)  # 获取商品SKU的商品状态
                # 下面是简单的转换
                if sku_goodsstatus == u'正常':
                    sku_goodsstatus = '1'
                elif sku_goodsstatus == u'售完下架':
                    sku_goodsstatus = '2'
                elif sku_goodsstatus == u'临时下架':
                    sku_goodsstatus = '3'
                elif sku_goodsstatus == u'停售':
                    sku_goodsstatus = '4'

                #print sku_goodsstatus
                ShopSKUImage = ''
                if variant['Variant'].has_key('main_image'):
                    ShopSKUImage = variant['Variant']['main_image'].replace(
                        '\\', '')
                classshopsku_obj.setImage(eshopsku, ShopSKUImage)  # 变体图 set

                Price = variant['Variant']['price']
                classshopsku_obj.setPrice(eshopsku, Price)  # 价格 set

                Inventory = variant['Variant']['inventory']
                if Inventory == '':
                    Inventory = None
                classshopsku_obj.setQuantity(eshopsku, Inventory)  # 库存 set

                Status = variant['Variant'].get('enabled',
                                                '')  # "enabled": "False",
                if Status.strip() == 'False':
                    Statusssss = 'Disabled'
                elif Status.strip() == 'True':  # True
                    Statusssss = 'Enabled'
                else:
                    Statusssss = Status
                classshopsku_obj.setStatus(eshopsku, Statusssss)  # 状态 set

                if Statusssss == 'Enabled':
                    filterdict[SKU] = 0

                Shipping = variant['Variant']['shipping']
                if Shipping == '':
                    Shipping = None
                classshopsku_obj.setShipping(eshopsku, Shipping)  # 运费 set

                Color = ''
                if variant['Variant'].has_key('color'):
                    Color = variant['Variant']['color'].replace('&amp;',
                                                                '&')  #  &
                classshopsku_obj.setColor(eshopsku, Color)  # 颜色 set

                Size = ''
                if variant['Variant'].has_key('size'):
                    Size = variant['Variant']['size'][:30]
                classshopsku_obj.setSize(eshopsku, Size)  # 尺寸 set

                msrp = variant['Variant']['msrp']
                classshopsku_obj.setmsrp(eshopsku, msrp)  # 标签价 set

                ShippingTime = variant['Variant']['shipping_time']
                classshopsku_obj.setshippingtime(eshopsku,
                                                 ShippingTime)  # 运输时间 set
                # Quantity = Inventory

                cursor.execute(
                    "select count(VariationID) from t_online_info WHERE ProductID=%s and VariationID=%s;",
                    (
                        ProductID,
                        VariationID,
                    ))
                somecount = cursor.fetchone()
                if somecount[0] > 0:
                    sql_update = "update t_online_info set Title=%s,Price=%s,Quantity=%s,RefreshTime=%s,Image=%s,Status=%s," \
                                 "ReviewState=%s,OfWishes=%s,OfSales=%s,LastUpdated=%s,Shipping=%s,Color=%s,`Size`=%s,msrp=%s," \
                                 "ShippingTime=%s,ExtraImages=%s,Description=%s,Tags=%s,ShopSKUImage=%s,is_promoted=%s," \
                                 "WishExpress=%s,seller=%s,Published=%s,SKU=%s,MainSKU=%s,BeforeReviewState=%s,ShopSKU=%s" \
                                 " WHERE ProductID=%s and VariationID=%s;"

                    cursor.execute(
                        sql_update,
                        (Title, Price, Inventory, RefreshTime, ImageURL,
                         Statusssss, ReviewState, OfWishes, OfSales,
                         LastUpdated, Shipping, Color, Size, msrp,
                         ShippingTime, ExtraImages, Description, Tags,
                         ShopSKUImage, is_promoted, WishExpress,
                         seller, Published, SKU,
                         classsku_obj.get_bemainsku_by_sku(SKU),
                         BeforeReviewState, shopskutmp, ProductID,
                         VariationID))
                    # if not SKU:
                    update_product.append(ProductID)
                else:
                    sql_insert = 'INSERT INTO t_online_info(ShopIP,ShopName,PlatformName,ProductID,Title,' \
                                 'SKU,ShopSKU,Price,Quantity,RefreshTime,Image,Status,DateUploaded,ParentSKU,' \
                                 'ReviewState,OfWishes,OfSales,LastUpdated,Shipping,Color,`Size`,msrp,' \
                                 'ShippingTime,ExtraImages,VariationID,Description,Tags,' \
                                 'MainSKU,ShopSKUImage,is_promoted,WishExpress,DepartmentID,seller,Published,' \
                                 'GoodsStatus,filtervalue,APIState,BeforeReviewState)' \
                                 ' VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,' \
                                 '%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ; '
                    cursor.execute(
                        sql_insert,
                        (self.ShopIP, ShopName, PlatformName, ProductID, Title,
                         SKU, shopskutmp, Price, Inventory, RefreshTime,
                         ImageURL, Statusssss, DateUploaded, ParentSKU,
                         ReviewState, OfWishes, OfSales, LastUpdated, Shipping,
                         Color, Size, msrp, ShippingTime, ExtraImages,
                         VariationID, Description, Tags,
                         classsku_obj.get_bemainsku_by_sku(SKU), ShopSKUImage,
                         is_promoted, WishExpress, DepartmentID, seller,
                         Published, sku_goodsstatus, 1, 'nothing',
                         BeforeReviewState))
                    insert_product.append(ProductID)
                # sql_update = "update  py_db.b_goodsskulinkshop a, t_online_info b set b.sku = a.sku ,b.MainSKU  = getMainSKU(a.SKU) ,b.MainShopSKU = getMainSKU(b.shopSKU) where a.shopsku =  b.shopsku and  b.ProductID  = %s and b.ShopSKU = %s "
                # cursor.execute(sql_update,(ProductID,ShopSKU))

                shopskulist.append(shopskutmp)
                # logger.error("shopskulist===%s" % (shopskulist, ))
                # logger.error("join===%s" % ('|'.join(shopskulist), ))
                #sql_update_mainsku = 'update t_online_info set MainSKU  = getMainSKU(SKU) ,MainShopSKU = getMainSKU(shopSKU)  where   ProductID= %s and ShopSKU =%s '
                #cursor.execute(sql_update_mainsku,(ProductID,ShopSKU))

            # 获取该产品的海外仓运费和库存

            for we in eval(WishExpress):  # 是属于海外仓的
                # raise Exception(self.warehouse)
                if self.warehouse.has_key(we) and we in ['DE', 'GB', 'US']:
                    warehouseid = self.warehouse[we]
                    vgoodsinfos = cwishapi_obj.warehouse_vgoodsinfo(
                        self.access_token, ProductID, warehouseid)
                    # assert vgoodsinfos['errorcode'] == 1, vgoodsinfos['errortext']
                    if vgoodsinfos['errorcode'] == 1:
                        for vgoods in vgoodsinfos['data']:
                            wvid = vgoods['Variant']['id']

                            shopsku = vgoods['Variant']['sku'].replace(
                                '&lt;', '<').replace('&gt;', '>').replace(
                                    '&amp;',
                                    '&').replace("&#39;",
                                                 "'").replace('\\/', '/')
                            if '\u' in shopsku:
                                try:
                                    shopsku = shopsku.decode('unicode-escape')
                                except:
                                    pass

                            wshipping = vgoods['Variant'][
                                'shipping']  # DEExpressShipping
                            if wshipping == '':
                                wshipping = None
                            ws = getattr(classshopsku_obj,
                                         "setWish%sShipping" % we)
                            ws(shopsku, wshipping)
                            # eval("classshopsku_obj.setWish%sShipping" % we)(shopsku, wshipping)

                            winventory = vgoods['Variant'][
                                'inventory']  # DEExpressInventory
                            if winventory == '':
                                winventory = None
                            wi = getattr(classshopsku_obj,
                                         "setWish%sQuantity" % we)
                            wi(shopsku, winventory)
                            # eval("classshopsku_obj.setWish%sQuantity" % we)(shopsku, winventory)

                            vsql = "update t_online_info set " + we + "ExpressShipping=%s," + we + \
                                   "ExpressInventory=%s WHERE ProductID=%s and VariationID=%s;"

                            cursor.execute(
                                vsql, (wshipping, winventory, ProductID, wvid))

            if vidlist:  # 删除多余的变体信息
                del_param_list = []
                old_shopsku_list = classlisting_obj.getShopSKUList(ProductID)
                if old_shopsku_list:
                    for del_shopsku in old_shopsku_list:
                        if del_shopsku not in shopskulist:
                            del_param_list.append([ProductID, del_shopsku])
                            delete_product.append(ProductID)
                            # del_sku = classshopsku_obj.getSKU(del_shopsku)
                            # if del_sku:
                            #     delete_sku.append(del_sku)

                cursor.executemany(
                    "delete from t_online_info WHERE ProductID=%s and ShopSKU=%s ;",
                    del_param_list)

            classlisting_obj.setShopSKUList(
                ProductID, '|'.join(shopskulist))  # ProductID ShopSKUList
            # for k,v in filterdict.items():
            #     cursor.execute("update t_online_info set filtervalue = 0 WHERE ProductID=%s and SKU=%s;",(ProductID,k,))

            if fbw_flag_list and 'True' in fbw_flag_list:
                cursor.execute(
                    "update t_online_info set FBW_Flag = 'True' WHERE ProductID=%s ;",
                    (ProductID, ))
            elif 'False' in fbw_flag_list:
                cursor.execute(
                    "update t_online_info set FBW_Flag = 'False' WHERE ProductID=%s ;",
                    (ProductID, ))

        self.cnxn.commit()

        for inproduct in set(insert_product):
            iResult = t_event_class_obj.t_online_info_insert_trigger(inproduct)

        for delproduct in set(delete_product):
            del_Result = t_event_class_obj.t_online_info_delete_trigger(
                delproduct)

        for updproduct in set(update_product):
            upd_Result = t_event_class_obj.t_online_info_update_trigger(
                updproduct)

        cursor.close()
        refreshdict['ProductID'] = prolist
        return refreshdict
Пример #14
0
    def insertWishV2(self, data):
        t_chart_wish_refund_log_obj = t_chart_wish_refund_log(self.cnxn)
        t_order_of_wish_fbw_fee_obj = t_order_of_wish_fbw_fee(self.cnxn)
        #{'Order': {'last_updated': '2017-12-23T04:20:10', 'refunded_time': '2017-12-23', 'variant_id': '58ca21d8415c9d10f9e1f5c5', 'requires_delivery_confirmation': 'False', 'refunded_by': 'REFUNDED BY WISH FOR MERCHANT', 'cost': '0.85', 'shipping_cost': '0.85', 'sku': 'YIYI0683', 'shipping_provider': 'Yanwen', 'order_total': '1.7', 'state': 'REFUNDED', 'refunded_reason': 'Shipping taking too long', 'product_name': 'Silver Small  Bells Bracelet Women&#39;s Fashion Jewelry Bracelet Adjustable', 'transaction_id': '59ffdfaef3d77e7c40e39bd6', 'order_time': '2017-11-06T04:06:07', 'order_id': '59ffdfaf7fb32058245cea71', 'price': '1.0', 'ShippingDetail': {'phone_number': '2056168267', 'city': 'Pensacola', 'name': 'Cindy Steadman', 'country': 'US', 'zipcode': '32507', 'street_address1': '10085 north loop rd #4', 'state': 'Florida'}, 'is_wish_express': 'False', 'product_image_url': 'https:\\/\\/contestimg.wish.com\\/api\\/webimage\\/58ca21d8415c9d10f9e1f5c3-normal.jpg?cache_buster=07f5b38ede50dd311f1f68157ae14cc7', 'shipped_date': '2017-11-06', 'tracking_confirmed': 'True', 'product_id': '58ca21d8415c9d10f9e1f5c3', 'shipping': '1.0', 'tracking_number': '8001535543033', 'tracking_confirmed_date': '2017-11-11T02:35:34', 'buyer_id': '57c6f9fbc3eea72dc2328dfd', 'quantity': '1'}}
        #{'Order': {'last_updated': '2017-12-23T02:07:23', 'variant_id': '58e7544b28c2731929227750', 'requires_delivery_confirmation': 'False', 'shipped_date': '2017-12-23', 'cost': '1.7', 'shipping_cost': '0.85', 'sku': 'YIYI0696', 'shipping_provider': 'PX4', 'order_total': '2.55', 'state': 'SHIPPED', 'product_name': 'Soft Ball Puzzle Fun Baby Infant Baby Teether Toy Rattles Spherical Molar Baby Physical Exercise Toy', 'transaction_id': '5a3c27c0cbe959d4e463031e', 'order_time': '2017-12-21T21:29:36', 'order_id': '5a3c27c0df424514f14d3b86', 'price': '2.0', 'ShippingDetail': {'phone_number': '096225134', 'city': 'Hirschau', 'name': 'Nicoleta Bischof', 'country': 'DE', 'zipcode': '92242', 'street_address1': 'Klostergasse 22'}, 'is_wish_express': 'False', 'product_image_url': 'https:\\/\\/contestimg.wish.com\\/api\\/webimage\\/58e7544b28c273192922774e-normal.jpg?cache_buster=ab029a461cdd1d41ba05ef5ffe5b1320', 'tracking_confirmed': 'False', 'product_id': '58e7544b28c273192922774e', 'shipping': '1.0', 'tracking_number': 'OZ034586029PY', 'buyer_id': '5918d37818b43a855637ce38', 'quantity': '1'}}
        redreshdict = {}

        cursor = self.cnxn.cursor()
        redreshdict['ShopName'] = self.ShopName
        productlist = []
        for row in data:
            PlatformName = 'Wish'
            ShopName = self.ShopName
            OrderDate = row['Order'].get('order_time', '')
            OrderId = row['Order'].get('order_id', '')
            OrderState = row['Order'].get('state', '')
            ShopSKU = row['Order'].get('sku', '')
            SKU = ''
            Title = row['Order'].get('product_name', '')  #.replace('\'','`')
            ProductID = row['Order'].get('product_id', '')

            productlist.append(ProductID)
            ImageURL = row['Order'].get('product_image_url',
                                        '').replace('\\', '')

            Price = row['Order'].get('price', '')
            Shipping = row['Order'].get('shipping', '')
            Quantity = row['Order'].get('quantity', '')
            TotalCost = row['Order'].get('order_total', '')
            Shippedon = row['Order'].get('shipped_date', '')
            LastUpdated = row['Order'].get('last_updated', '')
            RefundDate = row['Order'].get('refunded_time', '')
            RefundReason = row['Order'].get('refunded_reason',
                                            '').decode("unicode-escape")
            UpdateTime = datetime.datetime.now()

            is_wish_express = row['Order'].get('is_wish_express',
                                               '')  # 海外仓信息 标志
            is_fbw = row['Order'].get('is_fbw')  # fbw 订单处理
            fbw_fee_list = row['Order'].get('fbw_fees', [])
            if is_fbw == 'True':
                fbw_default = {
                    'currency': None,
                    'amount': None,
                    'fee_name': None,
                    'fee_type_text': None,
                    'fee_type': None,
                    'order_id': None
                }

                fbw_fee = fbw_fee_list[0]['FBWFee'] if len(
                    fbw_fee_list) >= 1 else fbw_default
                fbw_fee['fbw_warehouse_code'] = row['Order'].get(
                    'fbw_warehouse_code')
                fbw_fee['order_id'] = OrderId
                fee_result = t_order_of_wish_fbw_fee_obj.insert_fbw_fee(
                    fbw_fee)

            ShippingDetail = row['Order'].get('ShippingDetail', '')  # 买家信息 标志

            fine_ids = row['Order'].get('fine_ids', [])  # 罚款ID

            log_param = {
                'OrderID': OrderId,
                'OrderState': OrderState,
                'OrderFlag': '',
            }

            cursor.execute(
                "select count(OrderId) from t_order WHERE OrderId = %s ; ",
                (OrderId, ))
            ordernum = cursor.fetchone()
            if ordernum[0] > 0:
                sql_update = "update t_order set OrderState = %s, SKU = %s, LastUpdated = %s, UpdateTime = %s," \
                             " TotalCost = %s, RefundDate = %s, RefundReason = %s, WishExpress = %s, FBWStatus=%s," \
                             "BuyerInfor = %s " \
                             "WHERE OrderId = %s ;"

                cursor.execute(
                    sql_update,
                    (OrderState, SKU, LastUpdated, UpdateTime, TotalCost,
                     RefundDate, RefundReason, is_wish_express, is_fbw,
                     str(ShippingDetail), OrderId))

                log_param['OrderFlag'] = 'OrderUpdate'
            else:
                sql_insert = "INSERT INTO t_order(PlatformName,ShopName,OrderDate,OrderId,OrderState,SKU,ShopSKU," \
                             "ProductID,Quantity,Price,Shipping,Shippedon,LastUpdated,UpdateTime,Image,Title," \
                             "TotalCost,RefundDate,RefundReason,WishExpress,FBWStatus,BuyerInfor) VALUES " \
                             "(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s); "
                cursor.execute(
                    sql_insert,
                    (PlatformName, ShopName, OrderDate, OrderId, OrderState,
                     SKU, ShopSKU, ProductID, Quantity, Price, Shipping,
                     Shippedon, LastUpdated, UpdateTime, ImageURL, Title,
                     TotalCost, RefundDate, RefundReason, is_wish_express,
                     is_fbw, str(ShippingDetail)))

                log_param['OrderFlag'] = 'OrderInsert'
            t_chart_wish_refund_log_obj.insert_data_log(log_param)

            for fine_id in fine_ids:
                param_data = {
                    'access_token': self.access_token,
                    'fine_id': fine_id
                }
                fine_infor_result = cwishapi().fine_info(param_data)
                if fine_infor_result['errorcode'] == 1:
                    fine_infor_result['fine_info']['order_id'] = OrderId
                    order_fine_insert_result = order_fine(self.cnxn).insert(
                        fine_infor_result['fine_info'])

        # 整理order信息
        redreshdict['ProductID'] = productlist
        #self.cnxn.commit()
        # cursor.execute("commit;")
        cursor.close()

        return redreshdict