This commit is contained in:
2025-10-29 15:32:26 +08:00
parent d90614805b
commit b7462657cd
78921 changed files with 2753938 additions and 71 deletions

View File

@@ -0,0 +1,10 @@
<?php
namespace app\model\rrmodel;
use think\Model;
use think\facade\Db;
class EweiShopCategory extends Model
{
protected $connection = 'rrdata';
}

View File

@@ -0,0 +1,186 @@
<?php
namespace app\model\rrmodel;
use think\Model;
use think\facade\Db;
use app\model\goods\Goods;
use app\model\rrmodel\EweiShopCategory as EweiShopCategory;
use think\facade\Cache;
use app\model\system\Cron;
class EweiShopGoods extends Model
{
protected $connection = 'rrdata';
//同步获取商品详情
public function goodsContent($list,$data){
// $list = Db::connect('rrdata')->name('ewei_shop_goods')->where(['uniacid'=>$data['uniacid'],'deleted'=>0])->select()->toArray();
if($list['list']){
foreach($list['list'] as $val){
$goods = Db::connect('rrdata')->name('ewei_shop_goods')->field('id,content,uniacid')->where(['uniacid'=>$val['site_id'],'id'=>$val['goods_id']])->find();
//空详情跳过
if(empty($goods['content'])){
continue;
}
$content = $this->html_to_images($goods['content']);
$data['goods_content'] = $content;
$up_data = [
'goods_content'=>$content
];
model('goods')->update($up_data,['site_id'=>$val['site_id'],'goods_id'=>$val['goods_id']]);
}
$page = $data['page']+1;
echo $val['site_id'].'---'.$page.'<br/>';
// model('syngoods')->update(['page'=>intval($page)],['id'=>$data['id']]);
}else{
echo '空';
// model('syngoods')->update(['status'=>1],['id'=>$data['id']]);
}
}
public function getList($uniacid){
$goods_class = new Goods();
$list = Db::connect('rrdata')->name('ewei_shop_goods')->where(['uniacid'=>$uniacid,'deleted'=>0])->select()->toArray();
$goods_list = [];
$key = 'goods_'.$uniacid;
// $redis = Cache::store('redis')->handler();
$i = 0;
foreach($list as $g){
$goods_info = model('goods')->getInfo(['goods_id'=>$g['id']]);
if($goods_info){
continue;
}
// echo $g['id'].'<br/>';
//商品图片合并
if($g['thumb_url']){
$piclist = array_merge( array($g['thumb']), unserialize($g['thumb_url']) );
$goods_image = $this->geturl($piclist);
}else{
$goods_image = array($g['thumb']);
}
//组装数据通过接口导入
$goods = array (
'goods_id' => $g['id'],
'goods_name' => $g['title'],
'introduction' => $g['subtitle'],
'keywords' => $g['shorttitle'],
'goods_image' => implode(',',$goods_image),
'is_many_sku' => '0',//是否多规格0否1是
'goods_code' => $g['goodssn'],
'price' => $g['marketprice'],
'market_price' => $g['productprice'],
'cost_price' => $g['costprice'],
'stock' => $g['total'],
'stock_alarm' => '',
'weight' => $g['weight'],
'virtual_sale' => $g['sales'],
'volume' => '',
'unit' => '',
'is_free_shipping' => '1',
'template_name' => '',
'is_consume_discount' => '0',
'goods_state'=>1,
'sort'=>$g['displayorder'],
'merch_id'=>$g['merchid'],
'goods_state'=>$g['status'],
// 'category_1' => '鞋类',
// 'category_2' => '女鞋',
// 'category_3' => '板鞋',
);
//分类合并
$goods['category_id'] = 0;
$goods['category_json'] = [];
if($g['cates']){
$cate_ids = $this->cates(explode(',',$g['cates']));
$goods['category_id'] = implode(',',$cate_ids);
$goods['category_json'] = $cate_ids;
}
//推荐或者新品
if($g['isrecommand'] || $g['isnew']){
if($g['isrecommand']) $goods['recommend_way'] = 3;
if($g['isnew']) $goods['recommend_way'] = 1;
}
//拨打电话的商品
if($g['mobile']){
$goods['isinformation'] = 1;
$goods['goods_mobile'] = $g['mobile'];
}
if($g['content']){//容易死机
// $content = $this->html_to_images($g['content']);
// $goods['goods_content'] = $content;
}
// $goods_list[] = $goods;
// $redis->rPush($key, serialize($goods));
$res = $goods_class->importGoods($goods, $uniacid);
$i++;
// dump($res);
}
// $cron_model = new Cron();
// $res = $cron_model->addCron(1, 0, '商品数据redis', 'Syntest', (time()+60), $uniacid);
echo '同步商品数量:'.$i.'个.<br/>';
// dump($goods_list);
}
//商品详情图片兑换
public function html_to_images($detail = '') {
$detail = htmlspecialchars_decode($detail);
preg_match_all("/<img.*?src=[\\\'| \\\"](.*?(?:[\.gif|\.jpg|\.png|\.jpeg]?))[\\\'|\\\"].*?[\/]?>/", $detail, $imgs);
$images = array();
if (isset($imgs[1])) {
foreach ($imgs[1] as $img) {
$im = array(
"old" => $img,
"new" => $this->geturl($img),
);
$images[] = $im;
}
}
foreach ($images as $img) {
$detail = str_replace($img['old'], $img['new'], $detail);
}
return $detail;
}
public function cates($cates){
$category_id = [];
$EweiShopCategory = new EweiShopCategory();
foreach($cates as $c){
$cate = Db::connect('rrdata')->name('ewei_shop_category')->where(['id'=>$c])->find();
if($cate){
if($cate['level'] == 3){//三级分类获得一二三级分类id
$two = $EweiShopCategory->where(['id'=>$cate['parentid']])->find();
$one = $EweiShopCategory->where(['id'=>$two['parentid']])->find();
$category_id[] = $one['id'];//一级
$category_id[] = $two['id'];//二级
$category_id[] = $cate['id'];//三级
}if($cate['level'] == 2){//二级分类获得一二级分类id
$one = $EweiShopCategory->where(['id'=>$cate['parentid']])->find();
$category_id[] = $one['id'];//一级
$category_id[] = $cate['id'];//二级
}else{//一级分类
$category_id[] = $cate['id'];//一级
}
}
}
return $category_id;
}
//获取图片链接
public function geturl($url){
if(is_array($url)){
foreach($url as &$r){
$r = 'attachment/'.$r;
//$r = 'https://xcx8.5g-quickapp.com/attachment/'.$r;
}
return $url;
}else{
return 'attachment/'.$url;
// return 'https://xcx8.5g-quickapp.com/attachment/'.$url;
}
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace app\model\rrmodel;
use think\Model;
use think\facade\Db;
class EweiShopWxappPage extends Model
{
protected $connection = 'rrdata';
}

View File

@@ -0,0 +1,35 @@
<?php
/**
*/
namespace app\model\rrmodel;
use addon\memberregister\model\Register as RegisterModel;
use app\model\BaseModel;
use app\model\message\Sms;
use app\model\system\Stat;
use app\model\upload\Upload;
use app\model\system\Address;
use think\facade\Cache;
use think\facade\Db;
use addon\wechat\model\Fans;
use think\facade\Config;
/**
* 会员管理
*/
class Lshop extends BaseModel
{
public function test(){
return model('member')->getInfo(['site_id'=>1]);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
<?php
namespace app\model\rrmodel;
use think\Model;
use think\facade\Db;
use app\model\goods\goods;
use app\model\rrmodel\EweiShopCategory as EweiShopCategory;
//公众号表
class UniAccount extends Model
{
protected $connection = 'rrdata';
}

View File

@@ -0,0 +1,14 @@
<?php
namespace app\model\rrmodel;
use think\Model;
use think\facade\Db;
use app\model\goods\goods;
use app\model\rrmodel\EweiShopCategory as EweiShopCategory;
//用户表
class Users extends Model
{
protected $connection = 'rrdata';
}