This commit is contained in:
mkm 2025-04-24 18:36:14 +08:00
parent 13a575ca0c
commit 7e11bf3bb2

View File

@ -61,14 +61,100 @@ class IndexController extends BaseApiController
public function index()
{
$arr= Db::name('ceshi_copy_copy')->select();
foreach ($arr as $k => $v) {
$find=Db::name('ceshi_copy')->where('product_id',$v['product_id'])->find();
if($find){
Db::name('ceshi_copy_copy')->where('id',$v['id'])->update(['price_two'=>bcadd($v['price'],bcmul($v['price'], $find['purchase'], 2),2),'purchase'=>bcadd($v['price'],bcmul($v['price'], $find['price'], 2),2)]);
}
$arr=Db::connect('demo')->name('sheet1')->where('name','<>','')->limit(2)->select();
foreach ($arr as $k => $v) {
$find= Db::connect('demo')->name('store_product_unit')->where('value',$v['unit_name'])->find();
if(!$find){
$aa=['mer_id'=>7,'type'=>1,'value'=>$v['unit_name'],'status'=>1];
$id=Db::connect('demo')->name('store_product_unit')->insertGetId($aa);
}
$data=[
'mer_id'=>7,
'store_name'=>$v['name'],
'store_info'=>$v['name_tow'],
'cate_id'=>0,
'unit_name'=>$v['unit_name'],
'price'=>$v['price'],
'cost'=>$v['cost'],
'ot_price'=>0,
'image'=>$v['image'],
'slider_image'=>$v['image'],
'mer_svip_status'=>1,
'svip_price_type'=>2,
'svip_price'=>$v['cost'],
];
$product_id=Db::connect('demo')->name('store_product')->insertGetId($data);
$data2=[
'mer_id'=>7,
'product_id'=>$product_id,
'store_name'=>$v['name'],
'ot_price'=>0,
'image'=>$v['image'],
];
Db::connect('demo')->name('store_spu')->insert($data2);
$sku='';
$unique=substr(md5($sku . $product_id), 12, 10) . 0;
$data4=[
'product_id'=>$product_id,
'detail'=>'""',
'image'=>$v['image'],
'price'=>$v['price'],
'unique'=>$unique,
'svip_price'=>$v['cost'],
];
$vid=Db::connect('demo')->name('store_product_attr_value')->insertGetId($data4);
$json=[
'attr'=>[],
'attrValue'=>[
'value_id'=>$vid,
'product_id'=>$product_id,
'detail'=>'',
'sku'=>'',
'stock'=>0,
'brand_id'=>0,
'sales'>0,
'image'=>$v['image'],
'bar_code'=>'',
'cost'=>0,
'ot_price'=>0,
'price'=>$v['price'],
'svip_price'=>$v['cost'],
'weight'=>0,
'volume'=>0,
'type'=>0,
'extension_one'=>0,
'extension_two'=>0,
'unique'=>$unique,
'library_id'=>0,
'bar_code_number'=>'',
'is_default_select'=>0,
'is_show'=>1,
'productCdkey'=>[],
'select'=>1,
'list'=>[]
],
'params'=>[]
];
$data3=[
'product_id'=>$product_id,
'change_time'=>time(),
'result'=>json_encode($json),
];
Db::connect('demo')->name('store_product_attr_result')->insert($data3);
$data5=[
'product_id'=>$product_id,
'content'=>'',
'type'=>0,
];
Db::connect('demo')->name('store_product_content')->insert($data5);
}
d($arr);
d(1);
$arr = Db::name('ceshi_copy')->select();
foreach ($arr as $k => $v) {