|
|
@@ -44,11 +44,11 @@ class ImportList extends Backend
|
|
|
$sql_restul = $shopList->alias('s')
|
|
|
->join("yun_customer c", "s.customer_id = c.id", "INNER")
|
|
|
->where(['s.status' => 1, 'c.status' => 1])
|
|
|
- ->field(['s.id','s.shop_id', 's.name', 'c.name' => 'nickname'])
|
|
|
+ ->field(['s.id', 's.shop_id', 's.name', 'c.name' => 'nickname'])
|
|
|
->select();
|
|
|
$arr = [];
|
|
|
foreach ($sql_restul as $item) {
|
|
|
- $arr[$item['id']] = $item['name'] .'('.'店铺id:'.$item['shop_id'].',客户:' . $item['nickname'] . ')';
|
|
|
+ $arr[$item['id']] = $item['name'] . '(' . '店铺id:' . $item['shop_id'] . ',客户:' . $item['nickname'] . ')';
|
|
|
}
|
|
|
|
|
|
return $this->jsonSuccess('', $arr);
|
|
|
@@ -113,11 +113,11 @@ class ImportList extends Backend
|
|
|
$sql_restul = $shopList->alias('s')
|
|
|
->join("yun_customer c", "s.customer_id = c.id", "INNER")
|
|
|
->where(['s.status' => 1, 'c.status' => 1])
|
|
|
- ->field(['s.id','s.shop_id', 's.name', 'c.name' => 'nickname'])
|
|
|
+ ->field(['s.id', 's.shop_id', 's.name', 'c.name' => 'nickname'])
|
|
|
->select();
|
|
|
$arr = [];
|
|
|
foreach ($sql_restul as $item) {
|
|
|
- $arr[$item['id']] = $item['name'] .'('.'店铺id:'.$item['shop_id'].',客户:' . $item['nickname'] . ')';
|
|
|
+ $arr[$item['id']] = $item['name'] . '(' . '店铺id:' . $item['shop_id'] . ',客户:' . $item['nickname'] . ')';
|
|
|
}
|
|
|
|
|
|
$this->assign('shopList', $arr);
|
|
|
@@ -169,6 +169,7 @@ class ImportList extends Backend
|
|
|
public function specs(mixed $row = null)
|
|
|
{
|
|
|
$ids = $this->request->param('ids');
|
|
|
+ $importSku = new ImportSku();
|
|
|
if (!$row || is_array($row)) {
|
|
|
$row = $this->model->find($ids);
|
|
|
}
|
|
|
@@ -187,8 +188,12 @@ class ImportList extends Backend
|
|
|
$shopListModel = new ShopListModel();
|
|
|
|
|
|
$rows = $shopListModel::where('shop_id', $shop_id)->where('status', 1)->find();
|
|
|
+ $sql_data = $importSku->where(['shop_id' => $row['shop_id'], 'sku_id' => $row['sku_id']])->find();
|
|
|
+
|
|
|
$this->assign('rows', $rows->type_spec ?? '');
|
|
|
$this->assign('row', $row);
|
|
|
+ $this->assign('now_spec_id', $sql_data['spec_id']);
|
|
|
+
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
$params = $this->request->post("");
|
|
|
@@ -197,53 +202,135 @@ class ImportList extends Backend
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
|
|
|
- //插入规格
|
|
|
- ImportSku::insertSpecs($row['shop_id'], $row['sku_id'], (int)$params['all_data'][0]['type_id'], (int)$params['all_data'][0]['id']);
|
|
|
+ $status = $row['status'];
|
|
|
+ $time = time();
|
|
|
|
|
|
- //查看有多少规格
|
|
|
- $list = $this->model::where('shop_id', $row['shop_id'])->where('sku_id', $row['sku_id'])->where('status', 2)->select();
|
|
|
$shopList = new ShopList();
|
|
|
$productConfig = new ProductConfig();
|
|
|
$shopDelivery = new ShopDelivery();
|
|
|
$customerSpec = new CustomerSpec();
|
|
|
- $importSku = new ImportSku();
|
|
|
- $shopDelivery_list=[];
|
|
|
- $import_list=[];
|
|
|
- foreach ($list as $item) {
|
|
|
- //插入发货数据
|
|
|
- $res=JuShuiTanService::setAdditionalPrice(
|
|
|
- $importSku,
|
|
|
- $shopList,
|
|
|
- $productConfig,
|
|
|
- $shopDelivery,
|
|
|
- $customerSpec,
|
|
|
- $item['shop_id'],
|
|
|
- $item['sku_id'],
|
|
|
- $params['all_data'][0]['type_id'],
|
|
|
- $params['all_data'][0]['id'],
|
|
|
- $params['all_data'][0]['name'],
|
|
|
- $item
|
|
|
- );
|
|
|
- $getPackSpecsFee=$res['getPackSpecsFee'];
|
|
|
- $shopDelivery_list[]=$res['shopDelivery'];
|
|
|
- $import_list_item=[
|
|
|
- 'id'=>$item['id'],
|
|
|
- 'pack_specs_id'=>$getPackSpecsFee['data']['id'],
|
|
|
- 'labor_cost_money'=>$getPackSpecsFee['data']['labor_cost_money'],
|
|
|
- 'one_surcharge_money'=>$getPackSpecsFee['one_surcharge_money'],
|
|
|
- 'two_surcharge_money'=>$getPackSpecsFee['two_surcharge_money'],
|
|
|
- 'status' => 3
|
|
|
- ];
|
|
|
- $import_list[]=$import_list_item;
|
|
|
- $count++;
|
|
|
- // $count += $item->save(['pack_specs_id'=>$getPackSpecsFee['data']['id'],'labor_cost_money'=>$getPackSpecsFee['data']['labor_cost_money'],'one_surcharge_money'=>$getPackSpecsFee['one_surcharge_money'],'two_surcharge_money'=>$getPackSpecsFee['two_surcharge_money'],'status' => 3]);
|
|
|
- }
|
|
|
- $this->model->saveAll($import_list);
|
|
|
- $shopDelivery->saveAll($shopDelivery_list);
|
|
|
- if ($this->callback) {
|
|
|
- $callback = $this->callback;
|
|
|
- $callback($ids);
|
|
|
+
|
|
|
+ $shopDelivery_list = [];
|
|
|
+ $import_list = [];
|
|
|
+
|
|
|
+ $shopDelivery_updata_list=[];
|
|
|
+ $todayStart = date('Y-m-d', $time);
|
|
|
+ $todayStart=$todayStart.' 00:00:00';
|
|
|
+ switch ($status) {
|
|
|
+ case 2:
|
|
|
+ //插入规格
|
|
|
+ ImportSku::insertSpecs($row['shop_id'], $row['sku_id'], (int)$params['all_data'][0]['type_id'], (int)$params['all_data'][0]['id']);
|
|
|
+
|
|
|
+ //查看有多少规格
|
|
|
+ $list = $this->model::where('shop_id', $row['shop_id'])->where('sku_id', $row['sku_id'])->where('status', 2)->select();
|
|
|
+
|
|
|
+ foreach ($list as $item) {
|
|
|
+ //插入发货数据
|
|
|
+ $res = JuShuiTanService::setAdditionalPrice(
|
|
|
+ $importSku,
|
|
|
+ $shopList,
|
|
|
+ $productConfig,
|
|
|
+ $shopDelivery,
|
|
|
+ $customerSpec,
|
|
|
+ $item['shop_id'],
|
|
|
+ $item['sku_id'],
|
|
|
+ $params['all_data'][0]['type_id'],
|
|
|
+ $params['all_data'][0]['id'],
|
|
|
+ $params['all_data'][0]['name'],
|
|
|
+ $item
|
|
|
+ );
|
|
|
+ $getPackSpecsFee = $res['getPackSpecsFee'];
|
|
|
+ $shopDelivery_list[] = $res['shopDelivery'];
|
|
|
+ $import_list_item = [
|
|
|
+ 'id' => $item['id'],
|
|
|
+ 'pack_specs_id' => $getPackSpecsFee['data']['id'],
|
|
|
+ 'labor_cost_money' => $getPackSpecsFee['data']['labor_cost_money'],
|
|
|
+ 'one_surcharge_money' => $getPackSpecsFee['one_surcharge_money'],
|
|
|
+ 'two_surcharge_money' => $getPackSpecsFee['two_surcharge_money'],
|
|
|
+ 'status' => 3
|
|
|
+ ];
|
|
|
+ $import_list[] = $import_list_item;
|
|
|
+ $count++;
|
|
|
+ }
|
|
|
+ $this->model->saveAll($import_list);
|
|
|
+ $shopDelivery->saveAll($shopDelivery_list);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ //修改规格
|
|
|
+ $importSku = new ImportSku();
|
|
|
+ $sql_data = $importSku->where(['shop_id' => $row['shop_id'], 'sku_id' => $row['sku_id']])->find();
|
|
|
+
|
|
|
+ $result = $sql_data->save([
|
|
|
+ 'variety_id' => (int)$params['all_data'][0]['type_id'],
|
|
|
+ 'spec_id' => (int)$params['all_data'][0]['id']
|
|
|
+ ]);
|
|
|
+ if (!$result) $this->error(__('没有数据被更新'));
|
|
|
+ //查看有多少规格
|
|
|
+ $where=[];
|
|
|
+ $where[] = ['shop_id', '=', $row['shop_id']];
|
|
|
+ $where[] = ['sku_id', '=', $row['sku_id']];
|
|
|
+ $where[] = ['consign_time','>=',$todayStart];
|
|
|
+
|
|
|
+ $whereOr=[];
|
|
|
+ $whereOr[] = ['shop_id', '=', $row['shop_id']];
|
|
|
+ $whereOr[] = ['sku_id', '=', $row['sku_id']];
|
|
|
+ $whereOr[] = ['status','=',2];
|
|
|
+
|
|
|
+ $list = $this->model::where($where)->whereOr($whereOr)->select();
|
|
|
+
|
|
|
+ foreach ($list as $item) {
|
|
|
+ //插入发货数据
|
|
|
+ $res = JuShuiTanService::setAdditionalPrice(
|
|
|
+ $importSku,
|
|
|
+ $shopList,
|
|
|
+ $productConfig,
|
|
|
+ $shopDelivery,
|
|
|
+ $customerSpec,
|
|
|
+ $item['shop_id'],
|
|
|
+ $item['sku_id'],
|
|
|
+ $params['all_data'][0]['type_id'],
|
|
|
+ $params['all_data'][0]['id'],
|
|
|
+ $params['all_data'][0]['name'],
|
|
|
+ $item
|
|
|
+ );
|
|
|
+ $getPackSpecsFee = $res['getPackSpecsFee'];
|
|
|
+
|
|
|
+
|
|
|
+ if($item['status']==2){
|
|
|
+ $shopDelivery_list[] = $res['shopDelivery'];
|
|
|
+ }else if($item['status']==3){
|
|
|
+ $waybill_no=$res['shopDelivery']['waybill_no'];
|
|
|
+ $shopDelivery_id=JuShuiTanService::get_shopDelivery_id($waybill_no);
|
|
|
+ if($shopDelivery_id>0){
|
|
|
+ $res['shopDelivery']['id']=$shopDelivery_id;
|
|
|
+ $res['shopDelivery']['updatetime']=$time;
|
|
|
+ $shopDelivery_updata_list[]=$res['shopDelivery'];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $import_list_item = [
|
|
|
+ 'id' => $item['id'],
|
|
|
+ 'pack_specs_id' => $getPackSpecsFee['data']['id'],
|
|
|
+ 'labor_cost_money' => $getPackSpecsFee['data']['labor_cost_money'],
|
|
|
+ 'one_surcharge_money' => $getPackSpecsFee['one_surcharge_money'],
|
|
|
+ 'two_surcharge_money' => $getPackSpecsFee['two_surcharge_money'],
|
|
|
+ 'status' => 3
|
|
|
+ ];
|
|
|
+
|
|
|
+ $import_list[] = $import_list_item;
|
|
|
+ $count++;
|
|
|
+ }
|
|
|
+ $this->model->saveAll($import_list);
|
|
|
+ $shopDelivery->saveAll($shopDelivery_list);
|
|
|
+ $shopDelivery->saveAll($shopDelivery_updata_list);
|
|
|
+
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ # code...
|
|
|
+ break;
|
|
|
}
|
|
|
+
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollback();
|