lqmac 11 months ago
parent ff075cd559
commit 49c9010049
  1. 6
      app/api/service/Goods.php
  2. 10
      app/api/service/order/Checkout.php
  3. 6
      app/common/model/Channel.php
  4. 6
      app/common/model/Region.php
  5. 3
      app/job/service/goods/AdminImport.php
  6. 2
      app/store/controller/Goods.php
  7. 20
      app/store/model/goods/Import.php
  8. BIN
      public/store/static/template/batch-goods.xlsx

@ -250,7 +250,11 @@ class Goods extends GoodsService
'store_id' => $storeid, 'store_id' => $storeid,
'is_main' => 1, 'is_main' => 1,
])->field('shop_name,star,shop_hours,summary,phone, ])->field('shop_name,star,shop_hours,summary,phone,
province_id,city_id,region_id,shop_id,address,latitude,longitude,wechat_img_id,history1,history2,history3,remark,history,parking_name,parking_desc,parking_latitude,parking_longitude,shop_image_id,fuwu_hours,fuwu_num')->find()->toArray(); province_id,city_id,region_id,shop_id,address,latitude,longitude,wechat_img_id,history1,history2,history3,remark,history,parking_name,parking_desc,parking_latitude,parking_longitude,shop_image_id,fuwu_hours,fuwu_num')->find();
if (!$info) {
return [];
}
$info = $info->toArray();
//todo wmc //todo wmc
$info['remark'] = json_decode($info['remark'],true); $info['remark'] = json_decode($info['remark'],true);
$arr = explode(" ", $info['shop_hours']); $arr = explode(" ", $info['shop_hours']);

@ -178,13 +178,17 @@ class Checkout extends BaseService
$this->orderData = $this->getOrderData(); $this->orderData = $this->getOrderData();
//校验是否在销售区域 //校验是否在销售区域
foreach ($this->goodsList as $key => $value) { foreach ($this->goodsList as $key => $value) {
if (!$value['sale_areas']) { if (!$value['region']) {
continue; continue;
} }
if (strpos($this->orderData['address']->province_id.".".$this->orderData['address']->city_id, $value['sale_areas']) === false) {
if (!in_array($this->orderData['address']->city_id, json_decode($value['region']))) {
$this->setError("您的收货地址不在商品 [{$value['goods_name']}] 的销售区域内"); $this->setError("您的收货地址不在商品 [{$value['goods_name']}] 的销售区域内");
break;
} }
// if (strpos($this->orderData['address']->province_id.".".$this->orderData['address']->city_id, $value['sale_areas']) === false) {
// $this->setError("您的收货地址不在商品 [{$value['goods_name']}] 的销售区域内");
// break;
// }
} }
// 验证商品状态, 是否允许购买 // 验证商品状态, 是否允许购买

@ -29,5 +29,9 @@ class Channel extends BaseModel
// 定义主键 // 定义主键
protected $pk = 'id'; protected $pk = 'id';
public static function init()
{
self::$storeId = 0;
app()->request->setStoreId(0);
}
} }

@ -44,7 +44,11 @@ class Region extends BaseModel
// 当前数据版本号 // 当前数据版本号
private static string $version = '1.0.3'; private static string $version = '1.0.3';
public static function init()
{
self::$storeId = 0;
app()->request->setStoreId(0);
}
/** /**
* 根据ID获取地区名称 * 根据ID获取地区名称
* @param int $id * @param int $id

@ -196,6 +196,7 @@ class AdminImport extends BaseService
*/ */
public function createData(array $original, int $storeId): array public function createData(array $original, int $storeId): array
{ {
$channel = Channel::where('name', $original["B"])->find(); $channel = Channel::where('name', $original["B"])->find();
$arr = []; $arr = [];
@ -225,6 +226,8 @@ class AdminImport extends BaseService
'goods_status' => 10,//上架 'goods_status' => 10,//上架
'store_id' => $storeId, 'store_id' => $storeId,
'sale_areas' => $arr ? implode("、", $arr) : "", 'sale_areas' => $arr ? implode("、", $arr) : "",
'region' => $arr ? implode("、", $arr) : "",
'region_text' => $arr ? implode("、", $arr) : "",
'import' => 1,//是否是导入采集 'import' => 1,//是否是导入采集
]; ];
// echo "<pre>"; // echo "<pre>";

@ -33,7 +33,7 @@ class Goods extends Controller
{ {
// 获取列表记录 // 获取列表记录
$model = new GoodsModel; $model = new GoodsModel;
$list= $model->getList($this->request->param()); $list= $model->getList($this->request->param(), (int)$this->request->param('pageSize', 15));
return $this->renderSuccess(compact('list')); return $this->renderSuccess(compact('list'));
} }

@ -78,15 +78,19 @@ class Import extends ImportModel
$this->checkLimit($execlData); $this->checkLimit($execlData);
self::$storeId = $form['store_id'] ?? 0; self::$storeId = $form['store_id'] ?? 0;
// $obj = new \app\job\service\goods\AdminImport(); $obj = new \app\job\service\goods\AdminImport();
// $service = new \app\job\service\goods\Collector(); $service = new \app\job\service\goods\Collector();
// foreach ($execlData as $item) { foreach ($execlData as $item) {
// $data = $obj->createData($item, self::$storeId); $data = $obj->createData($item, self::$storeId);
// $service->single($item['D'], $data, self::$storeId); echo "<pre>";
// // // 记录导入成功 print_r($data);
// // $this->successCount++; exit();
// } $service->single($item['D'], $data, self::$storeId);
// // 记录导入成功
// $this->successCount++;
}
exit();
// 新增商品导入记录 // 新增商品导入记录
$recordId = $this->addRecord(\count($execlData)); $recordId = $this->addRecord(\count($execlData));

Loading…
Cancel
Save