|
|
|
@ -24,6 +24,9 @@ use app\common\library\helper; |
|
|
|
|
use app\common\library\phpoffice\ReadExecl; |
|
|
|
|
use app\common\model\goods\Import as ImportModel; |
|
|
|
|
use cores\exception\BaseException; |
|
|
|
|
use app\common\model\Goods as GoodsModel; |
|
|
|
|
use app\common\model\GoodsSku as GoodsSkuModel; |
|
|
|
|
use app\store\model\GoodsCategoryRel as GoodsCategoryRelModel; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 商品批量导入记录模型 |
|
|
|
@ -165,7 +168,6 @@ class Import extends ImportModel |
|
|
|
|
$this->storeDispatchJob($execlData, $recordId); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 执行批量更新 |
|
|
|
|
* @param array $form |
|
|
|
@ -174,7 +176,7 @@ class Import extends ImportModel |
|
|
|
|
* @throws Exception |
|
|
|
|
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception |
|
|
|
|
*/ |
|
|
|
|
public function goodsUpdateBatch(array $form): bool |
|
|
|
|
public function goodsUpdateBatch (array $form): bool |
|
|
|
|
{ |
|
|
|
|
// 读取excel文件内容 |
|
|
|
|
$execlData = $this->readExecl(); |
|
|
|
@ -208,6 +210,53 @@ class Import extends ImportModel |
|
|
|
|
$this->goodsUpdateJob($execlData, $recordId); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 执行批量更新 |
|
|
|
|
* @param array $form |
|
|
|
|
* @return bool |
|
|
|
|
* @throws BaseException |
|
|
|
|
* @throws Exception |
|
|
|
|
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception |
|
|
|
|
*/ |
|
|
|
|
public function storeGoodsUpdateBatch(array $form): bool |
|
|
|
|
{ |
|
|
|
|
// 读取excel文件内容 |
|
|
|
|
$execlData = $this->readExecl(); |
|
|
|
|
|
|
|
|
|
// echo "<pre>"; |
|
|
|
|
// print_r($execlData); |
|
|
|
|
// exit(); |
|
|
|
|
// 验证导入的商品数量是否合法 |
|
|
|
|
$this->checkLimit($execlData); |
|
|
|
|
|
|
|
|
|
self::$storeId = $form['store_id'] ?? 0; |
|
|
|
|
foreach ($execlData as $key => $value) { |
|
|
|
|
$upData = [ |
|
|
|
|
'goods_name'=> $value['B'], |
|
|
|
|
'cmmdty_model'=> $value['C'], |
|
|
|
|
'goods_source'=> $value['D'], |
|
|
|
|
'goods_no'=> $value['E'], |
|
|
|
|
'delivery_time'=> $value['G'], |
|
|
|
|
'is_check'=> $value['H'], |
|
|
|
|
'delivery_id'=> $value['I'], |
|
|
|
|
'status'=> $value['J'], |
|
|
|
|
'cost_price_min'=> $value['K'], |
|
|
|
|
'goods_price_min'=> $value['L'], |
|
|
|
|
'goods_price_max'=> $value['L'], |
|
|
|
|
'line_price_min'=> $value['L'], |
|
|
|
|
'line_price_max'=> $value['L'], |
|
|
|
|
'stock_total'=> $value['M'], |
|
|
|
|
'remark'=> $value['N'], |
|
|
|
|
]; |
|
|
|
|
// echo "<pre>"; |
|
|
|
|
// print_r(explode(",", $value['F'])); |
|
|
|
|
// exit(); |
|
|
|
|
GoodsModel::where('goods_id', $value['A'])->update($upData); |
|
|
|
|
GoodsSkuModel::where('goods_id', $value['A'])->update(['cost_price' => $value['K'], 'goods_price' => $value['L']]); |
|
|
|
|
GoodsCategoryRelModel::updates((int)$value['A'], explode(",", $value['F'])); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 执行批量导入 |
|
|
|
|
* @param array $form |
|
|
|
|