Tools: each randomly generated actual sales stock store a stock of goods and merchandise stores the corresponding 2 sku


#
Coding: UTF. 8- # @filename:. 2 each randomly generated actual sales inventory stock of merchandise and stores a corresponding commodity shop 2 sku.py # @createTime: 2020/4/4 10:33 # @author: hongjingsheng # @email: [email protected] # @software: PyCharm # Please start writing a script from the next line from testcase.goodsAPI.goodsSave.createData.create_one_goods_of_have_twoSku import Create_one_goods_of_have_twoSku from testcase.goodsStockAPI.realStockSet.createData.set_real_stock_of_have_twoSku import Set_real_stock_of_have_twosSku from testcase.itemAPI.itemSalesStockUpdate.createData.set_sales_stock_of_have_twoSku import Set_sales_stock_of_have_twoSku from config.config import relationshipOfShopAndWarehouses from model.m_kd_goods import M_kd_goods from model.m_kd_item import M_kd_item from model.m_kd_item_sku import M_kd_item_sku m_kd_goods = M_kd_goods() m_kd_item = M_kd_item() m_kd_item_sku = M_kd_item_sku() class run: ''' 1. The tools implement the functions: generating randomly each time sales stock actual stock of goods and stores a corresponding commodity shop 2 SKU; 2. Generate a Data: orders, associated with the coupon, to fight groups / spike / Save full send activities; ''' def __init__(self,goods_lib_id:int,whatGroupOfDataDoYouChoose:str): ''' : Param goods_lib_id Definition: Commodity library id; data type: int : Param whatGroupOfDataDoYouChoose Definition: warehouse stores the user to select which group relations ''' self.goods_lib_id = goods_lib_id self.whatGroupOfDataDoYouChoose = whatGroupOfDataDoYouChoose self.oneRelationshipOfShopAndWarehouse = self.__oneRelationshipOfShopAndWarehouse() self.sys_item_id = self.__get_one_sys_item_id() self.two_sysSkuIds_skuIds = self.__get_two_sysSkuIds_skuIds() self.sys_sku_id_of_sku_a = self.two_sysSkuIds_skuIds [ ' first sku-a commodity information of commodities A ' ] [ " sys_sku_id " ] self.sku_id_of_sku_a = self.two_sysSkuIds_skuIds [ ' first sku-a commodity information of commodities A ' ] [ " sku_id " ] self.sys_sku_id_of_sku_b = self.two_sysSkuIds_skuIds [ ' second product sku-b of the information of commodities A ' ] [ " sys_sku_id " ] self.sku_id_of_sku_b = self.two_sysSkuIds_skuIds [ ' second product sku-b of the information of commodities A ' ] [ " sku_id " ] self.out_item_id= self.realStockSet_of_DigitalStoreA() self.realStockSet_of_OfflineStoreB() self.realStockSet_of_OfflineStoreC() self.set_sales_stock_of_have_twoSku() self.log() def __oneRelationshipOfShopAndWarehouse(self): ''' : Return returns a set of data associated with the store warehouse; is int '' ' IF self.whatGroupOfDataDoYouChoose == " first set of data associated with store warehouse " : return relationshipOfShopAndWarehouses [ " first set of data associated with store warehouse " ] elif self.whatGroupOfDataDoYouChoose == " a second group of associated store data warehouse " : return relationshipOfShopAndWarehouses [ " The second group of associated store data warehouse " ] elif self.whatGroupOfDataDoYouChoose == " third set of associated data warehouse stores " : return relationshipOfShopAndWarehouses [ "The third set of linked data warehouse stores "] The else : The raise Exception ( " whatGroupOfDataDoYouChoose the value of the input parameter error; the user can enter only one of the three values: a first set of associated data warehouse store, the second set of associated data warehouse stores, warehouse stores a third set of associated data " ) def __get_one_sys_item_id(self): ''' : Return of a return value sys_item_id new product; is int ''' create_one_goods_of_have_twoSku = Create_one_goods_of_have_twoSku() create_one_goods_of_have_twoSku.goodsLibId = self.goods_lib_id r = create_one_goods_of_have_twoSku.sendRequest() sys_item_id = r["result"]["sysItemId"] return sys_item_id def __get_two_sysSkuIds_skuIds(self): ''' : Return to return a commodity product sku, two sku_id sys_sku_id and other information; data type dict ''' r = m_kd_goods.mysql_getRows_new("select sys_item_id,sys_sku_id,sku_id from kd_goods_sku where sys_item_id = %s"%self.sys_item_id) Result = { " first sku-a commodity information of the commodity A " : { " sys_item_id " : R & lt [0] [0], " sys_sku_id " : R & lt [0] [. 1], " sku_id " : R & lt [0 ] [2 ]}, " second sku-b commodity information of the commodity a " : { " sys_item_id " : R & lt [. 1] [0], " sys_sku_id " : R & lt [. 1] [. 1], " sku_id " : R & lt [. 1] [2 ]} } print(result) return result def realStockSet_of_DigitalStoreA(self): ''' : Out_item_id return value Returns A store merchandise in a store 1. The interface is mainly achieved: A warehouse configuration set up shop merchandise physical inventory ''' set_real_stock_of_have_twosSku = Set_real_stock_of_have_twosSku() set_real_stock_of_have_twosSku.goodsLibId = self.goods_lib_id set_real_stock_of_have_twosSku.realStockA = 100 set_real_stock_of_have_twosSku.sysSkuIdA = self.sys_sku_id_of_sku_a set_real_stock_of_have_twosSku.realStockB = 100 set_real_stock_of_have_twosSku.sysSkuIdB = self.sys_sku_id_of_sku_b set_real_stock_of_have_twosSku.sysItemId = self.sys_item_id set_real_stock_of_have_twosSku.warehouseId = self.oneRelationshipOfShopAndWarehouse [ " Digital store A " ] [ " binding repository ID " ] R & lt = set_real_stock_of_have_twosSku.sendRequest () Print (R & lt) # When the interface above request succeeds, stores A will generate a number of product A in kd_item table data store can obtain the value of the field out_item_id out_item_id = m_kd_item.get_one_random_value_of_one_tableField ( " out_item_id " , [[ " sys_item_id " , self.sys_item_id], [ " digit_shop_id " , self.oneRelationshipOfShopAndWarehouse [ " digital store A " ] [ " shop ID " ]]]) return out_item_id def realStockSet_of_OfflineStoreB(self): ''' :return None 1. Main Interface Function: Set the actual stock of goods at a shop line process cartridge B ''' set_real_stock_of_have_twosSku = Set_real_stock_of_have_twosSku() set_real_stock_of_have_twosSku.goodsLibId = self.goods_lib_id set_real_stock_of_have_twosSku.realStockA = 200 set_real_stock_of_have_twosSku.sysSkuIdA = self.sys_sku_id_of_sku_a set_real_stock_of_have_twosSku.realStockB = 200 set_real_stock_of_have_twosSku.sysSkuIdB = self.sys_sku_id_of_sku_b set_real_stock_of_have_twosSku.sysItemId = self.sys_item_id set_real_stock_of_have_twosSku.warehouseId = self.oneRelationshipOfShopAndWarehouse [ " offline store B " ] [ " binding repository ID " ] set_real_stock_of_have_twosSku.sendRequest()
def realStockSet_of_OfflineStoreC(self): ''' :return None 1. Main Interface Function: Set the actual stock of goods at the store of a wire magazine C ''' set_real_stock_of_have_twosSku = Set_real_stock_of_have_twosSku() set_real_stock_of_have_twosSku.goodsLibId = self.goods_lib_id set_real_stock_of_have_twosSku.realStockA = 300 set_real_stock_of_have_twosSku.sysSkuIdA = self.sys_sku_id_of_sku_a set_real_stock_of_have_twosSku.realStockB = 300 set_real_stock_of_have_twosSku.sysSkuIdB = self.sys_sku_id_of_sku_b set_real_stock_of_have_twosSku.sysItemId = self.sys_item_id set_real_stock_of_have_twosSku.warehouseId = self.oneRelationshipOfShopAndWarehouse [ " offline store C " ] [ " binding repository ID " ] set_real_stock_of_have_twosSku.sendRequest() def set_sales_stock_of_have_twoSku(self): ''' :return None 1. Interface Main Function: Set shop merchandise and two shops selling goods sku's largest inventory ''' set_sales_stock_of_have_twoSku = Set_sales_stock_of_have_twoSku() set_sales_stock_of_have_twoSku.goodsLibId = self.goods_lib_id set_sales_stock_of_have_twoSku.salesStock_of_skuA = 600 set_sales_stock_of_have_twoSku.skuIdA = self.sku_id_of_sku_a set_sales_stock_of_have_twoSku.salesStock_of_skuB = 600 set_sales_stock_of_have_twoSku.skuIdB = self.sku_id_of_sku_b set_sales_stock_of_have_twoSku.outItemId = self.out_item_id set_sales_stock_of_have_twoSku.salesStock_of_good = 1200 set_sales_stock_of_have_twoSku.shopId = self.oneRelationshipOfShopAndWarehouse["数字门店A"]["门店id"] set_sales_stock_of_have_twoSku.sendRequest() def log(self): ''' :return None 1. The interface is mainly achieved: output-related log '' ' Print ( " 1. Generate a commodity A sys_item_id value:% s; ---> values can be found in table kd_goods; " % self.sys_item_id) Print ( " 2. A generated a product of two sys_sku_id sku_id information and the goods sku:% s; ---> values can be found in table kd_goods_sku; " % self.two_sysSkuIds_skuIds) Print ( " out_item_id store to generate a digital value 3. a store a commodity a commodity a is:% s; ---> values can be found in table kd_item; " % self.out_item_id) r1 = m_kd_item.get_one_random_value_of_one_tableField("sales_stock",[["sys_item_id",self.sys_item_id],["out_item_id",self.out_item_id],["digit_shop_id",self.oneRelationshipOfShopAndWarehouse["数字门店A"]["门店id"]],["goods_lib_id",self.goods_lib_id]]) r2 = m_kd_item_sku.get_one_random_value_of_one_tableField("sales_stock",[["out_item_id",self.out_item_id],["digit_shop_id",self.oneRelationshipOfShopAndWarehouse["数字门店A"]["门店id"]],["goods_lib_id",self.goods_lib_id],["sku_id",self.sku_id_of_sku_a]]) R3 = m_kd_item_sku.get_one_random_value_of_one_tableField ( " sales_stock " , [[ " out_item_id " , self.out_item_id], [ " digit_shop_id " , self.oneRelationshipOfShopAndWarehouse [ " Digital store A " ] [ " shop ID " ]], [ " goods_lib_id " , Self .goods_lib_id], [ " sku_id " , self.sku_id_of_sku_b]]) Print ( " 4. a generates a maximum sales shop merchandise inventory value is:% s ---> values can be found in table kd_item; "%r1) print(" The generation of a commodity A store product sku-a shop selling stock maximum value is:% s ---> values can be found in table kd_item_sku; " % R2) Print ( " 6. The shop generates a commodity A a shop sold product sku-b Stock maximum value is:% s ---> values can be found in the list kd_item_sku; " % R3) Print ( " 7. the product generated in this shop and the shop a product sku-a & sku-b according to stores the digital / line store / warehouse information like:% S " % self.oneRelationshipOfShopAndWarehouse) if __name__ == "__main__": R & lt = RUN (100009, " the first set of data associated with store warehouse " )

 

 

2. The relevant debugging results (debugging through; the relevant database table information is stored correctly;)


3. Note
Examples of (1) attribute type, class, class inheritance, class method / property overrides, be familiar with the theory and the like;
(2) class is instantiated, the properties and the initialization parameters are automatically allocate physical memory;

Guess you like

Origin www.cnblogs.com/xiamen-momo/p/12636685.html