Merge pull request 'dev' (#86) from dev into master

Reviewed-on: #86
This commit is contained in:
mkm 2023-12-02 13:05:33 +08:00
commit 606120da33
12 changed files with 423 additions and 218 deletions

View File

@ -2501,234 +2501,219 @@ class StoreOrderRepository extends BaseRepository
* @throws DbException
* @throws ModelNotFoundException
*/
public function setProduct(array $arrary, $merId,$type_id=0)
public function setProduct($datum, $merId, $product_type)
{
//读取excel
$data = SpreadsheetExcelService::instance()->_import($arrary['path'], $arrary['sql'], $arrary['where'], 1);
if (!$data) return false;
unset($data[0]);
$product_type = 0;
if ($type_id == 12) {
$product_type = 98; //供应链
}
try {
foreach ($data as $datum) {
$find = Db::name('store_product')->where('mer_id', $merId)->where('store_name', $datum['value']['store_name'])->find();
$attr_one = explode('|', $datum['value']['attr_one']);
$attr_two = explode('|', $datum['value']['attr_two']);
$attr = [];
$arr = [];
$find = Db::name('store_product')->where('mer_id', $merId)->where('store_name', $datum['value']['store_name'])->find();
$attr_one = explode('|', $datum['value']['attr_one']);
$attr_two = explode('|', $datum['value']['attr_two']);
$attr = [];
$arr = [];
foreach ($attr_one as $key => $value) {
$attr[$value] = $attr_two[$key];
$arr[] = [
'value' => $value,
'detail' => [$attr_two[$key] ?? []],
'inputVisible' => false
];
}
$array_values = array_values($attr);
$attr_implode= implode(',', $array_values);
if ($find) {
$store_product_attr_value_where['product_id']=$find['product_id'];
if($datum['value']['bar_code']!=''){
$store_product_attr_value_where['bar_code']=$datum['value']['bar_code'];
}else{
$store_product_attr_value_where['sku']=$attr_implode;
}
$is_update = false;
$store_product_attr_value = Db::name('store_product_attr_value')->where($store_product_attr_value_where)->find();
if ($store_product_attr_value) {
$datas['product_id'] = $find['product_id'];
$datas['mer_id'] = $merId;
$datas['store_name'] = $datum['value']['store_name'];
$datas['content'] = 'xls导入商品:已经导入过该规格了';
$this->create_product_import_log($datas,0);
continue;
}
foreach ($attr as $kk => $vv) {
/**查询当前规格属性是否存在 */
$attr_values_find = Db::name('store_product_attr')->where('product_id', $find['product_id'])->where('attr_name', $kk)
->find();
if ($attr_values_find) {
$attr_values = $attr_values_find['attr_values'];
$attr_values = explode('-!-', $attr_values);
if (!in_array($vv, $attr_values)) {
$attr_values[] = $vv;
$attr_values = implode('-!-', $attr_values);
//更新规格属性
Db::name('store_product_attr')->where('product_id', $find['product_id'])->where('attr_name', $kk)->update(['attr_values' => $attr_values]);
}
} else {
$datas = [
'product_id' => $find['product_id'],
'attr_name' => $kk, 'attr_values' => $vv,
];
Db::name('store_product_attr')->insert($datas);
}
}
if ($is_update == false) {
$this->create_product_attr_value($find, $datum, $product_type, $attr, $merId, $attr_implode);
}
foreach ($attr_one as $key => $value) {
$attr[$value] = $attr_two[$key];
$arr[] = [
'value' => $value,
'detail' => [$attr_two[$key] ?? []],
'inputVisible' => false
];
}
$array_values = array_values($attr);
$attr_implode = implode(',', $array_values);
if ($find) {
$store_product_attr_value_where['product_id'] = $find['product_id'];
if ($datum['value']['bar_code'] != '') {
$store_product_attr_value_where['bar_code'] = $datum['value']['bar_code'];
} else {
//默认其他分类
$cate_id = 1726;
$spec_type = 1;
$detail = $attr;
/**查询平台分类 */
$cate_id_one = Db::name('store_category')->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_one'])->value('store_category_id');
if ($cate_id_one) {
$cate_id_two = Db::name('store_category')->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_two'])->value('store_category_id');
if ($cate_id_two) {
$cate_id = $cate_id_two;
$store_product_attr_value_where['sku'] = $attr_implode;
}
$is_update = false;
$store_product_attr_value = Db::name('store_product_attr_value')->where($store_product_attr_value_where)->find();
if ($store_product_attr_value) {
$datas['product_id'] = $find['product_id'];
$datas['mer_id'] = $merId;
$datas['store_name'] = $datum['value']['store_name'];
$datas['content'] = 'xls导入商品:已经导入过该规格了';
$this->create_product_import_log($datas, 0);
return false;
}
foreach ($attr as $kk => $vv) {
/**查询当前规格属性是否存在 */
$attr_values_find = Db::name('store_product_attr')->where('product_id', $find['product_id'])->where('attr_name', $kk)
->find();
if ($attr_values_find) {
$attr_values = $attr_values_find['attr_values'];
$attr_values = explode('-!-', $attr_values);
if (!in_array($vv, $attr_values)) {
$attr_values[] = $vv;
$attr_values = implode('-!-', $attr_values);
//更新规格属性
Db::name('store_product_attr')->where('product_id', $find['product_id'])->where('attr_name', $kk)->update(['attr_values' => $attr_values]);
}
} else {
$datas = [
'product_id' => $find['product_id'],
'attr_name' => $kk, 'attr_values' => $vv,
];
Db::name('store_product_attr')->insert($datas);
}
/**查询商户分类 */
$mer_cate_id = 0;
if ($datum['value']['cate_id_one_mer'] != '' && $datum['value']['cate_id_one_two'] != '') {
$cate_id_one_mer = Db::name('store_category')->where('level', 0)->where('mer_id', $merId)->where('cate_name', $datum['value']['cate_id_one_mer'])->value('store_category_id');
/**有一级分类 */
if ($cate_id_one_mer) {
$cate_id_one_two = Db::name('store_category')->where('pid', $cate_id_one_mer)->where('level', 1)->where('mer_id', $merId)->where('cate_name', $datum['value']['cate_id_one_two'])->value('store_category_id');
/**有二级分类 */
if ($cate_id_one_two) {
$mer_cate_id = $cate_id_one_two;
} else {
$mer_cate = ['level' => 1, 'pid' => $cate_id_one_mer, 'cate_name' => $datum['value']['cate_id_one_mer'], 'path' => '/' . $cate_id_one_mer . '/', 'mer_id' => $merId, 'sort' => 0, 'is_show' => 1, 'create_time' => date('Y-m-d H:i:s')];
$mer_cate_id = Db::name('store_category')->insertGetId($mer_cate);
}
}
if ($is_update == false) {
$this->create_product_attr_value($find, $datum, $product_type, $attr, $merId, $attr_implode);
}
} else {
//默认其他分类
$cate_id = 1726;
$spec_type = 1;
$detail = $attr;
/**查询平台分类 */
$cate_id_one = Db::name('store_category')->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_one'])->value('store_category_id');
if ($cate_id_one) {
$cate_id_two = Db::name('store_category')->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_two'])->value('store_category_id');
if ($cate_id_two) {
$cate_id = $cate_id_two;
}
}
/**查询商户分类 */
$mer_cate_id = 0;
if ($datum['value']['cate_id_one_mer'] != '' && $datum['value']['cate_id_one_two'] != '') {
$cate_id_one_mer = Db::name('store_category')->where('level', 0)->where('mer_id', $merId)->where('cate_name', $datum['value']['cate_id_one_mer'])->value('store_category_id');
/**有一级分类 */
if ($cate_id_one_mer) {
$cate_id_one_two = Db::name('store_category')->where('pid', $cate_id_one_mer)->where('level', 1)->where('mer_id', $merId)->where('cate_name', $datum['value']['cate_id_one_two'])->value('store_category_id');
/**有二级分类 */
if ($cate_id_one_two) {
$mer_cate_id = $cate_id_one_two;
} else {
$cate_id_one_mer_arr = ['pid' => 0, 'cate_name' => $datum['value']['cate_id_one_mer'], 'path' => '/', 'mer_id' => $merId, 'sort' => 0, 'is_show' => 1, 'create_time' => date('Y-m-d H:i:s')];
$cate_id_one_mer = Db::name('store_category')->insertGetId($cate_id_one_mer_arr);
$mer_cate = ['level' => 1, 'pid' => $cate_id_one_mer, 'cate_name' => $datum['value']['cate_id_one_mer'], 'path' => '/' . $cate_id_one_mer . '/', 'mer_id' => $merId, 'sort' => 0, 'is_show' => 1, 'create_time' => date('Y-m-d H:i:s')];
$mer_cate_id = Db::name('store_category')->insertGetId($mer_cate);
}
} else {
$cate_id_one_mer_arr = ['pid' => 0, 'cate_name' => $datum['value']['cate_id_one_mer'], 'path' => '/', 'mer_id' => $merId, 'sort' => 0, 'is_show' => 1, 'create_time' => date('Y-m-d H:i:s')];
$cate_id_one_mer = Db::name('store_category')->insertGetId($cate_id_one_mer_arr);
$mer_cate = ['level' => 1, 'pid' => $cate_id_one_mer, 'cate_name' => $datum['value']['cate_id_one_mer'], 'path' => '/' . $cate_id_one_mer . '/', 'mer_id' => $merId, 'sort' => 0, 'is_show' => 1, 'create_time' => date('Y-m-d H:i:s')];
$mer_cate_id = Db::name('store_category')->insertGetId($mer_cate);
}
$bar_code = (int) $datum['value']['bar_code'];
$bar_code_where = ['is_used' => 1, 'status' => 1, 'is_del' => 0];
$bar_code_field = 'id,store_name,bar_code,manu_address,price,stock,image,slider_image,spec,trademark,manu_name,manu_address,note';
$library = null;
if ($bar_code) {
}
$bar_code = (int) $datum['value']['bar_code'];
$bar_code_where = ['is_used' => 1, 'status' => 1, 'is_del' => 0];
$bar_code_field = 'id,store_name,bar_code,manu_address,price,stock,image,slider_image,spec,trademark,manu_name,manu_address,note';
$library = null;
if ($bar_code) {
$library = Db::name('product_library')->where('bar_code', $bar_code)->where($bar_code_where)->field($bar_code_field)
->withAttr('slider_image', function ($value, $data) {
return $value ? explode(',', $value) : [];
})
->find();
if (!$library) {
$ProductLibrary = app()->make(ProductLibrary::class);
$ProductLibrary->caiji($bar_code);
$library = Db::name('product_library')->where('bar_code', $bar_code)->where($bar_code_where)->field($bar_code_field)
->withAttr('slider_image', function ($value, $data) {
return $value ? explode(',', $value) : [];
})
->find();
if (!$library) {
$ProductLibrary = app()->make(ProductLibrary::class);
$ProductLibrary->caiji($bar_code);
$library = Db::name('product_library')->where('bar_code', $bar_code)->where($bar_code_where)->field($bar_code_field)
->withAttr('slider_image', function ($value, $data) {
return $value ? explode(',', $value) : [];
})
->find();
}
}
if ($library) {
$image = $library['image'];
$slider_image = $library['slider_image'];
} else {
$image = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png';
$slider_image = [
0 => "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png",
];
}
$procure_price=0;
if(!empty($datum['value']['procure_price'])){
$procure_price=$datum['value']['procure_price'];
}
$datas = [
"image" => $image,
"slider_image" => $slider_image,
"store_name" => $datum['value']['store_name'],
"store_info" => $datum['value']['store_name'],
"keyword" => '',
"bar_code" => $bar_code,
"guarantee_template_id" => "",
"cate_id" => $cate_id,
"mer_cate_id" => [
0 => $mer_cate_id
],
'product_type' => $product_type,
"unit_name" => $datum['value']['unit_name'],
"sort" => 0,
"is_show" => "",
"is_good" => 0,
"is_gift_bag" => 0,
"integral_rate" => -1,
"video_link" => "",
"temp_id" => "",
"content" => "",
"spec_type" => $spec_type,
"extension_type" => 0,
"attr" => $arr,
"mer_labels" => [],
"delivery_way" => [
0 => "2",
1 => "1"
],
"delivery_free" => 0,
"param_temp_id" => [],
"extend" => [],
"brand_id" => "",
"once_max_count" => 0,
"once_min_count" => 0,
"pay_limit" => 0,
"attrValue" => [
[
"image" => $image,
"price" => $datum['value']['price'],
"cost" => $datum['value']['cost'],
"ot_price" => $datum['value']['price'],
"svip_price" => null,
"procure_price" => $procure_price,
"stock" => 1,
"bar_code" => (int)$datum['value']['bar_code'],
"weight" => 0,
"volume" => 0,
"detail" => $detail,
],
],
"give_coupon_ids" => [],
"type" => 0,
"svip_price" => 0,
"svip_price_type" => 0,
"params" => [],
"mer_id" => $merId,
"status" => 1,
"mer_status" => 1,
"rate" => 3,
}
if ($library) {
$image = $library['image'];
$slider_image = $library['slider_image'];
} else {
$image = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png';
$slider_image = [
0 => "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png",
];
// $data_list = [
// 'data' => $datas,
// 'product_type' => $product_type,
// ];
$make = app()->make(ProductRepository::class);
$product_id = $make->create($datas, $product_type);
if ($product_id) {
$datas['product_id'] = $product_id;
$datas['mer_id'] = $merId;
$datas['store_name'] = $datum['value']['store_name'];
$this->create_product_import_log($datas);
}
// Queue::push(ProductImportJob::class, $data_list);
}
$procure_price = 0;
if (!empty($datum['value']['procure_price'])) {
$procure_price = $datum['value']['procure_price'];
}
$datas = [
"image" => $image,
"slider_image" => $slider_image,
"store_name" => $datum['value']['store_name'],
"store_info" => $datum['value']['store_name'],
"keyword" => '',
"bar_code" => $bar_code,
"guarantee_template_id" => "",
"cate_id" => $cate_id,
"mer_cate_id" => [
0 => $mer_cate_id
],
'product_type' => $product_type,
"unit_name" => $datum['value']['unit_name'],
"sort" => 0,
"is_show" => "",
"is_good" => 0,
"is_gift_bag" => 0,
"integral_rate" => -1,
"video_link" => "",
"temp_id" => "",
"content" => "",
"spec_type" => $spec_type,
"extension_type" => 0,
"attr" => $arr,
"mer_labels" => [],
"delivery_way" => [
0 => "2",
1 => "1"
],
"delivery_free" => 0,
"param_temp_id" => [],
"extend" => [],
"brand_id" => "",
"once_max_count" => 0,
"once_min_count" => 0,
"pay_limit" => 0,
"attrValue" => [
[
"image" => $image,
"price" => $datum['value']['price'],
"cost" => $datum['value']['cost'],
"ot_price" => $datum['value']['price'],
"svip_price" => null,
"procure_price" => $procure_price,
"stock" => 1,
"bar_code" => (int)$datum['value']['bar_code'],
"weight" => 0,
"volume" => 0,
"detail" => $detail,
],
],
"give_coupon_ids" => [],
"type" => 0,
"svip_price" => 0,
"svip_price_type" => 0,
"params" => [],
"mer_id" => $merId,
"status" => 1,
"mer_status" => 1,
"rate" => 3,
];
$make = app()->make(ProductRepository::class);
$product_id = $make->create($datas, $product_type);
if ($product_id) {
$datas['product_id'] = $product_id;
$datas['mer_id'] = $merId;
$datas['store_name'] = $datum['value']['store_name'];
$this->create_product_import_log($datas);
}
}
} catch (Exception $e) {
$datas['product_id'] = $product_id??0;
return true;
} catch (\Exception $e) {
$datas['product_id'] = $product_id ?? 0;
$datas['mer_id'] = $merId;
$datas['store_name'] = $datum['value']['store_name'];
$datas['content'] = $e->getMessage().'line:'.$e->getLine();
$datas['content'] = $e->getMessage() . 'line:' . $e->getLine();
$this->create_product_import_log($datas, 0);
}
return true;
}
public function create_product_import_log($data, $status = 1)
{
$data = [
'product_id' => $data['product_id']??0,
'product_id' => $data['product_id'] ?? 0,
'mer_id' => $data['mer_id'],
'name' => $data['store_name'],
'content' => $data['content'] ?? '',
@ -2740,9 +2725,9 @@ class StoreOrderRepository extends BaseRepository
public function create_product_attr_value($find, $datum, $product_type, $attr_values, $merId, $sku)
{
$procure_price=0;
if(!empty($datum['value']['procure_price'])){
$procure_price=$datum['value']['procure_price'];
$procure_price = 0;
if (!empty($datum['value']['procure_price'])) {
$procure_price = $datum['value']['procure_price'];
}
$attrValue['stock'] = 1;
$unique = app(ProductRepository::class)->setUnique($find['product_id'], $datum['value']['bar_code'], $product_type);

View File

@ -0,0 +1,154 @@
<?php
namespace app\controller\api\dataview;
use app\common\repositories\article\ArticleRepository as repository;
use crmeb\basic\BaseController;
use GuzzleHttp\Exception\ClientException;
use think\App;
use think\exception\ValidateException;
use think\facade\Db;
class Order extends BaseController
{
/**
* @var repository
*/
protected $repository;
public $areaCode; // 区县地区码
public $streetCode; // 镇街道地区码
/**
* StoreBrand constructor.
* @param App $app
* @param repository $repository
*/
public function __construct(App $app, repository $repository)
{
parent::__construct($app);
$this->repository = $repository;
$this->areaCode = $this->request->param('areaCode', '');
$this->streetCode = $this->request->param('streetCode', '');
if ($this->areaCode == '' && $this->streetCode == '') {
throw new ValidateException('请选择地区');
}
}
// 今日订单
public function currOrderInfo()
{
try {
$day = '2023-11-29'; // today
$currOrderCountQuery = Db::name('store_order')->alias('o')
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->leftJoin('merchant m', 'o.mer_id = m.mer_id')
->leftJoin('store_order_product op', 'o.order_id = op.order_id')
->leftJoin('product_library p', 'op.product_id = p.id')
->whereDay('og.create_time', $day)
->where('o.paid', 1)
->whereNotNull('o.pay_time');
// 待取货订单数统计query 订单待发货
$pendingPickupOrderCountQuery = Db::name('store_order')->alias('o')
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->whereDay('og.create_time', $day)
->where('o.status', 0)
->where('o.paid', 1)
->whereNotNull('o.pay_time');;
// 未配送订单数统计query 订单待收货
$undeliveredOrderCountQuery = Db::name('store_order')->alias('o')
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->whereDay('og.create_time', $day)
->where('o.status', 1)
->where('o.paid', 1)
->whereNotNull('o.pay_time');;
// 已完成订单数统计query 订单已完成
$doneOrderCountQuery = Db::name('store_order')->alias('o')
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->whereDay('og.create_time', $day)
->whereIn('o.status', [2,3])
->where('o.paid', 1)
->whereNotNull('o.pay_time');
if ($this->areaCode != '') {
$currOrderCountQuery->where('og.district_code', $this->areaCode);
$pendingPickupOrderCountQuery->where('og.district_code', $this->areaCode);
$undeliveredOrderCountQuery->where('og.district_code', $this->areaCode);
$doneOrderCountQuery->where('og.district_code', $this->areaCode);
}
if ($this->streetCode != '') {
$currOrderCountQuery->where('og.street_code', $this->streetCode);
$pendingPickupOrderCountQuery->where('og.street_code', $this->streetCode);
$undeliveredOrderCountQuery->where('og.street_code', $this->streetCode);
$doneOrderCountQuery->where('og.street_code', $this->streetCode);
}
// 今日订单数
$currOrderCount = $currOrderCountQuery->count();
[$page, $limit] = $this->getPage();
$client = new \GuzzleHttp\Client();
// 今日订单列表
$currOrderList = $currOrderCountQuery->page($page, $limit)->select()->toArray();
foreach ($currOrderList as $k => $order) {
$getUrl = env('LOGISTICS_HOST_URL') . '/api/courierData?order_sn=' . $order['order_sn'];
$response = $client->request('GET', $getUrl);
$courierData = json_decode($response->getBody(), true);
$currOrderList[$k]['courier'] = $courierData['data']['courier_name'];
}
// 待取货订单数
$pendingOrderCount = $pendingPickupOrderCountQuery->count();
// 未配送订单数
$undeliveredOrderCount = $undeliveredOrderCountQuery->count();
// 已完成订单数
$doneOrderCountQuery = $doneOrderCountQuery->count();
return app('json')->success(compact('currOrderCount', 'pendingOrderCount', 'undeliveredOrderCount', 'doneOrderCountQuery', 'currOrderList'));
} catch (ValidateException $e) {
throw new ValidateException($e->getMessage());
}
}
// 镇级订单数排行榜
public function orderRanking()
{
$type = $this->request->get('type',2); // 1今日 2总计
$townList = Db::name('geo_street')->field('street_code,street_name')->where('area_code', $this->areaCode)->select()->toArray(); // 镇/街道列表
foreach ($townList as &$town) {
// 查询订单数
$orderCountQuery = Db::name('product_order_log')->where('street_code', $town['street_code'])->where('status', 1);
if ($type == 1) {
$orderCountQuery->whereDay('create_time', 'today');
}
$orderCount = $orderCountQuery->count();
$town['order_count'] = $orderCount;
}
unset($town);
// $orderRankingQuery = Db::name('product_order_log')->alias('op')
// ->leftJoin('geo_street s','op.street_code = s.street_code')
// ->field('op.street_code,COUNT(op.order_id) AS order_count,s.street_name')
// ->where('op.district_code',$this->areaCode)
// ->where('op.status',1);
//
// if ($type == 1) {
// $orderCountQuery->whereDay('create_time', 'today');
// }
// $orderRankingList = $orderRankingQuery->group('op.street_code')->order('order_count desc')->select();
$orderCountArr = array_column($townList, 'order_count');
array_multisort($orderCountArr, SORT_DESC, $townList);
return app('json')->success($townList);
}
}

View File

@ -16,7 +16,7 @@ use app\common\repositories\store\order\StoreImportDeliveryRepository;
use app\common\repositories\store\order\StoreOrderRepository;
use crmeb\jobs\ImportSpreadsheetExcelJob;
use crmeb\jobs\ImportPicJob;
use crmeb\jobs\ImportProductJob;
use crmeb\jobs\ImportProductXlsJob;
use crmeb\services\ExcelService;
use crmeb\services\SpreadsheetExcelService;
use crmeb\services\UploadService;
@ -234,7 +234,7 @@ class StoreImport extends BaseController
]
];
// app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id'],$type_id);
Queue::push(ImportProductJob::class,['mer_id'=>$data['mer_id'],'data'=>$data['data'],'type_id'=>$type_id]);
Queue::push(ImportProductXlsJob::class,['mer_id'=>$data['mer_id'],'data'=>$data['data'],'type_id'=>$type_id]);
}else{
$check =[
@ -261,7 +261,7 @@ class StoreImport extends BaseController
'where' => ['store_name' => 'A'],
]
];
Queue::push(ImportProductJob::class,['mer_id'=>$data['mer_id'],'data'=>$data['data'],'type_id'=>$type_id]);
Queue::push(ImportProductXlsJob::class,['mer_id'=>$data['mer_id'],'data'=>$data['data'],'type_id'=>$type_id]);
// app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id'],$type_id);
}
}

View File

@ -42,7 +42,7 @@ class OrderTake
}
}
} catch (\Exception $e) {
Log::error($e->getMessage() . 'lien:' . $e->getLine());
Log::error('收货后的逻辑:'.$e->getMessage() . 'lien:' . $e->getLine());
}
}

View File

@ -14,7 +14,6 @@ class ProductCreate
public function handle($event)
{
Log::error(json_encode($event));
$product = $event['product'];
// $data = $event['data'];
// $contentType = $event['conType'];

View File

@ -53,7 +53,7 @@ class paySuccess
}
}
}catch(\Exception $e){
Log::error($e->getMessage().'lien:'.$e->getLine());
Log::error('支付后逻辑报错:'.$e->getMessage().'lien:'.$e->getLine());
}
}

View File

@ -13,7 +13,7 @@ class ImportPicJob implements JobInterface
{
public function fire($job, $data)
{
Log::error('开始导入商品图片:' . $job->attempts());
Log::info('开始导入商品图片:' . $job->attempts());
if ($job->attempts() > 3) {
$job->delete();
$this->failed($data);

View File

@ -10,12 +10,12 @@ class ImportProductJob implements JobInterface
{
public function fire($job, $data)
{
Log::error('开始导入商品:' . $job->attempts());
Log::info('开始导入商品:');
if ($job->attempts() > 1) {
$job->delete();
$this->failed($data);
}
app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id'],$data['type_id']);
app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id'],$data['product_type']);
$job->delete();
}

View File

@ -0,0 +1,64 @@
<?php
namespace crmeb\jobs;
use crmeb\interfaces\JobInterface;
use think\facade\Log;
use app\common\repositories\store\order\StoreOrderRepository;
use think\facade\Db;
use crmeb\services\SpreadsheetExcelService;
use think\facade\Queue;
class ImportProductXlsJob implements JobInterface
{
public function fire($job, $data)
{
Log::info('开始读取excel商品:' . $job->attempts());
if ($job->attempts() > 1) {
$job->delete();
$this->failed($data);
}
$arrary = $data['data'];
//读取excel
$excel_data = SpreadsheetExcelService::instance()->_import($arrary['path'], $arrary['sql'], $arrary['where'], 1);
if (!$excel_data) return false;
unset($excel_data[0]);
$product_type = 0;
if ($data['type_id'] == 12) {
$product_type = 98; //供应链
}
try {
foreach ($excel_data as $datum) {
Queue::push(ImportProductJob::class,['data'=>$datum,'mer_id'=>$data['mer_id'],'product_type'=>$product_type]);
// $StoreOrderRepository->setProduct();
}
} catch (\Exception $e) {
$job->delete();
$datas['product_id'] = $product_id ?? 0;
$datas['mer_id'] = $data['mer_id'];
$datas['store_name'] = $datum['value']['store_name'];
$datas['content'] = $e->getMessage() . 'line:' . $e->getLine();
$this->create_product_import_log($datas, 0);
}
}
public function failed($data)
{
Log::error('读取excel失败:' . json_encode($data));
// TODO: Implement failed() method.
}
public function create_product_import_log($data, $status = 1)
{
$data = [
'product_id' => $data['product_id'] ?? 0,
'mer_id' => $data['mer_id'],
'name' => $data['store_name'],
'content' => $data['content'] ?? '',
'status' => $status,
'create_time' => date('Y-m-d H:i:s'),
];
Db::name('store_product_import')->insert($data);
}
}

View File

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://mer.crmeb.net/static/images/cancellation-header.png

View File

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
HostUrl=about:internet

View File

@ -713,6 +713,14 @@ Route::group('api/', function () {
//滑块验证码
Route::get('ajcaptcha', 'api.Auth/ajcaptcha');
Route::post('ajcheck', 'api.Auth/ajcheck');
// dataview接口
Route::group('dataview', function () {
// Route::post('cancel/:id', '/cancelGroupOrder');
Route::get('curr_order_info', 'Order/currOrderInfo');
Route::get('order_ranking', 'Order/orderRanking');
})->prefix('api.dataview.');
})->middleware(AllowOriginMiddleware::class)
->middleware(InstallMiddleware::class)
->middleware(CheckSiteOpenMiddleware::class)
@ -730,3 +738,4 @@ Route::group('/open-location', function () {
Route::miss('View/h5');
})->middleware(InstallMiddleware::class)
->middleware(CheckSiteOpenMiddleware::class);