lqmac 8 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,
'is_main' => 1,
])->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
$info['remark'] = json_decode($info['remark'],true);
$arr = explode(" ", $info['shop_hours']);

@ -178,13 +178,17 @@ class Checkout extends BaseService
$this->orderData = $this->getOrderData();
//校验是否在销售区域
foreach ($this->goodsList as $key => $value) {
if (!$value['sale_areas']) {
if (!$value['region']) {
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']}] 的销售区域内");
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';
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';
public static function init()
{
self::$storeId = 0;
app()->request->setStoreId(0);
}
/**
* 根据ID获取地区名称
* @param int $id

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

@ -33,7 +33,7 @@ class Goods extends Controller
{
// 获取列表记录
$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'));
}

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

Loading…
Cancel
Save