| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\command\test\ln;
- use app\common\repositories\user\UserRepository;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\facade\Db;
- class ImportStore extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('import_store')->setDescription('导入一壶茶商城148');
- }
- protected function execute(Input $input, Output $output)
- {
- $mer_info = Db::connect('chuxubao')->query("select * from rrx_merchant where mer_id = 148")[0] ?? [];
- //查询产品信息
- $store_product_list = Db::connect('chuxubao')->query('select * from rrx_store_product where mer_id = 148');
- foreach ($store_product_list as $store_product) {
- $product_info = Db::name('store_product')->where('mer_id', $store_product['mer_id'])->where('store_name', $store_product['store_name'])->find();
- if (empty($product_info)) {
- unset($product_info['product_id']);
- Db::name('store_product')->insert($product_info);
- }
- $attr_list = Db::connect('chuxubao')->query("select * from rrx_store_product_attr where product_id = {$store_product['product_id']}");
- foreach ($attr_list as $attr) {
- $temp = Db::name('store_product_attr')->where('product_id', $attr['product_id'])->where('attr_name', $attr['attr_name'])->find();
- if (empty($temp)) {
- $product_attr_id = Db::name('store_product_attr')->insert($attr);
- }
- }
- $attr_sort_list = Db::connect('chuxubao')->query("select * from rrx_store_product_attr_sort where product_id = {$store_product['product_id']}");
- foreach ($attr_sort_list as $attr_sort) {
- $temp = Db::name('store_product_attr')->where('product_id', $attr_sort['product_id'])->where('attr_id', $attr_sort['attr_id'])->find();
- if (empty($temp)) {
- $product_attr_sort_id = Db::name('store_product_attr_sort')->insert($attr_sort);
- }
- }
- $attr_value_list = Db::connect('chuxubao')->query("select * from rrx_store_product_attr_value where product_id = {$store_product['product_id']}");
- foreach ($attr_value_list as $attr_value) {
- var_dump($attr_value);
- $temp = Db::name('store_product_attr_value')->where('product_id', $attr_value['product_id'])->where('unique', $attr_value['unique'])->find();
- if (empty($temp)) {
- $attr_value_id = Db::name('store_product_attr_value')->insert($attr_value);
- }
- }
- $product_cate_list = Db::connect('chuxubao')->query("select * from rrx_store_product_cate where product_id = {$store_product['product_id']}");
- foreach ($product_cate_list as $product_cate) {
- var_dump($product_cate);
- $temp = Db::name('store_product_cate')->where('product_id', $product_cate['product_id'])->where('mer_cate_id', $product_cate['mer_cate_id'])->find();
- if (empty($temp)) {
- $attr_value_id = Db::name('store_product_cate')->insert($product_cate);
- }
- }
- }
- }
- }
|