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

Reviewed-on: #79
This commit is contained in:
mkm 2023-11-30 09:36:22 +08:00
commit 8868f69ac8
153 changed files with 17863 additions and 685 deletions

View File

@ -72,7 +72,7 @@ class StoreOrderDao extends BaseDao
if (isset($where['is_trader']) && $where['is_trader'] !== '') { if (isset($where['is_trader']) && $where['is_trader'] !== '') {
$query->where('is_trader', $where['is_trader']); $query->where('is_trader', $where['is_trader']);
} }
$query->where('is_del',0); $query->where('is_del', 0);
}); });
$query->when(($sysDel !== null), function ($query) use ($sysDel) { $query->when(($sysDel !== null), function ($query) use ($sysDel) {
@ -81,9 +81,9 @@ class StoreOrderDao extends BaseDao
->when(isset($where['order_type']) && $where['order_type'] >= 0 && $where['order_type'] !== '', function ($query) use ($where) { ->when(isset($where['order_type']) && $where['order_type'] >= 0 && $where['order_type'] !== '', function ($query) use ($where) {
if ($where['order_type'] == 2) { if ($where['order_type'] == 2) {
$query->where('is_virtual', 1); $query->where('is_virtual', 1);
} else if($where['order_type'] == 0){ //实体发货订单 } else if ($where['order_type'] == 0) { //实体发货订单
$query->where('order_type', 0)->where('is_virtual',0); $query->where('order_type', 0)->where('is_virtual', 0);
} else if($where['order_type'] == 3) { //发货订单 } else if ($where['order_type'] == 3) { //发货订单
$query->where('order_type', 0); $query->where('order_type', 0);
} else { } else {
$query->where('order_type', $where['order_type']); $query->where('order_type', $where['order_type']);
@ -98,19 +98,19 @@ class StoreOrderDao extends BaseDao
->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) { ->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
// 12表示信用购 先货后款 // 12表示信用购 先货后款
switch ($where['status']) { switch ($where['status']) {
case 0 : case 0:
$query->whereIn('StoreOrder.status', [0, 9, 12]); $query->whereIn('StoreOrder.status', [0, 9, 12]);
break; break;
case -2 : case -2:
$query->where('StoreOrder.paid', 1)->whereNotIn('StoreOrder.status', [10, 11]); $query->where('StoreOrder.paid', 1)->whereNotIn('StoreOrder.status', [10, 11]);
break; break;
case 10 : case 10:
$query->where('StoreOrder.paid', 1)->whereIn('StoreOrder.status', [10, 11]); $query->where('StoreOrder.paid', 1)->whereIn('StoreOrder.status', [10, 11]);
break; break;
case 2 : case 2:
$query->where('StoreOrder.paid', 1)->where('StoreOrder.status', $where['status'])->where('pay_type', '<>', StoreGroupOrder::PAY_TYPE_CREDIT_BUY); $query->where('StoreOrder.paid', 1)->where('StoreOrder.status', $where['status'])->where('pay_type', '<>', StoreGroupOrder::PAY_TYPE_CREDIT_BUY);
break; break;
case 20 : case 20:
$query->where('StoreOrder.paid', 1)->whereIn('StoreOrder.status', [2, 3]); $query->where('StoreOrder.paid', 1)->whereIn('StoreOrder.status', [2, 3]);
break; break;
default: default:
@ -122,15 +122,15 @@ class StoreOrderDao extends BaseDao
$query->where('StoreOrder.uid', $where['uid']); $query->where('StoreOrder.uid', $where['uid']);
}) })
->when(isset($where['is_user']) && $where['is_user'] !== 0, function ($query) use ($where) { ->when(isset($where['is_user']) && $where['is_user'] !== 0, function ($query) use ($where) {
$query->where(function($query) { $query->where(function ($query) {
$query->where('order_type',0)->whereOr(function($query){ $query->where('order_type', 0)->whereOr(function ($query) {
$query->where('order_type',1)->where('main_id',0); $query->where('order_type', 1)->where('main_id', 0);
}); });
}); });
}) })
//待核销订单 //待核销订单
->when(isset($where['is_verify']) && $where['is_verify'], function ($query) use ($where) { ->when(isset($where['is_verify']) && $where['is_verify'], function ($query) use ($where) {
$query->where('StoreOrder.order_type', 1)->where('StoreOrder.status',0); $query->where('StoreOrder.order_type', 1)->where('StoreOrder.status', 0);
}) })
->when(isset($where['pay_type']) && $where['pay_type'] !== '', function ($query) use ($where) { ->when(isset($where['pay_type']) && $where['pay_type'] !== '', function ($query) use ($where) {
$query->where('StoreOrder.pay_type', $where['pay_type']); $query->where('StoreOrder.pay_type', $where['pay_type']);
@ -139,9 +139,9 @@ class StoreOrderDao extends BaseDao
$query->whereIn('order_id', $where['order_ids']); $query->whereIn('order_id', $where['order_ids']);
}) })
->when(isset($where['order_id']) && $where['order_id'] !== '', function ($query) use ($where) { ->when(isset($where['order_id']) && $where['order_id'] !== '', function ($query) use ($where) {
if(is_array($where['order_id'])){ if (is_array($where['order_id'])) {
$query->whereIn('order_id',$where['order_id']); $query->whereIn('order_id', $where['order_id']);
}else{ } else {
$query->where('order_id', $where['order_id']); $query->where('order_id', $where['order_id']);
} }
}) })
@ -154,6 +154,9 @@ class StoreOrderDao extends BaseDao
->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) { ->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
getModelTime($query, $where['date'], 'StoreOrder.create_time'); getModelTime($query, $where['date'], 'StoreOrder.create_time');
}) })
->when(isset($where['pay_time']) && $where['pay_time'] !== '', function ($query) use ($where) {
getModelTime($query, $where['pay_time'], 'StoreOrder.pay_time');
})
->when(isset($where['verify_date']) && $where['verify_date'] !== '', function ($query) use ($where) { ->when(isset($where['verify_date']) && $where['verify_date'] !== '', function ($query) use ($where) {
getModelTime($query, $where['verify_date'], 'verify_time'); getModelTime($query, $where['verify_date'], 'verify_time');
}) })
@ -170,40 +173,40 @@ class StoreOrderDao extends BaseDao
$query->where('service_id', $where['service_id']); $query->where('service_id', $where['service_id']);
}) })
->when(isset($where['username']) && $where['username'] !== '', function ($query) use ($where) { ->when(isset($where['username']) && $where['username'] !== '', function ($query) use ($where) {
$query->join('User U','StoreOrder.uid = U.uid') $query->join('User U', 'StoreOrder.uid = U.uid')
->where(function($query) use($where) { ->where(function ($query) use ($where) {
$query->where('nickname', 'like', "%{$where['username']}%") $query->where('nickname', 'like', "%{$where['username']}%")
->whereOr('phone', 'like', "%{$where['username']}%") ->whereOr('phone', 'like', "%{$where['username']}%")
->whereOr('user_phone', 'like', "%{$where['username']}%"); ->whereOr('user_phone', 'like', "%{$where['username']}%");
}); });
}) })
->when(isset($where['store_name']) && $where['store_name'] !== '', function ($query) use ($where) { ->when(isset($where['store_name']) && $where['store_name'] !== '', function ($query) use ($where) {
$orderId = StoreOrderProduct::alias('op') $orderId = StoreOrderProduct::alias('op')
->join('storeProduct sp','op.product_id = sp.product_id') ->join('storeProduct sp', 'op.product_id = sp.product_id')
->whereLike('store_name',"%{$where['store_name']}%") ->whereLike('store_name', "%{$where['store_name']}%")
->when((isset($where['sp.mer_id']) && $where['mer_id'] !== ''),function($query) use($where){ ->when((isset($where['sp.mer_id']) && $where['mer_id'] !== ''), function ($query) use ($where) {
$query->where('mer_id',$where['mer_id']); $query->where('mer_id', $where['mer_id']);
})->column('order_id'); })->column('order_id');
$query->whereIn('order_id',$orderId ?: '' ); $query->whereIn('order_id', $orderId ?: '');
}) })
->when(isset($where['search']) && $where['search'] !== '', function ($query) use ($where) { ->when(isset($where['search']) && $where['search'] !== '', function ($query) use ($where) {
$orderId = StoreOrderProduct::alias('op') $orderId = StoreOrderProduct::alias('op')
->join('storeProduct sp','op.product_id = sp.product_id') ->join('storeProduct sp', 'op.product_id = sp.product_id')
->whereLike('store_name',"%{$where['search']}%") ->whereLike('store_name', "%{$where['search']}%")
->when((isset($where['sp.mer_id']) && $where['mer_id'] !== ''),function($query) use($where){ ->when((isset($where['sp.mer_id']) && $where['mer_id'] !== ''), function ($query) use ($where) {
$query->where('mer_id',$where['mer_id']); $query->where('mer_id', $where['mer_id']);
})->column('order_id'); })->column('order_id');
$query->where(function($query) use($orderId,$where){ $query->where(function ($query) use ($orderId, $where) {
$query->whereIn('order_id',$orderId ? $orderId : '') $query->whereIn('order_id', $orderId ? $orderId : '')
->whereOr('order_sn','like',"%{$where['search']}%") ->whereOr('order_sn', 'like', "%{$where['search']}%")
->whereOr('user_phone','like',"%{$where['search']}%"); ->whereOr('user_phone', 'like', "%{$where['search']}%");
}); });
}) })
->when(isset($where['order_search']) && $where['order_search'] !== '', function ($query) use ($where) { ->when(isset($where['order_search']) && $where['order_search'] !== '', function ($query) use ($where) {
$query->where('order_sn', 'like', '%' . $where['order_search'] . '%')->whereOr('user_phone', $where['order_search']); $query->where('order_sn', 'like', '%' . $where['order_search'] . '%')->whereOr('user_phone', $where['order_search']);
}) })
->when(isset($where['group_order_sn']) && $where['group_order_sn'] !== '', function ($query) use ($where) { ->when(isset($where['group_order_sn']) && $where['group_order_sn'] !== '', function ($query) use ($where) {
$query->join('StoreGroupOrder GO','StoreOrder.group_order_id = GO.group_order_id')->where('group_order_sn',$where['group_order_sn']); $query->join('StoreGroupOrder GO', 'StoreOrder.group_order_id = GO.group_order_id')->where('group_order_sn', $where['group_order_sn']);
}) })
->when(isset($where['keywords']) && $where['keywords'] !== '', function ($query) use ($where) { ->when(isset($where['keywords']) && $where['keywords'] !== '', function ($query) use ($where) {
$query->where(function ($query) use ($where) { $query->where(function ($query) use ($where) {
@ -270,8 +273,8 @@ class StoreOrderDao extends BaseDao
public function fieldExists($field, $value, ?int $except = null): bool public function fieldExists($field, $value, ?int $except = null): bool
{ {
return ($this->getModel()::getDB())->when($except, function ($query) use ($field, $except) { return ($this->getModel()::getDB())->when($except, function ($query) use ($field, $except) {
$query->where($field, '<>', $except); $query->where($field, '<>', $except);
})->where($field, $value)->count() > 0; })->where($field, $value)->count() > 0;
} }
/** /**
@ -360,15 +363,15 @@ class StoreOrderDao extends BaseDao
})->when($date, function ($query, $date) use ($paid) { })->when($date, function ($query, $date) use ($paid) {
if (!$paid) { if (!$paid) {
getModelTime($query, $date); getModelTime($query, $date);
// $query->where(function ($query) use ($date) { // $query->where(function ($query) use ($date) {
// $query->where(function ($query) use ($date) { // $query->where(function ($query) use ($date) {
// $query->where('paid', 1); // $query->where('paid', 1);
// getModelTime($query, $date, 'pay_time'); // getModelTime($query, $date, 'pay_time');
// })->whereOr(function ($query) use ($date) { // })->whereOr(function ($query) use ($date) {
// $query->where('paid', 0); // $query->where('paid', 0);
// getModelTime($query, $date); // getModelTime($query, $date);
// }); // });
// }); // });
} else } else
getModelTime($query, $date, 'pay_time'); getModelTime($query, $date, 'pay_time');
})->group('uid')->count(); })->group('uid')->count();
@ -424,7 +427,7 @@ class StoreOrderDao extends BaseDao
public function orderGroupNum($date, $merId = null) public function orderGroupNum($date, $merId = null)
{ {
$field = Db::raw('sum(pay_price) as pay_price,count(*) as total,count(distinct uid) as user,pay_time,from_unixtime(unix_timestamp(pay_time),\'%m-%d\') as `day`'); $field = Db::raw('sum(pay_price) as pay_price,count(*) as total,count(distinct uid) as user,pay_time,from_unixtime(unix_timestamp(pay_time),\'%m-%d\') as `day`');
if ($date == 'year'){ if ($date == 'year') {
$field = Db::raw('sum(pay_price) as pay_price,count(*) as total,count(distinct uid) as user,pay_time,from_unixtime(unix_timestamp(pay_time),\'%m\') as `day`'); $field = Db::raw('sum(pay_price) as pay_price,count(*) as total,count(distinct uid) as user,pay_time,from_unixtime(unix_timestamp(pay_time),\'%m\') as `day`');
} }
$query = StoreOrder::getDB()->field($field) $query = StoreOrder::getDB()->field($field)
@ -440,10 +443,19 @@ class StoreOrderDao extends BaseDao
{ {
return StoreOrder::getDB()->when(isset($where['dateRange']), function ($query) use ($where) { return StoreOrder::getDB()->when(isset($where['dateRange']), function ($query) use ($where) {
getModelTime($query, date('Y/m/d 00:00:00', $where['dateRange']['start']) . '-' . date('Y/m/d 00:00:00', $where['dateRange']['stop']), 'pay_time'); getModelTime($query, date('Y/m/d 00:00:00', $where['dateRange']['start']) . '-' . date('Y/m/d 00:00:00', $where['dateRange']['stop']), 'pay_time');
})->field(Db::raw('sum(pay_price) as pay_price,count(*) as total,count(distinct uid) as user,pay_time,from_unixtime(unix_timestamp(pay_time),\'%m-%d\') as `day`')) })->field(
Db::raw('status,sum(pay_price) as pay_price,count(*) as total,count(distinct uid) as user,pay_time,from_unixtime(unix_timestamp(pay_time),\'%m-%d\') as `day`')
)
->where('paid', 1)->when($merId, function ($query, $merId) { ->where('paid', 1)->when($merId, function ($query, $merId) {
$query->where('mer_id', $merId); $query->where('mer_id', $merId);
})->order('pay_time DESC')->page($page, $limit)->group('day')->select(); })->order('pay_time DESC')->page($page, $limit)->group('day')->select()->each(function ($item) use ($merId) {
$pay_time = explode(' ', $item['pay_time']);
$item->settlement_price = Db::name('store_order')
->whereIn('status', [2, 3])
->where('mer_id', $merId)
->whereDay('pay_time', $pay_time[0])
->sum('pay_price');
});
} }
public function dayOrderPriceGroup($date, $merId = null) public function dayOrderPriceGroup($date, $merId = null)
@ -534,20 +546,20 @@ class StoreOrderDao extends BaseDao
* @author Qinii * @author Qinii
* @day 2020-11-11 * @day 2020-11-11
*/ */
public function getTattendCount(array $data,?int $uid) public function getTattendCount(array $data, ?int $uid)
{ {
$query = StoreOrder::hasWhere('orderProduct',function($query)use($data,$uid){ $query = StoreOrder::hasWhere('orderProduct', function ($query) use ($data, $uid) {
$query->when(isset($data['activity_id']),function ($query)use($data){ $query->when(isset($data['activity_id']), function ($query) use ($data) {
$query->where('activity_id',$data['activity_id']); $query->where('activity_id', $data['activity_id']);
})
->when(isset($data['product_sku']), function ($query) use ($data) {
$query->where('product_sku', $data['product_sku']);
}) })
->when(isset($data['product_sku']),function ($query)use($data){ ->when(isset($data['product_id']), function ($query) use ($data) {
$query->where('product_sku',$data['product_sku']); $query->where('product_id', $data['product_id']);
}) })
->when(isset($data['product_id']),function ($query)use($data){ ->when(isset($data['exsits_id']), function ($query) use ($data) {
$query->where('product_id',$data['product_id']); switch ($data['product_type']) {
})
->when(isset($data['exsits_id']),function ($query)use ($data){
switch ($data['product_type']){
case 3: case 3:
$make = app()->make(ProductAssistSetRepository::class); $make = app()->make(ProductAssistSetRepository::class);
$id = 'product_assist_id'; $id = 'product_assist_id';
@ -559,34 +571,33 @@ class StoreOrderDao extends BaseDao
} }
$where = [$id => $data['exsits_id']]; $where = [$id => $data['exsits_id']];
$activity_id = $make->getSearch($where)->column($make->getPk()); $activity_id = $make->getSearch($where)->column($make->getPk());
if($activity_id) { if ($activity_id) {
$id = array_unique($activity_id); $id = array_unique($activity_id);
$query->where('activity_id','in',$id); $query->where('activity_id', 'in', $id);
}else{ } else {
$query->where('activity_id','<',0); $query->where('activity_id', '<', 0);
} }
}) })
->where('product_type',$data['product_type']); ->where('product_type', $data['product_type']);
if($uid) $query->where('uid',$uid); if ($uid) $query->where('uid', $uid);
}); });
$query->where('activity_type',$data['product_type']); $query->where('activity_type', $data['product_type']);
switch($data['product_type']) switch ($data['product_type']) {
{
case 0: case 0:
$query->where(function($query){ $query->where(function ($query) {
$query->where(function($query){ $query->where(function ($query) {
$query->where('paid',1); $query->where('paid', 1);
})->whereOr(function($query){ })->whereOr(function ($query) {
$query->where('paid',0)->where('is_del',0); $query->where('paid', 0)->where('is_del', 0);
}); });
}); });
break; break;
case 1: //秒杀 case 1: //秒杀
$query->where(function($query){ $query->where(function ($query) {
$query->where(function($query){ $query->where(function ($query) {
$query->where('paid',1); $query->where('paid', 1);
})->whereOr(function($query){ })->whereOr(function ($query) {
$query->where('paid',0)->where('is_del',0); $query->where('paid', 0)->where('is_del', 0);
}); });
})->when(isset($data['day']), function ($query) use ($data) { })->when(isset($data['day']), function ($query) use ($data) {
$query->whereDay('StoreOrder.create_time', $data['day']); $query->whereDay('StoreOrder.create_time', $data['day']);
@ -599,28 +610,28 @@ class StoreOrderDao extends BaseDao
* 第二阶段参与人数:支付了第一阶段 * 第二阶段参与人数:支付了第一阶段
*/ */
//第二阶段 //第二阶段
if($data['type'] == 1){ if ($data['type'] == 1) {
$query->where(function($query){ $query->where(function ($query) {
$query->where('paid',1)->whereOr(function($query){ $query->where('paid', 1)->whereOr(function ($query) {
$query->where('paid',0)->where('is_del',0); $query->where('paid', 0)->where('is_del', 0);
}); });
}); });
} }
if($data['type'] == 2) $query->where('paid',1)->where('status','in',[0,1,2,3,-1]); if ($data['type'] == 2) $query->where('paid', 1)->where('status', 'in', [0, 1, 2, 3, -1]);
break; break;
case 3: //助力 case 3: //助力
$query->where(function($query){ $query->where(function ($query) {
$query->where('paid',1)->whereOr(function($query){ $query->where('paid', 1)->whereOr(function ($query) {
$query->where('paid',0)->where('is_del',0); $query->where('paid', 0)->where('is_del', 0);
}); });
}); });
break; break;
case 4: // case 4: //
$query->where(function($query){ $query->where(function ($query) {
$query->where('paid',1)->whereOr(function($query){ $query->where('paid', 1)->whereOr(function ($query) {
$query->where('paid',0)->where('is_del',0); $query->where('paid', 0)->where('is_del', 0);
}) })
->where('status','>',-1); ->where('status', '>', -1);
}); });
break; break;
} }
@ -637,20 +648,20 @@ class StoreOrderDao extends BaseDao
* @author Qinii * @author Qinii
* @day 2020-10-30 * @day 2020-10-30
*/ */
public function getTattendSuccessCount($data,?int $uid) public function getTattendSuccessCount($data, ?int $uid)
{ {
$query = StoreOrder::hasWhere('orderProduct',function($query)use($data,$uid){ $query = StoreOrder::hasWhere('orderProduct', function ($query) use ($data, $uid) {
$query->when(isset($data['activity_id']),function ($query)use($data){ $query->when(isset($data['activity_id']), function ($query) use ($data) {
$query->where('activity_id',$data['activity_id']); $query->where('activity_id', $data['activity_id']);
})
->when(isset($data['product_sku']), function ($query) use ($data) {
$query->where('product_sku', $data['product_sku']);
}) })
->when(isset($data['product_sku']),function ($query)use($data){ ->when(isset($data['product_id']), function ($query) use ($data) {
$query->where('product_sku',$data['product_sku']); $query->where('product_id', $data['product_id']);
}) })
->when(isset($data['product_id']),function ($query)use($data){ ->when(isset($data['exsits_id']), function ($query) use ($data) {
$query->where('product_id',$data['product_id']); switch ($data['product_type']) {
})
->when(isset($data['exsits_id']),function ($query)use ($data){
switch ($data['product_type']){
case 3: case 3:
$make = app()->make(ProductAssistSetRepository::class); $make = app()->make(ProductAssistSetRepository::class);
$id = 'product_assist_id'; $id = 'product_assist_id';
@ -662,34 +673,33 @@ class StoreOrderDao extends BaseDao
} }
$where = [$id => $data['exsits_id']]; $where = [$id => $data['exsits_id']];
$activity_id = $make->getSearch($where)->column($make->getPk()); $activity_id = $make->getSearch($where)->column($make->getPk());
if($activity_id) { if ($activity_id) {
$id = array_unique($activity_id); $id = array_unique($activity_id);
$query->where('activity_id','in',$id); $query->where('activity_id', 'in', $id);
}else{ } else {
$query->where('activity_id','<',0); $query->where('activity_id', '<', 0);
} }
}) })
->where('product_type',$data['product_type']); ->where('product_type', $data['product_type']);
if($uid) $query->where('uid',$uid); if ($uid) $query->where('uid', $uid);
}); });
$query->where('activity_type',$data['product_type'])->where('paid',1); $query->where('activity_type', $data['product_type'])->where('paid', 1);
switch($data['product_type']) switch ($data['product_type']) {
{
case 1: //秒杀 case 1: //秒杀
$query->where(function($query){ $query->where(function ($query) {
$query->where(function($query){ $query->where(function ($query) {
$query->where('paid',1); $query->where('paid', 1);
}); });
})->when(isset($data['day']), function ($query) use ($data) { })->when(isset($data['day']), function ($query) use ($data) {
$query->whereDay('StoreOrder.create_time', $data['day']); $query->whereDay('StoreOrder.create_time', $data['day']);
}); });
break; break;
case 2: //预售 case 2: //预售
if($data['type'] == 1){ //第一阶段 if ($data['type'] == 1) { //第一阶段
$query->where('status','in',[0,1,2,3,10]); $query->where('status', 'in', [0, 1, 2, 3, 10]);
} else { //第二阶段 } else { //第二阶段
$query->where('status','in',[0,1,2,3]); $query->where('status', 'in', [0, 1, 2, 3]);
} }
break; break;
case 3: //助力 case 3: //助力
@ -708,26 +718,26 @@ class StoreOrderDao extends BaseDao
* @author Qinii * @author Qinii
* @day 1/4/21 * @day 1/4/21
*/ */
public function getSeckillRefundCount($where,$type = 1) public function getSeckillRefundCount($where, $type = 1)
{ {
$query = StoreOrderProduct::getDB()->alias('P')->join('StoreRefundOrder R','P.order_id = R.order_id'); $query = StoreOrderProduct::getDB()->alias('P')->join('StoreRefundOrder R', 'P.order_id = R.order_id');
$query->join('StoreOrder O','O.order_id = P.order_id'); $query->join('StoreOrder O', 'O.order_id = P.order_id');
$query $query
->when(isset($where['activity_id']),function ($query)use($where){ ->when(isset($where['activity_id']), function ($query) use ($where) {
$query->where('P.activity_id',$where['activity_id']); $query->where('P.activity_id', $where['activity_id']);
}) })
->when(isset($where['product_sku']),function ($query)use($where){ ->when(isset($where['product_sku']), function ($query) use ($where) {
$query->where('P.product_sku',$where['product_sku']); $query->where('P.product_sku', $where['product_sku']);
}) })
->when(isset($where['day']), function ($query) use ($where) { ->when(isset($where['day']), function ($query) use ($where) {
$query->whereDay('P.create_time', $where['day']); $query->whereDay('P.create_time', $where['day']);
}) })
->when($type == 1, function ($query) use ($where) { ->when($type == 1, function ($query) use ($where) {
$query->where('O.verify_time',null)->where('O.delivery_type',null); $query->where('O.verify_time', null)->where('O.delivery_type', null);
},function ($query){ }, function ($query) {
$query ->where('R.refund_type',2); $query->where('R.refund_type', 2);
}) })
->where('P.product_type',1)->where('R.status',3); ->where('P.product_type', 1)->where('R.status', 3);
return $query->count(); return $query->count();
} }
@ -742,14 +752,13 @@ class StoreOrderDao extends BaseDao
*/ */
public function getMaxCountNumber(int $uid, int $productId) public function getMaxCountNumber(int $uid, int $productId)
{ {
return StoreOrder::hasWhere('orderProduct',function($query) use($productId){ return StoreOrder::hasWhere('orderProduct', function ($query) use ($productId) {
$query->where('product_id', $productId); $query->where('product_id', $productId);
}) })
->where(function($query) { ->where(function ($query) {
$query->where('is_del',0)->whereOr(function($query){ $query->where('is_del', 0)->whereOr(function ($query) {
$query->where('is_del',1)->where('paid',1); $query->where('is_del', 1)->where('paid', 1);
}); });
})->where('StoreOrder.uid',$uid)->count() })->where('StoreOrder.uid', $uid)->count();
;
} }
} }

View File

@ -377,7 +377,7 @@ class Product extends BaseModel
} }
public function content() public function content()
{ {
return $this->hasOne(ProductContent::class,'product_id','product_id'); return $this->hasOne(ProductContent::class,'product_id','product_id')->where('type',1);
} }
protected function temp() protected function temp()
{ {

View File

@ -67,6 +67,7 @@ use think\facade\Log;
use think\facade\Queue; use think\facade\Queue;
use think\facade\Route; use think\facade\Route;
use think\Model; use think\Model;
use app\controller\admin\ProductLibrary;
/** /**
* Class StoreOrderRepository * Class StoreOrderRepository
@ -143,25 +144,25 @@ class StoreOrderRepository extends BaseRepository
throw new ValidateException('未开启余额支付'); throw new ValidateException('未开启余额支付');
if ($user['now_money'] < $groupOrder['pay_price']) if ($user['now_money'] < $groupOrder['pay_price'])
throw new ValidateException('余额不足,请更换支付方式'); throw new ValidateException('余额不足,请更换支付方式');
Db::startTrans(); Db::startTrans();
try{ try {
$user->now_money = bcsub($user->now_money, $groupOrder['pay_price'], 2); $user->now_money = bcsub($user->now_money, $groupOrder['pay_price'], 2);
$user->save(); $user->save();
$userBillRepository = app()->make(UserBillRepository::class); $userBillRepository = app()->make(UserBillRepository::class);
$userBillRepository->decBill($user['uid'], 'now_money', 'pay_product', [ $userBillRepository->decBill($user['uid'], 'now_money', 'pay_product', [
'link_id' => $groupOrder['group_order_id'], 'link_id' => $groupOrder['group_order_id'],
'status' => 1, 'status' => 1,
'title' => '购买商品', 'title' => '购买商品',
'number' => $groupOrder['pay_price'], 'number' => $groupOrder['pay_price'],
'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品', 'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品',
'balance' => $user->now_money 'balance' => $user->now_money
]); ]);
$this->paySuccess($groupOrder); $this->paySuccess($groupOrder);
Db::commit(); Db::commit();
}catch (Exception $e) { } catch (Exception $e) {
Db::rollback(); Db::rollback();
throw new ValidateException('余额支付失败'); throw new ValidateException('余额支付失败');
} }
return app('json')->status('success', '余额支付成功', ['order_id' => $groupOrder['group_order_id']]); return app('json')->status('success', '余额支付成功', ['order_id' => $groupOrder['group_order_id']]);
} }
@ -261,15 +262,14 @@ class StoreOrderRepository extends BaseRepository
if ($order->activity_type == 99) { if ($order->activity_type == 99) {
$cartIdArray = explode(',', $order->cart_id); $cartIdArray = explode(',', $order->cart_id);
$ecartList = Db::name('store_cart')->whereIn('cart_id', $cartIdArray)->select(); $ecartList = Db::name('store_cart')->whereIn('cart_id', $cartIdArray)->select();
foreach($ecartList as $ecart) { foreach ($ecartList as $ecart) {
if (!empty($ecart['source_id'])) { if (!empty($ecart['source_id'])) {
Db::name('community')->where('community_id', $ecart['source_id'])->update(['entrust_order_id' => $order->order_id ?? 0]); Db::name('community')->where('community_id', $ecart['source_id'])->update(['entrust_order_id' => $order->order_id ?? 0]);
} }
} }
} }
// 订单的类型 0 发货 1 自提 // 订单的类型 0 发货 1 自提
if ($order->order_type == 1 && $order->status != 10) if ($order->order_type == 1 && $order->status != 10) {
{
$order->verify_code = $this->verifyCode(); $order->verify_code = $this->verifyCode();
} }
$order->save(); $order->save();
@ -291,8 +291,7 @@ class StoreOrderRepository extends BaseRepository
$flag = false; $flag = false;
} }
} }
if ($order->order_type == 0) if ($order->order_type == 0) {
{
//发起队列物流信息处理 //发起队列物流信息处理
//event('order.sendGoodsCode', $order); //event('order.sendGoodsCode', $order);
Queue::push(SendGoodsCodeJob::class, $order); Queue::push(SendGoodsCodeJob::class, $order);
@ -332,9 +331,8 @@ class StoreOrderRepository extends BaseRepository
$_order_rate = bcmul($_payPrice, $commission_rate, 2); $_order_rate = bcmul($_payPrice, $commission_rate, 2);
$_payPrice = bcsub($_payPrice, $_order_rate, 2); $_payPrice = bcsub($_payPrice, $_order_rate, 2);
// 结算各镇 小组佣金 // 结算各镇 小组佣金
event('order.paySuccessOrder', compact('order','_order_rate')); event('order.paySuccessOrder', compact('order', '_order_rate'));
} }
if (!$presell) { if (!$presell) {
@ -478,14 +476,14 @@ class StoreOrderRepository extends BaseRepository
Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_money', 'inc' => $groupOrder->pay_price]); Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_money', 'inc' => $groupOrder->pay_price]);
Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_num', 'inc' => 1]); Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_num', 'inc' => 1]);
app()->make(UserBrokerageRepository::class)->incMemberValue($groupOrder->uid, 'member_pay_num', $groupOrder->group_order_id); app()->make(UserBrokerageRepository::class)->incMemberValue($groupOrder->uid, 'member_pay_num', $groupOrder->group_order_id);
$groupOrder=$groupOrder->toArray(); $groupOrder = $groupOrder->toArray();
event('order.paySuccess', compact('groupOrder')); event('order.paySuccess', compact('groupOrder'));
//店内扫码支付 //店内扫码支付
if (isset($groupOrder['micro_pay']) && $groupOrder['micro_pay'] == 1) { if (isset($groupOrder['micro_pay']) && $groupOrder['micro_pay'] == 1) {
$order = $this->dao->search(['uid' => $groupOrder->uid])->where('group_order_id', $groupOrder->group_order_id)->find(); $order = $this->dao->search(['uid' => $groupOrder->uid])->where('group_order_id', $groupOrder->group_order_id)->find();
$order->status = 2; $order->status = 2;
$order->verify_time = date('Y-m-d H:i:s'); $order->verify_time = date('Y-m-d H:i:s');
$user=$order->user; $user = $order->user;
event('order.take.before', compact('order')); event('order.take.before', compact('order'));
Db::transaction(function () use ($order, $user) { Db::transaction(function () use ($order, $user) {
$this->takeAfter($order, $user); $this->takeAfter($order, $user);
@ -555,7 +553,7 @@ class StoreOrderRepository extends BaseRepository
return $cart['productAssistAttr']['assist_price']; return $cart['productAssistAttr']['assist_price'];
} else if ($cart['product_type'] == '4') { } else if ($cart['product_type'] == '4') {
return $cart['activeSku']['active_price']; return $cart['activeSku']['active_price'];
// 更新调货价格 // 更新调货价格
} else if ($cart['product_type'] == '98') { } else if ($cart['product_type'] == '98') {
// if ($cart['source_id'] > 0) { // if ($cart['source_id'] > 0) {
// $resale_find = Db::name('resale')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->find(); // $resale_find = Db::name('resale')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->find();
@ -570,12 +568,12 @@ class StoreOrderRepository extends BaseRepository
// } else { // } else {
// return $cart['productAttr']['price']; // return $cart['productAttr']['price'];
// } // }
if($cart['source']== StoreCartDao::SOURCE_PROCURE){ if ($cart['source'] == StoreCartDao::SOURCE_PROCURE) {
return $cart['productAttr']['procure_price']; return $cart['productAttr']['procure_price'];
}else{ } else {
return $cart['productAttr']['price']; return $cart['productAttr']['price'];
} }
// 更新委托价格 // 更新委托价格
} else if ($cart['product_type'] == '99') { } else if ($cart['product_type'] == '99') {
if ($cart['source_id'] > 0) { if ($cart['source_id'] > 0) {
$price = Db::name('entrust')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price'); $price = Db::name('entrust')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price');
@ -602,7 +600,7 @@ class StoreOrderRepository extends BaseRepository
return 0; return 0;
} else if ($cart['product_type'] == '4') { } else if ($cart['product_type'] == '4') {
return 0; return 0;
// 更新调货价格 // 更新调货价格
} else if ($cart['product_type'] == '98') { } else if ($cart['product_type'] == '98') {
$price = Db::name('resale')->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price'); $price = Db::name('resale')->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price');
if ($price) { if ($price) {
@ -610,7 +608,7 @@ class StoreOrderRepository extends BaseRepository
} else { } else {
return $cart['productAttr']['price']; return $cart['productAttr']['price'];
} }
// 更新委托价格 // 更新委托价格
} else if ($cart['product_type'] == '99') { } else if ($cart['product_type'] == '99') {
$price = Db::name('entrust')->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price'); $price = Db::name('entrust')->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price');
if ($price) { if ($price) {
@ -639,7 +637,7 @@ class StoreOrderRepository extends BaseRepository
* @author xaboy * @author xaboy
* @day 2020/6/10 * @day 2020/6/10
*/ */
public function userOrderNumber(int $uid, $product_type=0) public function userOrderNumber(int $uid, $product_type = 0)
{ {
//activity_type0普通订单 98采购订单 99委托商品 //activity_type0普通订单 98采购订单 99委托商品
//$noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid, $product_type); //$noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid, $product_type);
@ -841,14 +839,14 @@ class StoreOrderRepository extends BaseRepository
if ($order['status'] != 1 || $order['order_type']) if ($order['status'] != 1 || $order['order_type'])
throw new ValidateException('订单状态有误'); throw new ValidateException('订单状态有误');
$func = 'createUserLog'; $func = 'createUserLog';
if (!$user){ if (!$user) {
$func = 'createSysLog'; $func = 'createSysLog';
$user = $order->user; $user = $order->user;
} }
// if (!$user) { // if (!$user) {
// //
// throw new ValidateException('用户不存在'); // throw new ValidateException('用户不存在');
// } // }
$order->status = 2; $order->status = 2;
$order->verify_time = date('Y-m-d H:i:s'); $order->verify_time = date('Y-m-d H:i:s');
event('order.take.before', compact('order')); event('order.take.before', compact('order'));
@ -861,7 +859,7 @@ class StoreOrderRepository extends BaseRepository
'change_message' => '已收货', 'change_message' => '已收货',
'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE, 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE,
]; ];
Db::transaction(function () use ($order, $user,$storeOrderStatusRepository,$orderStatus,$func) { Db::transaction(function () use ($order, $user, $storeOrderStatusRepository, $orderStatus, $func) {
$this->takeAfter($order, $user); $this->takeAfter($order, $user);
$order->save(); $order->save();
$storeOrderStatusRepository->{$func}($orderStatus); $storeOrderStatusRepository->{$func}($orderStatus);
@ -878,14 +876,14 @@ class StoreOrderRepository extends BaseRepository
* @param int|null $orderType * @param int|null $orderType
* @return array * @return array
*/ */
public function OrderTitleNumber(?int $merId, ?int $orderType, ?int $product_type=0) public function OrderTitleNumber(?int $merId, ?int $orderType, ?int $product_type = 0)
{ {
$where = []; $where = [];
$sysDel = $merId ? 0 : null; //商户删除 $sysDel = $merId ? 0 : null; //商户删除
if ($merId) $where['mer_id'] = $merId; //商户订单 if ($merId) $where['mer_id'] = $merId; //商户订单
if ($orderType === 0) $where['order_type'] = 0; //普通订单 if ($orderType === 0) $where['order_type'] = 0; //普通订单
if ($orderType === 1) $where['take_order'] = 1; //已核销订单 if ($orderType === 1) $where['take_order'] = 1; //已核销订单
if ($product_type!=0) $where['product_type'] = $product_type; //商品属性 if ($product_type != 0) $where['product_type'] = $product_type; //商品属性
//1: 未支付 2: 未发货 3: 待收货 4: 待评价 5: 交易完成 6: 已退款 7: 已删除 8: 已支付 //1: 未支付 2: 未发货 3: 待收货 4: 待评价 5: 交易完成 6: 已退款 7: 已删除 8: 已支付
$all = $this->dao->search($where, $sysDel)->where($this->getOrderType(0))->count(); $all = $this->dao->search($where, $sysDel)->where($this->getOrderType(0))->count();
$statusAll = $all; $statusAll = $all;
@ -961,7 +959,7 @@ class StoreOrderRepository extends BaseRepository
$param['StoreOrder.paid'] = 1; $param['StoreOrder.paid'] = 1;
break; // 已支付 break; // 已支付
case 20: case 20:
$param['StoreOrder.status'] =[2,3]; $param['StoreOrder.status'] = [2, 3];
break; // 已收货的商品才可以继续导入 break; // 已收货的商品才可以继续导入
default: default:
unset($param['StoreOrder.is_del']); unset($param['StoreOrder.is_del']);
@ -1089,7 +1087,7 @@ class StoreOrderRepository extends BaseRepository
'change_type' => $storeOrderStatusRepository::ORDER_STATUS_CHANGE, 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_CHANGE,
]; ];
Db::transaction(function () use ($id, $data, $orderGroup, $order, $_group,$storeOrderStatusRepository,$orderStatus,$service_id) { Db::transaction(function () use ($id, $data, $orderGroup, $order, $_group, $storeOrderStatusRepository, $orderStatus, $service_id) {
$orderGroup->total_price = $_group['total_price']; $orderGroup->total_price = $_group['total_price'];
$orderGroup->pay_price = $_group['pay_price']; $orderGroup->pay_price = $_group['pay_price'];
$orderGroup->pay_postage = $_group['pay_postage']; $orderGroup->pay_postage = $_group['pay_postage'];
@ -1100,7 +1098,7 @@ class StoreOrderRepository extends BaseRepository
$this->changOrderProduct($id, $data); $this->changOrderProduct($id, $data);
if ($service_id) { if ($service_id) {
$storeOrderStatusRepository->createServiceLog($service_id,$orderStatus); $storeOrderStatusRepository->createServiceLog($service_id, $orderStatus);
} else { } else {
$storeOrderStatusRepository->createAdminLog($orderStatus); $storeOrderStatusRepository->createAdminLog($orderStatus);
} }
@ -1239,7 +1237,7 @@ class StoreOrderRepository extends BaseRepository
'mer_id' => $merId 'mer_id' => $merId
]; ];
if (!$ret || $ret['status'] != 1 || $ret['mer_id'] != $merId || $ret['is_del'] != 0 || $ret['paid'] != 1 || $ret['delivery_type'] != 0 ) { if (!$ret || $ret['status'] != 1 || $ret['mer_id'] != $merId || $ret['is_del'] != 0 || $ret['paid'] != 1 || $ret['delivery_type'] != 0) {
$imp['status'] = 0; $imp['status'] = 0;
$imp['mark'] = '订单信息不存在或状态错误'; $imp['mark'] = '订单信息不存在或状态错误';
} else { } else {
@ -1257,7 +1255,7 @@ class StoreOrderRepository extends BaseRepository
$imp['delivery_id'] = $ret['delivery_id']; $imp['delivery_id'] = $ret['delivery_id'];
$imp['delivery_name'] = $ret['delivery_name']; $imp['delivery_name'] = $ret['delivery_name'];
} else { } else {
$this->delivery($item, $merId,[ $this->delivery($item, $merId, [
'delivery_id' => $params['delivery_id'], 'delivery_id' => $params['delivery_id'],
'delivery_type' => $params['delivery_type'], 'delivery_type' => $params['delivery_type'],
'delivery_name' => $params['delivery_name'], 'delivery_name' => $params['delivery_name'],
@ -1315,7 +1313,7 @@ class StoreOrderRepository extends BaseRepository
'to_name' => $data['to_name'], 'to_name' => $data['to_name'],
]; ];
Db::transaction(function () use ($merId, $id, $delivery, $make, $dump, $service_id) { Db::transaction(function () use ($merId, $id, $delivery, $make, $dump, $service_id) {
$this->delivery($id, $merId, $delivery,$service_id); $this->delivery($id, $merId, $delivery, $service_id);
$arr = [ $arr = [
'type' => 'mer_dump', 'type' => 'mer_dump',
'num' => -1, 'num' => -1,
@ -1327,22 +1325,22 @@ class StoreOrderRepository extends BaseRepository
return $delivery; return $delivery;
} }
public function runDelivery($id, $merId, $data, $split, $method,$service_id = 0) public function runDelivery($id, $merId, $data, $split, $method, $service_id = 0)
{ {
return Db::transaction(function () use ($id, $merId, $data, $split, $method,$service_id) { return Db::transaction(function () use ($id, $merId, $data, $split, $method, $service_id) {
if ($split['is_split'] && !empty($split['split'])) { if ($split['is_split'] && !empty($split['split'])) {
foreach ($split['split'] as $v) { foreach ($split['split'] as $v) {
$splitData[$v['id']] = $v['num']; $splitData[$v['id']] = $v['num'];
} }
$order = $this->dao->get($id); $order = $this->dao->get($id);
$newOrder = app()->make(StoreOrderSplitRepository::class)->splitOrder($order, $splitData,$service_id); $newOrder = app()->make(StoreOrderSplitRepository::class)->splitOrder($order, $splitData, $service_id);
if ($newOrder){ if ($newOrder) {
$id = $newOrder->order_id; $id = $newOrder->order_id;
} else { } else {
throw new ValidateException('商品不能全部拆单'); throw new ValidateException('商品不能全部拆单');
} }
} }
return $this->{$method}($id, $merId, $data,$service_id); return $this->{$method}($id, $merId, $data, $service_id);
}); });
} }
@ -1403,17 +1401,17 @@ class StoreOrderRepository extends BaseRepository
'change_type' => $change_type, 'change_type' => $change_type,
]; ];
if ($service_id) { if ($service_id) {
$statusRepository->createServiceLog($service_id,$orderStatus); $statusRepository->createServiceLog($service_id, $orderStatus);
} else { } else {
$statusRepository->createAdminLog($orderStatus); $statusRepository->createAdminLog($orderStatus);
} }
//虚拟发货后用户直接确认收获 //虚拟发货后用户直接确认收获
if($data['status'] == 2){ if ($data['status'] == 2) {
$user = app()->make(UserRepository::class)->get($order['uid']); $user = app()->make(UserRepository::class)->get($order['uid']);
//订单记录 //订单记录
$this->takeAfter($order,$user); $this->takeAfter($order, $user);
$orderStatus = [ $orderStatus = [
'order_id' => $order->order_id, 'order_id' => $order->order_id,
'order_sn' => $order->order_sn, 'order_sn' => $order->order_sn,
@ -1422,7 +1420,6 @@ class StoreOrderRepository extends BaseRepository
'change_type' => $statusRepository::ORDER_STATUS_TAKE, 'change_type' => $statusRepository::ORDER_STATUS_TAKE,
]; ];
$statusRepository->createSysLog($orderStatus); $statusRepository->createSysLog($orderStatus);
} }
if (isset($temp_code)) Queue::push(SendSmsJob::class, ['tempId' => $temp_code, 'id' => $order->order_id]); if (isset($temp_code)) Queue::push(SendSmsJob::class, ['tempId' => $temp_code, 'id' => $order->order_id]);
@ -1447,7 +1444,7 @@ class StoreOrderRepository extends BaseRepository
$make->create($id, $merId, $data, $order); $make->create($id, $merId, $data, $order);
//订单记录 //订单记录
$storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
$this->dao->update($id, ['delivery_type' => 5, 'status' => 1,'remark' => $data['remark']]); $this->dao->update($id, ['delivery_type' => 5, 'status' => 1, 'remark' => $data['remark']]);
$orderStatus = [ $orderStatus = [
'order_id' => $id, 'order_id' => $id,
@ -1457,7 +1454,7 @@ class StoreOrderRepository extends BaseRepository
'change_type' => $storeOrderStatusRepository::ORDER_DELIVERY_SELF, 'change_type' => $storeOrderStatusRepository::ORDER_DELIVERY_SELF,
]; ];
if ($service_id) { if ($service_id) {
$storeOrderStatusRepository->createServiceLog($service_id,$orderStatus); $storeOrderStatusRepository->createServiceLog($service_id, $orderStatus);
} else { } else {
$storeOrderStatusRepository->createAdminLog($orderStatus); $storeOrderStatusRepository->createAdminLog($orderStatus);
} }
@ -1473,21 +1470,24 @@ class StoreOrderRepository extends BaseRepository
$whre['mer_id'] = $merId; $whre['mer_id'] = $merId;
$whre['is_system_del'] = 0; $whre['is_system_del'] = 0;
} }
$res = $this->dao->getWhere($where, '*', [ $res = $this->dao->getWhere(
'orderProduct', $where,
'user' => function ($query) { '*',
$query->field('uid,real_name,nickname,is_svip,svip_endtime,phone'); [
}, 'orderProduct',
'refundOrder' => function ($query) { 'user' => function ($query) {
$query->field('order_id,extension_one,extension_two,refund_price,integral')->where('status', 3); $query->field('uid,real_name,nickname,is_svip,svip_endtime,phone');
}, },
'finalOrder', 'refundOrder' => function ($query) {
'TopSpread' => function ($query) { $query->field('order_id,extension_one,extension_two,refund_price,integral')->where('status', 3);
$query->field('uid,nickname,avatar'); },
}, 'finalOrder',
'spread' => function ($query) { 'TopSpread' => function ($query) {
$query->field('uid,nickname,avatar'); $query->field('uid,nickname,avatar');
}, },
'spread' => function ($query) {
$query->field('uid,nickname,avatar');
},
] ]
); );
if (!$res) throw new ValidateException('数据不存在'); if (!$res) throw new ValidateException('数据不存在');
@ -1609,17 +1609,17 @@ class StoreOrderRepository extends BaseRepository
]); ]);
$count = $query->count(); $count = $query->count();
$list = $query->page($page, $limit)->select()->append(['refund_extension_one', 'refund_extension_two']) $list = $query->page($page, $limit)->select()->append(['refund_extension_one', 'refund_extension_two'])
->each(function($item){ ->each(function ($item) {
// 1:退款中 2:部分退款 3 = 全退 // 1:退款中 2:部分退款 3 = 全退
$refunding = 0; $refunding = 0;
if ($item['orderProduct']) { if ($item['orderProduct']) {
$is_refund = array_column($item['orderProduct']->toArray(),'is_refund'); $is_refund = array_column($item['orderProduct']->toArray(), 'is_refund');
$is_refund = array_unique($is_refund); $is_refund = array_unique($is_refund);
if (in_array(1,$is_refund)) { if (in_array(1, $is_refund)) {
$refunding = 1; $refunding = 1;
} else if (in_array(2,$is_refund)) { } else if (in_array(2, $is_refund)) {
$refunding = 2; $refunding = 2;
} else if (in_array(3,$is_refund)) { } else if (in_array(3, $is_refund)) {
$refunding = 3; $refunding = 3;
} }
} }
@ -1773,7 +1773,7 @@ class StoreOrderRepository extends BaseRepository
if ($status == 1) { if ($status == 1) {
$query = $this->dao->search($where)->where($this->getOrderType($status))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where('StoreOrder.is_del', 0); $query = $this->dao->search($where)->where($this->getOrderType($status))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where('StoreOrder.is_del', 0);
} else { } else {
$arr=$this->getOrderType($status); $arr = $this->getOrderType($status);
$query = $this->dao->search($where)->where($arr)->where('StoreOrder.is_del', 0); $query = $this->dao->search($where)->where($arr)->where('StoreOrder.is_del', 0);
} }
@ -1813,10 +1813,11 @@ class StoreOrderRepository extends BaseRepository
unset($order['takeOrderList'], $order->interest); unset($order['takeOrderList'], $order->interest);
} }
return compact( 'count','list'); return compact('count', 'list');
} }
public function getOrderStatusV2($order) { public function getOrderStatusV2($order)
{
//订单状态 1 未支付 2待发货 3待收货 4待评价 5交易完成 6已退款 7待核销 8先货后款待结算 9待商家确认 //订单状态 1 未支付 2待发货 3待收货 4待评价 5交易完成 6已退款 7待核销 8先货后款待结算 9待商家确认
$order->order_status = 0; $order->order_status = 0;
if ($order->paid == 0) { if ($order->paid == 0) {
@ -1998,8 +1999,11 @@ class StoreOrderRepository extends BaseRepository
public function verifyOrder(int $id, int $merId, array $data, $serviceId = 0) public function verifyOrder(int $id, int $merId, array $data, $serviceId = 0)
{ {
$order = $this->dao->getWhere(['order_id' => $id, 'mer_id' => $merId,'verify_code' => $data['verify_code'],'order_type' => 1],'*',['orderProduct']); $order = $this->dao->getWhere(['order_id' => $id, 'mer_id' => $merId, 'order_type' => 1], '*', ['orderProduct']);
if (!$order) throw new ValidateException('订单不存在'); if (!$order) throw new ValidateException('订单不存在');
if ($order['verify_code'] != $data['verify_code']) {
throw new ValidateException('核销码不正确');
}
if (!$order->paid) throw new ValidateException('订单未支付'); if (!$order->paid) throw new ValidateException('订单未支付');
if ($order['status']) throw new ValidateException('订单已全部核销,请勿重复操作'); if ($order['status']) throw new ValidateException('订单已全部核销,请勿重复操作');
foreach ($data['data'] as $v) { foreach ($data['data'] as $v) {
@ -2013,7 +2017,7 @@ class StoreOrderRepository extends BaseRepository
event('order.verify.before', compact('order')); event('order.verify.before', compact('order'));
//订单记录 //订单记录
$storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
Db::transaction(function () use ($order,$storeOrderStatusRepository,$serviceId) { Db::transaction(function () use ($order, $storeOrderStatusRepository, $serviceId) {
$this->takeAfter($order, $order->user); $this->takeAfter($order, $order->user);
$order->save(); $order->save();
$orderStatus = [ $orderStatus = [
@ -2023,12 +2027,11 @@ class StoreOrderRepository extends BaseRepository
'change_message' => '订单已核销', 'change_message' => '订单已核销',
'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE, 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE,
]; ];
if ($serviceId){ if ($serviceId) {
$storeOrderStatusRepository->createServiceLog($serviceId,$orderStatus); $storeOrderStatusRepository->createServiceLog($serviceId, $orderStatus);
} else { } else {
$storeOrderStatusRepository->createAdminLog($orderStatus); $storeOrderStatusRepository->createAdminLog($orderStatus);
} }
}); });
event('order.verify', compact('order')); event('order.verify', compact('order'));
} }
@ -2245,7 +2248,6 @@ class StoreOrderRepository extends BaseRepository
if (count($couponId)) { if (count($couponId)) {
app()->make(StoreCouponUserRepository::class)->updates($couponId, ['status' => 0]); app()->make(StoreCouponUserRepository::class)->updates($couponId, ['status' => 0]);
} }
} }
//订单记录 //订单记录
$storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
@ -2292,7 +2294,7 @@ class StoreOrderRepository extends BaseRepository
'change_type' => $storeOrderStatusRepository::ORDER_STATUS_DELETE, 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_DELETE,
]; ];
$productRepository = app()->make(ProductRepository::class); $productRepository = app()->make(ProductRepository::class);
Db::transaction(function () use ($info, $order, $orderStatus, $storeOrderStatusRepository,$productRepository) { Db::transaction(function () use ($info, $order, $orderStatus, $storeOrderStatusRepository, $productRepository) {
$order->is_del = 1; $order->is_del = 1;
$order->save(); $order->save();
$storeOrderStatusRepository->createUserLog($orderStatus); $storeOrderStatusRepository->createUserLog($orderStatus);
@ -2476,18 +2478,18 @@ class StoreOrderRepository extends BaseRepository
* @author Qinii * @author Qinii
* @day 2023/2/22 * @day 2023/2/22
*/ */
public function childrenList($id,$merId) public function childrenList($id, $merId)
{ {
$data = $this->dao->get($id); $data = $this->dao->get($id);
$query = $this->dao->getSearch([])->with(['orderProduct'])->where('order_id','<>',$id); $query = $this->dao->getSearch([])->with(['orderProduct'])->where('order_id', '<>', $id);
if ($merId) $query->where('mer_id',$merId); if ($merId) $query->where('mer_id', $merId);
if ($data['main_id']) { if ($data['main_id']) {
$query->where(function($query) use($data,$id){ $query->where(function ($query) use ($data, $id) {
$query->where('main_id',$data['main_id'])->whereOr('order_id',$data['main_id']); $query->where('main_id', $data['main_id'])->whereOr('order_id', $data['main_id']);
}); });
} else { } else {
$query->where('main_id',$id); $query->where('main_id', $id);
} }
return $query->select(); return $query->select();
} }
@ -2499,107 +2501,260 @@ class StoreOrderRepository extends BaseRepository
* @throws DbException * @throws DbException
* @throws ModelNotFoundException * @throws ModelNotFoundException
*/ */
public function setProduct(array $arrary, $merId) public function setProduct(array $arrary, $merId,$type_id=0)
{ {
//读取excel //读取excel
$data = SpreadsheetExcelService::instance()->_import($arrary['path'], $arrary['sql'], $arrary['where'], 1); $data = SpreadsheetExcelService::instance()->_import($arrary['path'], $arrary['sql'], $arrary['where'], 1);
if (!$data) return false; if (!$data) return false;
unset($data[0]); unset($data[0]);
$mer_cate_id=Db::name('store_category')->where('mer_id',$merId)->where('cate_name','默认分类')->value('store_category_id'); // $mer_cate_id = Db::name('store_category')->where('mer_id', $merId)->where('cate_name', '默认分类')->value('store_category_id');
if (!$mer_cate_id ||$mer_cate_id==0){ // if (!$mer_cate_id || $mer_cate_id == 0) {
$mer_cate=['pid'=>0,'cate_name'=>'默认分类','path'=>'/','mer_id'=>$merId,'sort'=>0,'is_show'=>1,'create_time'=>date('Y-m-d H:i:s')]; // $mer_cate = ['pid' => 0, 'cate_name' => '默认分类', 'path' => '/', '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); // $mer_cate_id = Db::name('store_category')->insertGetId($mer_cate);
$mer_cate['pid']=$mer_cate_id; // $mer_cate['pid'] = $mer_cate_id;
$mer_cate['path']='/'.$mer_cate_id.'/'; // $mer_cate['path'] = '/' . $mer_cate_id . '/';
$mer_cate['level']=1; // $mer_cate['level'] = 1;
$mer_cate_id=Db::name('store_category')->insertGetId($mer_cate); // $mer_cate_id = Db::name('store_category')->insertGetId($mer_cate);
// }
// $typeCode = Db::name('merchant_type')->where('mer_type_id', $merId)->value('type_code');
$product_type = 0;
if ($type_id == 12) {
$product_type = 98; //供应链
} }
// $type=Db::name('merchant')->where('mer_id',$merId)->value('type_id'); try {
$typeCode=Db::name('merchant_type')->where('mer_type_id',$merId)->value('type_code'); foreach ($data as $datum) {
$product_type=0;
// if ($type==12){ $find = Db::name('store_product')->where('mer_id', $merId)->where('store_name', $datum['value']['store_name'])->find();
if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ $attr_one = explode('|', $datum['value']['attr_one']);
$product_type=98;//供应链 $attr_two = explode('|', $datum['value']['attr_two']);
} $attr = [];
foreach ($data as $datum) { $arr = [];
// $find=Db::name('store_product')->where('mer_id', $merId)->where('bar_code', $datum['where']['bar_code'])->find(); foreach ($attr_one as $key => $value) {
// if ($find){ $attr[$value] = $attr_two[$key];
// Db::name('store_product')->where('product_id', $find['product_id'])->update($datum['value']); $arr[] = [
// }else{ 'value' => $value,
$store_category_id=Db::name('store_category')->where('mer_id',0)->where('cate_name',$datum['value']['cate_id'])->value('store_category_id'); 'detail' => [$attr_two[$key] ?? []],
if ($store_category_id==null){ 'inputVisible' => false
$store_category_id=438; ];
} }
$datas = [ $array_values = array_values($attr);
"image" => "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png", if ($find) {
"slider_image" => [ $store_product_attr_value = Db::name('store_product_attr_value')->where('product_id', $find['product_id'])->where('bar_code', $datum['value']['bar_code'])->find();
0 => "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png", if ($store_product_attr_value) {
],
"store_name" => $datum['value']['store_name'].' '.$datum['value']['specifications'], $datas['product_id'] = $find['product_id'];
"store_info" => $datum['value']['store_name'], $datas['mer_id'] = $merId;
"keyword" => $datum['value']['keyword'], $datas['store_name'] = $datum['value']['store_name'];
"bar_code" => $datum['value']['bar_code'], $datas['content'] = 'xls导入商品:已经导入过该规格了';
"guarantee_template_id" => "", $this->create_product_import_log($datas,0);
"cate_id" => $store_category_id,//要修改 continue;
"mer_cate_id" => [ }
0 => $mer_cate_id//要修改 $is_update = false;
], foreach ($attr as $kk => $vv) {
'product_type'=>$product_type,
"unit_name" => $datum['value']['unit_name'], /**查询当前规格是否存在 */
"sort" => 0, $attr_values_find = Db::name('store_product_attr')->where('product_id', $find['product_id'])->where('attr_name', $kk)
"is_show" => "", ->find();
"is_good" => 0, if ($attr_values_find) {
"is_gift_bag" => 0, $attr_values = $attr_values_find['attr_values'];
"integral_rate" => -1, $attr_values = explode('-!-', $attr_values);
"video_link" => "", if (!in_array($vv, $attr_values)) {
"temp_id" => "", $attr_values[] = $vv;
"content" => "", $attr_values = implode('-!-', $attr_values);
"spec_type" => 0, Db::name('store_product_attr')->where('product_id', $find['product_id'])->where('attr_name', $kk)->update(['attr_values' => $attr_values]);
"extension_type" => 0, $this->create_product_attr_value($find, $datum, $product_type, $attr, $merId, implode(',', $array_values));
"attr" => [], }
"mer_labels" => [], $is_update = true;
"delivery_way" => [ } else {
0 => "2" $datas = [
], 'product_id' => $find['product_id'],
"delivery_free" => 1, 'attr_name' => $kk, 'attr_values' => $vv,
"param_temp_id" => [], ];
"extend" => [], Db::name('store_product_attr')->insert($datas);
"brand_id" => "", }
"once_max_count" => 0, }
"once_min_count" => 0, if ($is_update == false) {
"pay_limit" => 0, $this->create_product_attr_value($find, $datum, $product_type, $attr, $merId, implode(',', $array_values));
"attrValue" => [ }
[ } else {
"image" => "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png", //默认其他分类
"price" => $datum['value']['price'], $cate_id = 1726;
"cost" => $datum['value']['price'], $spec_type = 1;
"ot_price" => $datum['value']['price'], $detail = $attr;
"svip_price" => null,
"stock" => $datum['value']['stock'], /**查询平台分类 */
"bar_code" => $datum['value']['bar_code'], $cate_id_one = Db::name('store_category')->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_one'])->value('store_category_id');
"weight" => 0, if ($cate_id_one) {
"volume" => 0, $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 {
$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) {
$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",
];
}
$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,
"give_coupon_ids" => [], "unit_name" => $datum['value']['unit_name'],
"type" => 0, "sort" => 0,
"svip_price" => 0, "is_show" => "",
"svip_price_type" => 0, "is_good" => 0,
"params" => [], "is_gift_bag" => 0,
"mer_id" => $merId, "integral_rate" => -1,
"status" => 1, "video_link" => "",
"mer_status" => 1, "temp_id" => "",
"rate" => 3, "content" => "",
]; "spec_type" => $spec_type,
$data_list=[ "extension_type" => 0,
'data'=>$datas, "attr" => $arr,
'product_type'=>$product_type, "mer_labels" => [],
]; "delivery_way" => [
Queue::push(ProductImportJob::class,$data_list); 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" => $datum['value']['procure_price'] ?? 0,
"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,
];
// $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);
}
}
} 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();
$this->create_product_import_log($datas, 0);
} }
return true; return true;
} }
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);
}
public function create_product_attr_value($find, $datum, $product_type, $attr_values, $merId, $sku)
{
$attrValue['stock'] = 1;
$unique = app(ProductRepository::class)->setUnique($find['product_id'], $datum['value']['bar_code'], $product_type);
$attrValue['unique'] = $unique;
$attrValue['detail'] = json_encode($attr_values);
$attrValue['product_id'] = $find['product_id'];
$attrValue['mer_id'] = $merId;
$attrValue['sku'] = $sku;
$attrValue['cost'] = $datum['value']['cost'];
$attrValue['ot_price'] = $datum['value']['price'];
$attrValue['price'] = $datum['value']['price'];
$attrValue['procure_price'] = $datum['value']['procure_price'];
$attrValue["image"] = "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png";
Db::name('store_product_attr_value')->insert($attrValue);
}
/** /**
* 订单结算 * 订单结算
* @param $id * @param $id
@ -2781,7 +2936,7 @@ class StoreOrderRepository extends BaseRepository
* @param $orderSn * @param $orderSn
* 更新扫描发货状态 * 更新扫描发货状态
*/ */
public function deliveryGoods($orderId, $orderSn, $logisticsCode='') public function deliveryGoods($orderId, $orderSn, $logisticsCode = '')
{ {
if ($logisticsCode) { if ($logisticsCode) {
$order = $this->dao->search([], null)->where('order_sn', $orderSn)->where('order_id', $orderId)->where('logistics_code', $logisticsCode)->where('StoreOrder.status', 1)->where('StoreOrder.is_del', 0)->find(); $order = $this->dao->search([], null)->where('order_sn', $orderSn)->where('order_id', $orderId)->where('logistics_code', $logisticsCode)->where('StoreOrder.status', 1)->where('StoreOrder.is_del', 0)->find();
@ -2803,5 +2958,4 @@ class StoreOrderRepository extends BaseRepository
} }
$order->save(); $order->save();
} }
} }

View File

@ -239,7 +239,9 @@ class ProductRepository extends BaseRepository
$result = $this->dao->create($product); $result = $this->dao->create($product);
$settleParams = $this->setAttrValue($data, $result->product_id, $productType, 0, $data['mer_id']); $settleParams = $this->setAttrValue($data, $result->product_id, $productType, 0, $data['mer_id']);
// $settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $result->product_id, $data['mer_id']); if(isset($data['mer_cate_id']) &&$data['mer_cate_id']!=0){
$settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $result->product_id, $data['mer_id']);
}
$settleParams['attr'] = $this->setAttr($data['attr'], $result->product_id); $settleParams['attr'] = $this->setAttr($data['attr'], $result->product_id);
if (in_array($productType, [0, 98, 99])) app()->make(ParameterValueRepository::class)->create($result->product_id, $data['params'] ?? [], $data['mer_id']); if (in_array($productType, [0, 98, 99])) app()->make(ParameterValueRepository::class)->create($result->product_id, $data['params'] ?? [], $data['mer_id']);
$this->save($result->product_id, $settleParams, $content, $product, $productType); $this->save($result->product_id, $settleParams, $content, $product, $productType);
@ -284,8 +286,9 @@ class ProductRepository extends BaseRepository
$spuData['price'] = $settleParams['data']['price']; $spuData['price'] = $settleParams['data']['price'];
$spuData['mer_id'] = $merId; $spuData['mer_id'] = $merId;
$spuData['mer_labels'] = $data['mer_labels']; $spuData['mer_labels'] = $data['mer_labels'];
Db::transaction(function () use ($id, $data, $productType, $settleParams, $content, $product, $spuData, $merId) { Db::startTrans();
$this->save($id, $settleParams, $content, $product, $productType); try{
$res=$this->save($id, $settleParams, $content, $product, $productType);
// if ($productType == 1) { //秒杀商品 // if ($productType == 1) { //秒杀商品
// $dat = $this->setSeckillProduct($data); // $dat = $this->setSeckillProduct($data);
// app()->make(StoreSeckillActiveRepository::class)->updateByProduct($id, $dat); // app()->make(StoreSeckillActiveRepository::class)->updateByProduct($id, $dat);
@ -300,8 +303,13 @@ class ProductRepository extends BaseRepository
if ($data['status'] == 0) { if ($data['status'] == 0) {
event('product.sell', ['product_id' => [$id]]); event('product.sell', ['product_id' => [$id]]);
} }
app()->make(SpuRepository::class)->changeStatus($id, $productType); app()->make(SpuRepository::class)->changeStatus($id, $productType);
}); Db::commit();
return $res;
}catch(\Exception $e){
Db::rollback();
return false;
}
} }
public function freeTrial(int $id, array $data, int $merId) public function freeTrial(int $id, array $data, int $merId)
@ -829,11 +837,11 @@ class ProductRepository extends BaseRepository
break; break;
} }
if ($productType == 0) { if ($productType == 0) {
$where[] = empty($merId) ? ['product_type', 'in', [0, 98, 99]] : ['product_type', 'in', [0]]; $where['product_type'] = $productType;
if (!$merId) $where['is_gift_bag'] = 0; if (!$merId) $where['is_gift_bag'] = 0;
} }
if ($productType == 1) { if ($productType == 1 ||$productType==98) {
$where[] = ['product_type', 'in', [$productType]]; $where['product_type'] = $productType;
} }
if ($productType == 10) { if ($productType == 10) {
$where['is_gift_bag'] = 1; $where['is_gift_bag'] = 1;

View File

@ -90,7 +90,7 @@ class SpuRepository extends BaseRepository
'keyword' => $param['keyword'] ?? '', 'keyword' => $param['keyword'] ?? '',
'image' => $param['image'], 'image' => $param['image'],
'price' => $param['price'], 'price' => $param['price'],
'status' => 0, 'status' => $param['status']??0,
'rank' => $param['rank'] ?? 0, 'rank' => $param['rank'] ?? 0,
'temp_id' => $param['temp_id'], 'temp_id' => $param['temp_id'],
'sort' => $param['sort'] ?? 0, 'sort' => $param['sort'] ?? 0,

View File

@ -129,6 +129,7 @@ class ProductLibrary extends BaseController
$data['create_time'] = date('Y-m-d H:i:s'); $data['create_time'] = date('Y-m-d H:i:s');
$data['images'] = ''; $data['images'] = '';
$arr=[]; $arr=[];
if ($param['img'] != '') { if ($param['img'] != '') {
$oss = $upload->to($dir)->stream(file_get_contents($param['img'])); $oss = $upload->to($dir)->stream(file_get_contents($param['img']));
$data['image'] = $oss->filePath; $data['image'] = $oss->filePath;
@ -165,12 +166,11 @@ class ProductLibrary extends BaseController
throw new \think\exception\ValidateException('添加失败'); throw new \think\exception\ValidateException('添加失败');
} }
} else { } else {
Log::error('一维码商品采集错误:' . $result['data']['remark']);
Log::error('商品采集错误:' . $result['message']); throw new \think\exception\ValidateException('一维码商品采集错误:'. $result['data']['remark']);
throw new \think\exception\ValidateException($result['message']);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new \think\exception\ValidateException($e->getMessage()); throw new \think\exception\ValidateException('一维码商品采集错误:'.$e->getMessage());
} }
} }
} }

View File

@ -244,7 +244,14 @@ class Merchant extends BaseController
if (!$this->repository->exists($id)) if (!$this->repository->exists($id))
return app('json')->fail('数据不存在'); return app('json')->fail('数据不存在');
$admins=$this->request->adminInfo(); $admins=$this->request->adminInfo();
if($admins['admin_id']!=1){ $admin_arr=explode(',',env('MERCHANT_Arr'));
$is_true=false;
foreach ($admins['roles'] as $k=>$v){
if(in_array($v,$admin_arr)){
$is_true=true;
}
}
if($admins['admin_id']!=1 && $is_true==false){
$adminInfo = $adminRepository->merIdByAdmin($id,['account'=>'yy'.$admins['account']],2); $adminInfo = $adminRepository->merIdByAdmin($id,['account'=>'yy'.$admins['account']],2);
if(!$adminInfo){ if(!$adminInfo){
$pwd =password_hash(rand(100000,999999), PASSWORD_BCRYPT); $pwd =password_hash(rand(100000,999999), PASSWORD_BCRYPT);

View File

@ -34,7 +34,6 @@ use crmeb\services\SmsService;
use crmeb\services\WechatService; use crmeb\services\WechatService;
use crmeb\services\WechatTemplateMessageService; use crmeb\services\WechatTemplateMessageService;
use Exception; use Exception;
use Firebase\JWT\JWT;
use Gregwar\Captcha\CaptchaBuilder; use Gregwar\Captcha\CaptchaBuilder;
use Gregwar\Captcha\PhraseBuilder; use Gregwar\Captcha\PhraseBuilder;
use Overtrue\Socialite\AccessToken; use Overtrue\Socialite\AccessToken;
@ -57,6 +56,11 @@ use app\common\service\TopClient;
use app\controller\api\Ceshi; use app\controller\api\Ceshi;
use taobao\request\TbkItemInfoGetRequest; use taobao\request\TbkItemInfoGetRequest;
use app\common\repositories\store\product\ProductRepository; use app\common\repositories\store\product\ProductRepository;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use Firebase\JWT\SignatureInvalidException;
use Firebase\JWT\BeforeValidException;
use Firebase\JWT\ExpiredException;
use think\facade\App; use think\facade\App;
/** /**
@ -67,6 +71,39 @@ use think\facade\App;
*/ */
class Auth extends BaseController class Auth extends BaseController
{ {
public function parseToken(UserRepository $repository)
{
$token = $this->request->param('token');
$app_key = 'ae47e94a7dcd1fdfacb499b60e361a8d';
try {
JWT::$leeway = 10; //当前时间减去10秒时间留点余地
// jwt ^5.0
// $decoded = JWT::decode($token, Config::get('app.app_key', 'default'), array('HS256'));
// jwt ^6.9
// $decoded = JWT::decode($token, new Key(env('app.app_key', '123456'), 'HS256'));
$decoded = JWT::decode($token, new Key($app_key, 'HS256'));
$decodedArray = json_decode(json_encode($decoded), true);
$jwtData = $decodedArray['data'] ?? [];
if (empty($jwtData['phone'])) {
return app('json')->fail('解析数据缺少phone');
}
$user = $repository->accountByUser($jwtData['phone']);
$user_type = 'app';
if (!$user) $user = $repository->registr($jwtData['phone'], null, $user_type);
$user = $repository->mainUser($user);
$tokenInfo = $repository->createToken($user);
$repository->loginAfter($user);
return app('json')->success($repository->returnToken($user, $tokenInfo));
} catch(\Firebase\JWT\SignatureInvalidException $e) {
return app('json')->fail('签名错误');
} catch(\Firebase\JWT\BeforeValidException $e) {
return app('json')->fail('token无效');
} catch(\Firebase\JWT\ExpiredException $e) {
return app('json')->fail('token已过期');
} catch(\Exception $e) {
return app('json')->fail('非法请求');
}
}
public function caiji() public function caiji()
{ {
$url=$this->request->host(); $url=$this->request->host();

View File

@ -42,6 +42,7 @@ use crmeb\services\WechatService;
use Exception; use Exception;
use Joypack\Tencent\Map\Bundle\Location; use Joypack\Tencent\Map\Bundle\Location;
use Joypack\Tencent\Map\Bundle\LocationOption; use Joypack\Tencent\Map\Bundle\LocationOption;
use Overtrue\Pinyin\Pinyin;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\facade\Cache; use think\facade\Cache;
use think\facade\Db; use think\facade\Db;
@ -161,8 +162,8 @@ class Common extends BaseController
$file = is_array($file) ? $file[0] : $file; $file = is_array($file) ? $file[0] : $file;
validate(["$field|图片" => [ validate(["$field|图片" => [
'fileSize' => config('upload.filesize'), 'fileSize' => config('upload.filesize'),
'fileExt' => 'jpg,jpeg,png,bmp,gif', 'fileExt' => config('upload.fileExt'),
'fileMime' => 'image/jpeg,image/png,image/gif,application/octet-stream' // 'fileMime' => 'image/jpeg,image/png,image/gif,application/octet-stream,application/vnd.android.package-archive'
]])->check([$field => $file]); ]])->check([$field => $file]);
$upload = UploadService::create(); $upload = UploadService::create();
$info = $upload->to('def')->move($field); $info = $upload->to('def')->move($field);
@ -485,7 +486,20 @@ class Common extends BaseController
//街道 乡镇数据 //街道 乡镇数据
public function get_street($area_code){ public function get_street($area_code){
$select=Db::name('geo_street')->where('area_code',$area_code)->field('street_id id,street_code code,street_name name')->select(); $select=Db::name('geo_street')->where('area_code',$area_code)->field('street_id id,street_code code,street_name name')->select();
return app('json')->success($select); $arr=$select?$select->toArray():[];
foreach ($arr as $k=>$item){
$first_char = mb_str_split($item['name']);
if($first_char[0]){
$pinyin=new Pinyin();
$string=$first_char[0];
$pinyin = $pinyin->abbr($string);
$arr[$k]['pinyin']=$pinyin;
}else{
$arr[$k]['pinyin']='';
}
}
return app('json')->success($arr);
} }
//村数据 //村数据
public function get_village($street_code){ public function get_village($street_code){

197
app/controller/api/Demo.php Normal file
View File

@ -0,0 +1,197 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\api;
use crmeb\basic\BaseController;
use think\facade\Db;
use crmeb\services\UploadService;
use Exception;
use ZipArchive;
/**
* Class Auth
* @package app\controller\api
* @author xaboy
* @day 2020-05-06
*/
class Demo extends BaseController
{
public function index()
{
$mer_id = 65;
$file = request()->file('file');
$zip_name = explode('.', $file->getOriginalName())[0];
// 上传到本地服务器
$savename = \think\facade\Filesystem::putFile('zippic', $file);
$dir = date('Y-m-d_H-i-s') . '_' . $mer_id;
$destination_path = public_path('uploads/pic/' . $dir.'_'.$zip_name);
mkdir($destination_path, 0777, true);
$zipFile = new \PhpZip\ZipFile();
try {
$zipFile
->openFile(public_path('uploads').$savename) // open archive from file
->extractTo($destination_path) // add an entry from the string
// ->deleteFromRegex('~^\.~') // delete all hidden (Unix) files
->close(); // close archive
} catch (\PhpZip\Exception\ZipException $e) {
throw new \think\exception\HttpException(404,$e->getMessage());
} finally {
$zipFile->close();
}
// if ($zip->open(public_path('uploads').$savename) === TRUE) {
// $zip->extractTo($destination_path);
// $zip->close();
// } else {
// throw new \think\exception\HttpException(404, '解压失败');
// }
$directory = $destination_path;
$files = scandir($directory);
$dir = 'def/' . date('Y-m-d');
$upload = UploadService::create();
/**循环目录 */
foreach ($files as $file) {
if ($file === '.' || $file === '..' || $file === '__MACOSX') {
continue;
}
if (!is_dir($directory . '/' . $file)) {
continue;
}
$files_two = scandir($directory . '/' . $file);
$image_extensions = array('jpg', 'jpeg', 'png');
$image = '';
$slider_image = [];
$details = [];
$sku_arr = [];
/**清洗图片 */
foreach ($files_two as $file_two) {
if ($file_two === '.' || $file_two === '..' || $file_two === '__MACOSX') {
continue;
}
$arr = explode('.', $file_two);
if (in_array($arr[1], $image_extensions)) {
/**首图 */
$images[] = $file_two;
if ($image == '' && is_numeric($arr[0])) {
$image = $directory . '/' . $file . '/' . $file_two;
continue;
}
/**轮播图 */
if (is_numeric($arr[0]) && count($slider_image) < 4) {
$slider_image[] = $directory . '/' . $file . '/' . $file_two;
continue;
}
/**详情图 */
if (is_numeric($arr[0])) {
$details[] = $directory . '/' . $file_two;
continue;
}
/**sku图 */
$sku = explode('==', $arr[0]);
if ($sku) {
$sku = implode(',', $sku);
$sku_arr[$sku] = $directory . '/' . $file . '/' . $file_two;
}
}
}
$where = ['mer_id' => $mer_id, 'is_del' => 0];
$update = [];
$update_content['title'] = '';
$update_content['image'] = [];
$update_content['type'] = 1;
$find = Db::name('store_product')->where($where)->where('store_name', $file)->find();
if ($find) {
try {
/**更新商品图片 */
$image = $upload->to($dir)->stream(file_get_contents($image));
$update['image'] = $image->filePath;
foreach ($slider_image as $k => $v) {
$oss = $upload->to($dir)->stream(file_get_contents($v));
$update['slider_image'][] = $oss->filePath;
}
if (isset($update['slider_image'])) {
$update['slider_image'] = implode(',', $update['slider_image']);
}
Db::name('store_product')->where('product_id', $find['product_id'])->update($update);
/**更新规格图片 */
foreach ($sku_arr as $k => $v) {
$store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])->find();
if ($store_product_attr_value) {
$oss = $upload->to($dir)->stream(file_get_contents($v));
Db::name('store_product_attr_value')
->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])
->update(['image' => $oss->filePath]);
}
}
/**更新详情图片 */
$store_product_content = Db::name('store_product_content')->where(['product_id' => $find['product_id']])->find();
foreach ($details as $k => $v) {
$oss = $upload->to($dir)->stream(file_get_contents($v));
$update_content['image'][] = $oss->filePath;
}
if ($store_product_content) {
if (isset($update_content['image']) && !empty($update_content['image'])) {
Db::name('store_product_content')
->where(['product_id' => $find['product_id']])
->update(['content' => json_encode($update_content)]);
}
} else {
$update_content['product_id'] = $find['product_id'];
Db::name('store_product_content')
->insert(['product_id' => $find['product_id'], 'type' => 1, 'content' => json_encode($update_content)]);
}
} catch (Exception $e) {
halt($e->getMessage(), $e->getLine());
}
}
}
halt(1);
}
public function transcoding($fileName)
{
$encoding = mb_detect_encoding($fileName, ['UTF-8', 'GBK', 'BIG5', 'CP936']);
if (DIRECTORY_SEPARATOR == '/') { // linux
$fileName = iconv($encoding, 'UTF-8', $fileName);
} else { // win
$fileName = iconv($encoding, 'GBK', $fileName);
}
return $fileName;
}
function createDirectories($path) {
if (is_dir($path)) {
return true ;
} else {
$parts = explode(DIRECTORY_SEPARATOR, $path);
$part = null;
foreach ($parts as $part) {
if ($part === '' || $part === '.' || $part === '..') {
continue;
}
$dir = dirname($path) . DIRECTORY_SEPARATOR . $part;
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
}
return true ;
}
}
}

View File

@ -109,11 +109,11 @@ class Statistics extends BaseController
if (isset($parmas['keyword']) && $parmas['keyword'] != '') { if (isset($parmas['keyword']) && $parmas['keyword'] != '') {
$where[] = ['store_name', 'like', '%' . $parmas['keyword'] . '%']; $where[] = ['store_name', 'like', '%' . $parmas['keyword'] . '%'];
} }
$count=Db::name('store_product')->where($where)->count(); $count = Db::name('store_product')->where($where)->count();
$list = Db::name('store_product')->where($where)->page($parmas['page']) $list = Db::name('store_product')->where($where)->page($parmas['page'])
->field('product_id,store_name,image,price') ->field('product_id,store_name,image,price')
->limit(10)->select(); ->limit(10)->select();
return app('json')->success(['page' => $parmas['page'], 'data' => $list,'count'=>$count]); return app('json')->success(['page' => $parmas['page'], 'data' => $list, 'count' => $count]);
} }
/** /**
@ -149,7 +149,7 @@ class Statistics extends BaseController
if (!isset($parmas['goods_id']) || $parmas['goods_id'] == '') { if (!isset($parmas['goods_id']) || $parmas['goods_id'] == '') {
return app('json')->fail('goods_id:格式错误'); return app('json')->fail('goods_id:格式错误');
} }
$mer_id=Db::name('merchant_intention')->where('mer_intention_id', $parmas['mer_intention_id'])->value('mer_id'); $mer_id = Db::name('merchant_intention')->where('mer_intention_id', $parmas['mer_intention_id'])->value('mer_id');
$where[] = ['p.create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]]; $where[] = ['p.create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]];
$where[] = ['p.product_id', 'in', explode(',', $parmas['goods_id'])]; $where[] = ['p.product_id', 'in', explode(',', $parmas['goods_id'])];
$where[] = ['p.is_refund', '=', 0]; $where[] = ['p.is_refund', '=', 0];
@ -231,7 +231,7 @@ class Statistics extends BaseController
// return app('json')->fail('type:格式错误'); // return app('json')->fail('type:格式错误');
// } // }
$area[] = ['street_id', 'in', explode(',', $parmas['responsible_area'])]; $area[] = ['street_id', 'in', explode(',', $parmas['responsible_area'])];
$area[] = ['type_id', '=',17]; $area[] = ['type_id', '=', 17];
$merchant = Db::name('merchant')->where($area)->column('mer_id'); $merchant = Db::name('merchant')->where($area)->column('mer_id');
if (!$merchant) { if (!$merchant) {
@ -262,17 +262,53 @@ class Statistics extends BaseController
if (!isset($parmas['phone']) || $parmas['phone'] == '') { if (!isset($parmas['phone']) || $parmas['phone'] == '') {
return app('json')->fail('phone:格式错误'); return app('json')->fail('phone:格式错误');
} }
$user_id= Db::name('user')->where('account',$parmas['phone'])->value('uid'); $account[] = ['account', 'in', explode(',', $parmas['phone'])];
if(!$user_id){ $user_id = Db::name('user')->where($account)->value('uid');
if (!$user_id) {
return app('json')->fail('查询的手机号用户不存在'); return app('json')->fail('查询的手机号用户不存在');
} }
$where[]=['create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; $where[] = ['create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]];
$where[]=['paid','=',1]; $where[] = ['paid', '=', 1];
$where[]=['status','<>',-1]; $where[] = ['status', '<>', -1];
$where[]=['uid','=',$user_id]; $where[] = ['uid', '=', $user_id];
$count=Db::name('store_order') $count = Db::name('store_order')
->where($where) ->where($where)
->sum('pay_price'); ->sum('pay_price');
return app('json')->success(['trade_amount'=>$count]); return app('json')->success(['trade_amount' => $count]);
}
/**
* 查询镇农科公司负责片区内的种养殖商户和供应链商户交易额
*暂无种养殖商户分类
*/
public function SupplyChainVillageBreedingPriceCount()
{
$parmas = $this->request->param();
if (!isset($parmas['start_time']) || $parmas['start_time'] == '') {
return app('json')->fail('start_time:格式错误');
} }
if (!isset($parmas['end_time']) || $parmas['end_time'] == '') {
return app('json')->fail('end_time:格式错误');
}
if (!isset($parmas['village']) || $parmas['village'] == '') {
return app('json')->fail('village:格式错误');
}
$village_id = Db::name('geo_village')->where('village_code', $parmas['village'])->value('village_id');
$merchant_category_id = Db::name('merchant_category')->where('code', 'zhongyangzhi')->value('merchant_category_id');
$area[] = ['village_id', '=', $village_id];
$area[] = ['category_id', '=', $merchant_category_id];
$merchant = Db::name('merchant')->where($area)->column('mer_id');
if (!$merchant) {
return app('json')->fail('查询商户为空');
}
$where[] = ['p.create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]];
$where[] = ['p.is_refund', '=', 0];
$count = Db::name('store_order_product')->alias('p')
->where($where)
->join('store_order o', 'o.mer_id in (' . implode(',', $merchant) . ') and o.paid=1 and o.is_del=0')
->sum('p.total_price');
return app('json')->success(['trade_amount' => $count]);
}
} }

View File

@ -70,6 +70,7 @@ class StoreOrder extends BaseController
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$where['status'] = $this->request->param('status'); $where['status'] = $this->request->param('status');
$where['pay_time'] = $this->request->param('pay_time');
$where['product_type'] = $this->request->param('product_type',0); $where['product_type'] = $this->request->param('product_type',0);
if ($where['product_type']==0){ if ($where['product_type']==0){
unset($where['product_type']); unset($where['product_type']);

View File

@ -58,14 +58,14 @@ class StoreProduct extends BaseController
public function lst($merId) public function lst($merId)
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$where = $this->request->params(['cate_id', 'keyword', ['type',20], 'mer_cate_id', 'is_gift_bag', 'status', 'us_status', 'product_id', 'mer_labels',['order','sort']]); $where = $this->request->params(['cate_id', 'keyword', ['type', 20], 'mer_cate_id', 'is_gift_bag', 'status', 'us_status', 'product_id', 'mer_labels', ['order', 'sort']]);
$merchant = app()->make(MerchantRepository::class)->get($merId); $merchant = app()->make(MerchantRepository::class)->get($merId);
$typeCode=Db::name('merchant_type')->where('mer_type_id',$merchant['type_id'])->value('type_code'); $typeCode = Db::name('merchant_type')->where('mer_type_id', $merchant['type_id'])->value('type_code');
// if ($merchant['type_id']==12){ // if ($merchant['type_id']==12){
if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ if ($typeCode == Merchant::TypeCode['TypeSupplyChain']) {
$product_type=98;//供应链 $product_type = 98; //供应链
}else{ } else {
$product_type=0;//普通商品 $product_type = 0; //普通商品
} }
$where = array_merge($where, $this->repository->switchType($where['type'], $merId, $product_type)); $where = array_merge($where, $this->repository->switchType($where['type'], $merId, $product_type));
return app('json')->success($this->repository->getList($merId, $where, $page, $limit)); return app('json')->success($this->repository->getList($merId, $where, $page, $limit));
@ -82,21 +82,26 @@ class StoreProduct extends BaseController
public function create($merId, StoreProductValidate $validate) public function create($merId, StoreProductValidate $validate)
{ {
$res = $this->request->params($this->repository::CREATE_PARAMS); $res = $this->request->params($this->repository::CREATE_PARAMS);
$data = $this->repository->checkParams($res,$merId); $data = $this->repository->checkParams($res, $merId);
$data['mer_id'] = $merId; $data['mer_id'] = $merId;
$data['is_gift_bag'] = 0; $data['is_gift_bag'] = 0;
$merchant = app()->make(MerchantRepository::class)->get($merId); $merchant = app()->make(MerchantRepository::class)->get($merId);
$data['status'] = $merchant->is_audit ? 0 : 1; $data['status'] = $merchant->is_audit ? 0 : 1;
$data['mer_status'] = ($merchant['is_del'] || !$merchant['mer_state'] || !$merchant['status']) ? 0 : 1; $data['mer_status'] = ($merchant['is_del'] || !$merchant['mer_state'] || !$merchant['status']) ? 0 : 1;
$data['rate'] = 3; $data['rate'] = 3;
$typeCode=Db::name('merchant_type')->where('mer_type_id',$merchant['type_id'])->value('type_code'); $typeCode = Db::name('merchant_type')->where('mer_type_id', $merchant['type_id'])->value('type_code');
if ($merchant['type_id']==12){ $product_type = 0; //普通商品
if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ if ($merchant['type_id'] == 12) {
$product_type=98;//供应链 if ($typeCode == Merchant::TypeCode['TypeSupplyChain']) {
}else{ $product_type = 98; //供应链
$product_type=0;//普通商品 }
} }
$productId = $this->repository->create($data, $product_type, 1); $productId = $this->repository->create($data, $product_type, 1);
if ($productId) {
return app('json')->success('添加成功');
} else {
return app('json')->fail('添加失败');
}
// $unique = Db::name('store_product_attr_value')->where('product_id', $productId)->value('unique'); // $unique = Db::name('store_product_attr_value')->where('product_id', $productId)->value('unique');
// if (!empty($unique) && $stockNum > 0) { // if (!empty($unique) && $stockNum > 0) {
// $this->repository->stockIn($merId, [ // $this->repository->stockIn($merId, [
@ -104,8 +109,6 @@ class StoreProduct extends BaseController
// 'unique' => $unique, // 'unique' => $unique,
// 'number' => $stockNum, // 'number' => $stockNum,
// ]); // ]);
}
return app('json')->success('添加成功');
} }
/** /**
@ -120,7 +123,7 @@ class StoreProduct extends BaseController
public function update($merId, $id, StoreProductValidate $validate) public function update($merId, $id, StoreProductValidate $validate)
{ {
$res = $this->request->params($this->repository::CREATE_PARAMS); $res = $this->request->params($this->repository::CREATE_PARAMS);
$data = $this->repository->checkParams($res,$merId,$id); $data = $this->repository->checkParams($res, $merId, $id);
$merchant = app()->make(MerchantRepository::class)->get($merId); $merchant = app()->make(MerchantRepository::class)->get($merId);
if (!$this->repository->merExists($merId, $id)) if (!$this->repository->merExists($merId, $id))
@ -135,8 +138,12 @@ class StoreProduct extends BaseController
$data['mer_id'] = $merId; $data['mer_id'] = $merId;
$typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id'); $typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
$productType = $merchant->type_id == $typeSupplyChainId ? 98 : 0; $productType = $merchant->type_id == $typeSupplyChainId ? 98 : 0;
$this->repository->edit($id, $data, $merId, $productType, 1); $product=$this->repository->edit($id, $data, $merId, $productType, 1);
return app('json')->success('编辑成功'); if ($product) {
return app('json')->success('编辑成功');
} else {
return app('json')->fail('编辑失败');
}
} }
/** /**
@ -167,7 +174,7 @@ class StoreProduct extends BaseController
$status = $this->request->param('status', 0) == 1 ? 1 : 0; $status = $this->request->param('status', 0) == 1 ? 1 : 0;
if (!$this->repository->merExists($merId, $id)) if (!$this->repository->merExists($merId, $id))
return app('json')->fail('数据不存在'); return app('json')->fail('数据不存在');
$this->repository->switchShow($id,$status, 'is_show',$merId); $this->repository->switchShow($id, $status, 'is_show', $merId);
return app('json')->success('修改成功'); return app('json')->success('修改成功');
} }
@ -194,9 +201,9 @@ class StoreProduct extends BaseController
$data['extension_status'] = systemConfig('extension_status'); $data['extension_status'] = systemConfig('extension_status');
$data['integral_status'] = 0; $data['integral_status'] = 0;
$data['integral_rate'] = 0; $data['integral_rate'] = 0;
if(systemConfig('integral_status') && merchantConfig($merId,'mer_integral_status')) { if (systemConfig('integral_status') && merchantConfig($merId, 'mer_integral_status')) {
$data['integral_status'] = 1; $data['integral_status'] = 1;
$data['integral_rate'] = merchantConfig($merId,'mer_integral_rate'); $data['integral_rate'] = merchantConfig($merId, 'mer_integral_rate');
} }
$merchant = app()->make(MerchantRepository::class)->get($merId); $merchant = app()->make(MerchantRepository::class)->get($merId);
$data['delivery_way'] = $merchant->delivery_way; $data['delivery_way'] = $merchant->delivery_way;
@ -239,15 +246,14 @@ class StoreProduct extends BaseController
public function stockIn() public function stockIn()
{ {
$params = $this->request->param(); $params = $this->request->param();
if($params['unique']==''){ if ($params['unique'] == '') {
return app('json')->fail('多规格编号不能为空'); return app('json')->fail('多规格编号不能为空');
} }
$res=$this->repository->stockIn($this->merId, $params); $res = $this->repository->stockIn($this->merId, $params);
if($res){ if ($res) {
return app('json')->success('入库成功'); return app('json')->success('入库成功');
}else{ } else {
return app('json')->fail('入库失败'); return app('json')->fail('入库失败');
} }
} }
} }

View File

@ -56,9 +56,9 @@ class MerchantIntention extends BaseController
if ($intentionInfo) { if ($intentionInfo) {
throw new ValidateException('此统一社会信用代码已申请商户'); throw new ValidateException('此统一社会信用代码已申请商户');
} }
$merInfo = Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->find(); $merInfo = Db::name('merchant_intention')->where('uid', $this->userInfo->uid)->where('status', 'in',[0,1])->where('is_del',0)->find();
if ($merInfo) { if ($merInfo) {
throw new ValidateException('该用户已存在商户,不可申请'); throw new ValidateException('该用户已申请商户,不可重复申请');
} }
$make = app()->make(MerchantRepository::class); $make = app()->make(MerchantRepository::class);
if ($make->fieldExists('mer_name', $data['mer_name'])) if ($make->fieldExists('mer_name', $data['mer_name']))
@ -275,7 +275,7 @@ class MerchantIntention extends BaseController
if ($adminRepository->fieldExists('account', $data['phone'])) if ($adminRepository->fieldExists('account', $data['phone']))
throw new ValidateException('手机号已是管理员,不可申请'); throw new ValidateException('手机号已是管理员,不可申请');
$data['create_time'] = date('Y-m-d H:i:s', time()); $data['create_time'] = date('Y-m-d H:i:s', time());
$this->repository->updateIntention((int)$id, $data); $updateIntention=$this->repository->updateIntention((int)$id, $data);
SwooleTaskService::admin('notice', [ SwooleTaskService::admin('notice', [
'type' => 'new_intention', 'type' => 'new_intention',
'data' => [ 'data' => [
@ -308,7 +308,11 @@ class MerchantIntention extends BaseController
if (!$res['ok']) { if (!$res['ok']) {
throw new ValidateException('供销平台申请商户入驻失败,' . $res['msg']); throw new ValidateException('供销平台申请商户入驻失败,' . $res['msg']);
} }
return app('json')->success('修改成功'); if($updateIntention){
return app('json')->success('修改成功');
}else{
return app('json')->success('修改失败');
}
} }
public function lst() public function lst()
@ -341,8 +345,8 @@ class MerchantIntention extends BaseController
'name', 'name',
'code', 'code',
'images', 'images',
'merchant_category_name',
'mer_type_id', 'mer_type_id',
'merchant_category_id',
'social_credit_code', 'social_credit_code',
'area_id', 'area_id',
'street_id', 'street_id',
@ -360,14 +364,14 @@ class MerchantIntention extends BaseController
if ($data['mer_type_id'] && !app()->make(MerchantTypeRepository::class)->exists($data['mer_type_id'])) { if ($data['mer_type_id'] && !app()->make(MerchantTypeRepository::class)->exists($data['mer_type_id'])) {
throw new ValidateException('店铺类型不存在'); throw new ValidateException('店铺类型不存在');
} }
if ($data['merchant_category_name'] == '') { // if ($data['merchant_category_name'] == '') {
throw new ValidateException('商户分类,不能为空'); // throw new ValidateException('商户分类,不能为空');
} // }
$merchant_category_id=Db::name('merchant_category')->where('category_name',$data['merchant_category_name'])->value('merchant_category_id'); // $merchant_category_id=Db::name('merchant_category')->where('category_name',$data['merchant_category_name'])->value('merchant_category_id');
if(!$merchant_category_id){ // if(!$merchant_category_id){
throw new ValidateException('没有对应的商户分类,请联系工作人员添加'); // throw new ValidateException('没有对应的商户分类,请联系工作人员添加');
} // }
$data['merchant_category_id']=$merchant_category_id; // $data['merchant_category_id']=$merchant_category_id;
unset($data['code']); unset($data['code']);
return $data; return $data;
} }

View File

@ -39,64 +39,15 @@ class CloudWarehouse extends BaseController
$this->spuRepository->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null; $this->spuRepository->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null;
} }
/**
* 指定类型的云仓商品列表
* @return mixed
*/
// public function index()
// {
// // 除了市级供应链都可以查询
// $typeIdArray = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypePlatform'])->column('mer_type_id');
// $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword','page_num']);
// $search = [
// // 'street_id' => $params['street_code'],
// 'type_id' => $typeIdArray ?? [],
// 'status' => 1,
// 'is_del' => 0,
// 'mer_state' => 1,
// ];
// if (!empty($params['category_id'])) {
// $search['category_id'] = $params['category_id'];
// }
// $merchantIds = $this->merchantDao->search($search)->column('mer_id');
// [$page, $limit] = $this->getPage();
// if(isset($params['page_num'])&&$params['page_num']!=''){
// $page=$params['page_num'];
// }
// if (empty($merchantIds)) {
// return app('json')->success(['count' => 0, 'list' => []]);
// }
// // 隐藏镇级云仓
// // $typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id');
// // $entryWhere = [
// // 'street_id' => $params['street_code'],
// // 'type_id' => $typeCloudWarehouseId,
// // 'status' => 1,
// // 'is_del' => 0,
// // 'mer_state' => 1,
// // ];
// // if (!empty($params['category_id'])) {
// // $entryWhere['category_id'] = $params['category_id'];
// // }
// // $where['entry_mer_id'] = $this->merchantDao->search($entryWhere)->value('mer_id');
// $where['entry_mer_id'] = 0;
// $where['keyword'] = $params['keyword'];
// $where['mer_ids'] = $merchantIds;
// $where['product_type'] = $params['product_type'];
// $where['is_gift_bag'] = 0;
// $where['order'] = $params['order'] ?: 'sort';
// $products = $this->spuRepository->getApiCloudSearch($where, $page, $limit, false);
// return app('json')->success($products);
// }
/** /**
* type_id 13云仓商品列表 * type_id 13云仓商品列表
* @return mixed * @return mixed
*/ */
public function index($street_code, $page = 1, $category_id = 0,$location='') public function index($street_code, $page = 1, $category_id = 0,$location='')
{ {
$cloud_product = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->page($page)->column('product_id'); $cloud_product = Db::name('cloud_product')
->where('cate_id',$category_id)
->where('street_code', $street_code)->where('status', 1)->page($page)->column('product_id');
$where = [ $where = [
'is_show' => 1, 'is_show' => 1,
'is_used' => 1, 'is_used' => 1,
@ -107,7 +58,6 @@ class CloudWarehouse extends BaseController
'product_id'=>$cloud_product 'product_id'=>$cloud_product
]; ];
if (!$cloud_product && $category_id==0) { if (!$cloud_product && $category_id==0) {
return app('json')->success(['count' => 0, 'list' => []]); return app('json')->success(['count' => 0, 'list' => []]);
} }
$count = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->count(); $count = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->count();
@ -128,14 +78,12 @@ class CloudWarehouse extends BaseController
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page']); $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page']);
$search = [ $search = [
'street_id' => $params['street_code'], 'street_id' => $params['street_code'],
'type_id' => Merchant::TypeTownSupplyChain, 'type_id' =>[Merchant::TypeStore,Merchant::TypeTownSupplyChain],
'status' => 1, 'status' => 1,
'is_del' => 0, 'is_del' => 0,
'mer_state' => 1, 'mer_state' => 1,
]; ];
if (!empty($params['category_id'])) {
$search['category_id'] = $params['category_id'];
}
$merchantIds = $this->merchantDao->search($search)->column('mer_id'); $merchantIds = $this->merchantDao->search($search)->column('mer_id');
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
if (isset($params['page']) && $params['page'] != '') { if (isset($params['page']) && $params['page'] != '') {
@ -150,6 +98,9 @@ class CloudWarehouse extends BaseController
$where['product_type'] = $params['product_type']; $where['product_type'] = $params['product_type'];
$where['is_gift_bag'] = 0; $where['is_gift_bag'] = 0;
$where['order'] = $params['order'] ?: 'sort'; $where['order'] = $params['order'] ?: 'sort';
if (!empty($params['category_id'])) {
$where['cate_id'] = $params['category_id'];
}
$products = $this->spuRepository->getApiSearch($where, $page, $limit, false,true); $products = $this->spuRepository->getApiSearch($where, $page, $limit, false,true);
return app('json')->success($products); return app('json')->success($products);
} }

View File

@ -69,6 +69,7 @@ class StoreMicro extends BaseController
//提交导入商品id //提交导入商品id
public function ProductImport(){ public function ProductImport(){
return app('json')->fail('该接口已废弃');
$id = $this->request->param('id', 0); $id = $this->request->param('id', 0);
$price = $this->request->param('price', 0); $price = $this->request->param('price', 0);
$stock = $this->request->param('stock', 0); $stock = $this->request->param('stock', 0);

View File

@ -15,13 +15,14 @@ use app\common\repositories\store\ExcelRepository;
use app\common\repositories\store\order\StoreImportDeliveryRepository; use app\common\repositories\store\order\StoreImportDeliveryRepository;
use app\common\repositories\store\order\StoreOrderRepository; use app\common\repositories\store\order\StoreOrderRepository;
use crmeb\jobs\ImportSpreadsheetExcelJob; use crmeb\jobs\ImportSpreadsheetExcelJob;
use crmeb\jobs\ImportPicJob;
use crmeb\services\ExcelService; use crmeb\services\ExcelService;
use crmeb\services\SpreadsheetExcelService; use crmeb\services\SpreadsheetExcelService;
use crmeb\services\UploadService; use crmeb\services\UploadService;
use think\App; use think\App;
use crmeb\basic\BaseController; use crmeb\basic\BaseController;
use app\common\repositories\store\order\StoreImportRepository; use app\common\repositories\store\order\StoreImportRepository;
use ZipArchive;
use think\facade\Db; use think\facade\Db;
use think\facade\Queue; use think\facade\Queue;
@ -72,13 +73,16 @@ class StoreImport extends BaseController
} }
/** /**
* TODO 导入excel信息 * TODO 导入excel商品信息
* @return \think\response\Json * @return \think\response\Json
* @author Qinii * @author Qinii
* @day 3/16/21 * @day 3/16/21
*/ */
public function Import($type) public function Import($type)
{ {
if($type=='import_images'){
return $this->import_images();
}
$file = $this->request->file('file'); $file = $this->request->file('file');
if (!$file) return app('json')->fail('请上传EXCEL文件'); if (!$file) return app('json')->fail('请上传EXCEL文件');
$file = is_array($file) ? $file[0] : $file; $file = is_array($file) ? $file[0] : $file;
@ -89,29 +93,10 @@ class StoreImport extends BaseController
$res = $upload->getUploadInfo(); $res = $upload->getUploadInfo();
$path = rtrim(public_path(),'/').$res['dir']; $path = rtrim(public_path(),'/').$res['dir'];
$data = []; $data = [];
$type_id=Db::name('merchant')->where('mer_id',$this->request->merId())->value('type_id');
switch ($type){ switch ($type){
case 'product': case 'product':
$check =[ $this->getXlsList($type_id,$path);
'A1'=>'商品名称',
'B1'=>'商品简介',
'C1'=>'关键字',
'D1'=>'商品条码',
'E1'=>'分类',
'F1'=>'单位名',
'G1'=>'出售价',
'H1'=>'总库存',
'I1'=>'规格',
];
SpreadsheetExcelService::instance()->checkImport($path,$check);
$data = [
'mer_id' => $this->request->merId(),
'data' => [
'path' => $path,
'sql' => ['store_name' => 'A', 'store_info' => 'B', 'keyword' => 'C', 'bar_code' => 'D', 'cate_id' => 'E', 'unit_name' => 'F', 'price' => 'G', 'stock' => 'H', 'specifications' => 'I'],
'where' => ['bar_code' => 'D'],
]
];
app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id']);
return app('json')->success('开始导入数据,请稍后在列表中查看!'); return app('json')->success('开始导入数据,请稍后在列表中查看!');
break; break;
case 'delivery' : case 'delivery' :
@ -177,5 +162,136 @@ class StoreImport extends BaseController
} }
return app('json')->fail('数据类型错误'); return app('json')->fail('数据类型错误');
} }
/**
* 导入商品图片
*/
public function import_images(){
$file = request()->file('file');
$zip_name = explode('.', $file->getOriginalName())[0];
// 上传到本地服务器
$savename = \think\facade\Filesystem::putFile('zippic', $file);
$mer_id = $this->request->merId();
$dir = date('Y-m-d_H-i-s') . '_' . $mer_id;
$path = public_path('uploads/pic').$dir;
try {
$zip = new ZipArchive;
$filePath = public_path('uploads') . $savename;
$zip->open($filePath);
for ($i = 0; $i < $zip->numFiles; $i++) {
$statInfo = $zip->statIndex($i, ZipArchive::FL_ENC_RAW);
$filename = $this->transcoding($statInfo['name']);
$mkdFile = explode('/',$filename);
if ($statInfo['crc'] == 0) {
// 新建目录
if (!file_exists($path . '/' . $filename)) {
mkdir($path . '/' . $filename, 0777, true);
}
} else {
// 拷贝文件
if(count($mkdFile)==3){
if (!file_exists($path . '/' . $mkdFile[0].'/'.$mkdFile[1])) {
mkdir($path . '/' .$mkdFile[0].'/'.$mkdFile[1], 0777, true);
}
copy('zip://' . $file . '#' . $zip->getNameIndex($i), $path . '/' . $filename);
}
}
}
$zip->close();
} catch (\Exception $e) {
throw new \think\exception\HttpException(404, $e->getMessage() . '。line:' . $e->getLine());
}
Queue::push(ImportPicJob::class,['mer_id'=>$mer_id,'path'=>$path.'/'.$zip_name]);
return app('json')->success('开始导入数据,请稍后在列表中查看!,如果未导入请检查格式');
}
public function getXlsList($type_id,$path){
if($type_id==12){
$check =[
'A1'=>'商品名称(必填)',
'B1'=>'平台一级类目(必填)',
'C1'=>'平台二级类目(必填)',
'D1'=>'店铺一级商品分类',
'E1'=>'店铺二级商品分类',
'F1'=>'规格组',
'G1'=>'规格值',
'H1'=>'销售单位',
'I1'=>'批发价(必填)',
'J1'=>'零售价(必填)',
'K1'=>'成本价',
'L1'=>'商品条码',
'M1'=>'商品品牌',
];
SpreadsheetExcelService::instance()->checkImport($path,$check);
$data = [
'mer_id' => $this->request->merId(),
'data' => [
'path' => $path,
'sql' => ['store_name' => 'A', 'cate_id_one' => 'B', 'cate_id_two' => 'C', 'cate_id_one_mer' => 'D', 'cate_id_one_two' => 'E',
'attr_one' => 'F', 'attr_two' => 'G', 'unit_name' => 'H', 'procure_price' => 'I','price'=>'J','cost'=>'K','bar_code'=>'L','brand_id'=>'M'],
'where' => ['store_name' => 'A'],
]
];
app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id'],$type_id);
}else{
$check =[
'A1'=>'商品名称(必填)',
'B1'=>'平台一级类目(必填)',
'C1'=>'平台二级类目(必填)',
'D1'=>'店铺一级商品分类',
'E1'=>'店铺二级商品分类',
'F1'=>'规格组',
'G1'=>'规格值',
'H1'=>'销售单位',
'I1'=>'零售价(必填)',
'J1'=>'成本价',
'K1'=>'商品条码',
'L1'=>'商品品牌',
];
SpreadsheetExcelService::instance()->checkImport($path,$check);
$data = [
'mer_id' => $this->request->merId(),
'data' => [
'path' => $path,
'sql' => ['store_name' => 'A', 'cate_id_one' => 'B', 'cate_id_two' => 'C', 'cate_id_one_mer' => 'D', 'cate_id_one_two' => 'E',
'attr_one' => 'F', 'attr_two' => 'G', 'unit_name' => 'H', 'price' => 'I','cost'=>'J','bar_code'=>'K','brand_id'=>'L'],
'where' => ['store_name' => 'A'],
]
];
app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id'],$type_id);
}
}
public function transcoding($fileName)
{
$encoding = mb_detect_encoding($fileName, ['UTF-8', 'GBK', 'BIG5', 'CP936']);
if (DIRECTORY_SEPARATOR == '/') { // linux
$fileName = iconv($encoding, 'UTF-8', $fileName);
} else { // win
$fileName = iconv($encoding, 'GBK', $fileName);
}
return $fileName;
}
function createDirectories($path) {
if (is_dir($path)) {
return true ;
} else {
$parts = explode(DIRECTORY_SEPARATOR, $path);
$part = null;
foreach ($parts as $part) {
if ($part === '' || $part === '.' || $part === '..') {
continue;
}
$dir = dirname($path) . DIRECTORY_SEPARATOR . $part;
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
}
return true ;
}
}
} }

View File

@ -1,120 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\merchant\store;
use app\common\repositories\store\ExcelRepository;
use app\common\repositories\store\order\StoreImportDeliveryRepository;
use app\common\repositories\store\order\StoreOrderRepository;
use crmeb\jobs\ImportSpreadsheetExcelJob;
use crmeb\services\ExcelService;
use crmeb\services\SpreadsheetExcelService;
use crmeb\services\UploadService;
use think\App;
use crmeb\basic\BaseController;
use app\common\repositories\store\order\StoreImportRepository;
use think\facade\Queue;
class StoreImport extends BaseController
{
protected $repository;
/**
* Product constructor.
* @param App $app
* @param StoreImportRepository $repository
*/
public function __construct(App $app, StoreImportRepository $repository)
{
parent::__construct($app);
$this->repository = $repository;
}
public function lst()
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['status','date',['import_type','delivery'],'type']);
$where['mer_id'] = $this->request->merId();
$data = $this->repository->getList($where,$page,$limit);
return app('json')->success($data);
}
public function detail($id)
{
$where = [
'import_id' => $id,
'mer_id' => $this->request->merId()
];
[$page, $limit] = $this->getPage();
$data = app()->make(StoreImportDeliveryRepository::class)->getList($where,$page, $limit);
return app('json')->success($data);
}
public function export($id)
{
$where = [
'import_id' => $id,
'mer_id' => $this->request->merId()
];
[$page, $limit] = $this->getPage();
$data = app()->make(ExcelService::class)->importDelivery($where, $page, $limit);
return app('json')->success($data);
}
/**
* TODO 导入excel信息
* @return \think\response\Json
* @author Qinii
* @day 3/16/21
*/
public function Import($type)
{
$file = $this->request->file('file');
if (!$file) return app('json')->fail('请上传EXCEL文件');
$file = is_array($file) ? $file[0] : $file;
validate(["file|文件" => ['fileExt' => 'xlsx,xls',]])->check(['file' => $file]);
$upload = UploadService::create(1);
$ret = $upload->to('excel')->move('file');
if ($ret === false) return app('json')->fail($upload->getError());
$res = $upload->getUploadInfo();
$path = rtrim(public_path(),'/').$res['dir'];
$data = [];
switch ($type){
case 'delivery' :
SpreadsheetExcelService::instance()->checkImport($path,['E3' => '物流单号']);
$data = [
'mer_id' => $this->request->merId(),
'data' => [
'path' => $path,
'sql' => ['delivery_name' => 'D', 'delivery_id' => 'E',],
'where' => ['order_sn' => 'B',],
]
];
break;
default:
$data = SpreadsheetExcelService::instance()->_import($path,[],[],0);
break;
}
if(!empty($data)){
$res = $this->repository->create($this->request->merId(),'delivery');
$data['data']['import_id'] = $res->import_id;
// app()->make(StoreOrderRepository::class)->setWhereDeliveryStatus($data['data'],$data['mer_id']);
Queue::push(ImportSpreadsheetExcelJob::class,$data);
return app('json')->success('开始导入数据,请稍后在批量发货记录中查看!');
}
return app('json')->fail('数据类型错误');
}
}

View File

@ -144,11 +144,10 @@ class Order extends BaseController
public function delivery($id) public function delivery($id)
{ {
$type = $this->request->param('delivery_type'); $type = $this->request->param('delivery_type');
$split = $this->request->params(['is_split',['split',[]]]); $split = $this->request->params(['is_split', ['split', []]]);
if (!$this->repository->merDeliveryExists($id, $this->request->merId())) if (!$this->repository->merDeliveryExists($id, $this->request->merId()))
return app('json')->fail('订单信息或状态错误'); return app('json')->fail('订单信息或状态错误');
switch ($type) switch ($type) {
{
case 3: //虚拟发货 case 3: //虚拟发货
$data = $this->request->params([ $data = $this->request->params([
'delivery_type', 'delivery_type',
@ -170,7 +169,8 @@ class Order extends BaseController
'temp_id', 'temp_id',
'remark', 'remark',
]); ]);
if (!$data['from_name'] || if (
!$data['from_name'] ||
!$data['delivery_name'] || !$data['delivery_name'] ||
!$data['from_tel'] || !$data['from_tel'] ||
!$data['from_addr'] || !$data['from_addr'] ||
@ -186,7 +186,7 @@ class Order extends BaseController
'delivery_type', 'delivery_type',
'station_id', 'station_id',
'mark', 'mark',
['cargo_weight',0], ['cargo_weight', 0],
'remark', 'remark',
]); ]);
if ($data['cargo_weight'] < 0) return app('json')->fail('包裹重量能为负数'); if ($data['cargo_weight'] < 0) return app('json')->fail('包裹重量能为负数');
@ -206,7 +206,7 @@ class Order extends BaseController
$method = 'delivery'; $method = 'delivery';
break; break;
} }
$this->repository->runDelivery($id,$this->request->merId(), $data, $split, $method); $this->repository->runDelivery($id, $this->request->merId(), $data, $split, $method);
return app('json')->success('发货成功'); return app('json')->success('发货成功');
} }
@ -295,7 +295,7 @@ class Order extends BaseController
public function status($id) public function status($id)
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$where = $this->request->params(['date','user_type']); $where = $this->request->params(['date', 'user_type']);
$where['id'] = $id; $where['id'] = $id;
if (!$this->repository->getOne($id, $this->request->merId())) if (!$this->repository->getOne($id, $this->request->merId()))
return app('json')->fail('数据不存在'); return app('json')->fail('数据不存在');
@ -337,7 +337,7 @@ class Order extends BaseController
*/ */
public function verify($id) public function verify($id)
{ {
$data = $this->request->params(['data','verify_code']); $data = $this->request->params(['data', 'verify_code']);
$this->repository->verifyOrder($id, $this->request->merId(), $data); $this->repository->verifyOrder($id, $this->request->merId(), $data);
return app('json')->success('订单核销成功'); return app('json')->success('订单核销成功');
} }
@ -349,6 +349,16 @@ class Order extends BaseController
return app('json')->success($order); return app('json')->success($order);
} }
/**
* 生成取货码
*/
public function logisticsCode($id)
{
$order = $this->repository->getWhere(['order_id' => $id, 'mer_id' => $this->request->merId(), 'is_del' => 0]);
if (!$order)
return app('json')->fail('订单状态有误');
return app('json')->success(['qrcode' => $this->repository->logisticsQrcode($id, $order->order_sn)]);
}
/** /**
* @param $id * @param $id
* @return mixed * @return mixed
@ -424,7 +434,7 @@ class Order extends BaseController
unset($where['order_type']); unset($where['order_type']);
} }
$where['mer_id'] = $this->request->merId(); $where['mer_id'] = $this->request->merId();
$data = app()->make(ExcelService::class)->order($where,$page,$limit); $data = app()->make(ExcelService::class)->order($where, $page, $limit);
return app('json')->success($data); return app('json')->success($data);
} }
@ -462,7 +472,7 @@ class Order extends BaseController
if (!$count) return app('json')->fail('没有可导出数据'); if (!$count) return app('json')->fail('没有可导出数据');
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$data = app()->make(ExcelService::class)->delivery($where,$page,$limit); $data = app()->make(ExcelService::class)->delivery($where, $page, $limit);
return app('json')->success($data); return app('json')->success($data);
} }

View File

@ -55,6 +55,7 @@ class Product extends BaseController
$type=$this->request->merchant()['type_id']; $type=$this->request->merchant()['type_id'];
$typeCode=Db::name('merchant_type')->where('mer_type_id',$type)->value('type_code'); $typeCode=Db::name('merchant_type')->where('mer_type_id',$type)->value('type_code');
$product_type=0; $product_type=0;
// if ($type==12){ // if ($type==12){
if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){
$where['product_type']=98;//供应链 $where['product_type']=98;//供应链

View File

@ -39,12 +39,7 @@ class OrderTake
$product_arr = Db::name('store_order_product')->where('order_id', $order['order_id'])->where('is_refund', 'in', [0, 2])->field('product_id,product_sku,refund_num')->select(); $product_arr = Db::name('store_order_product')->where('order_id', $order['order_id'])->where('is_refund', 'in', [0, 2])->field('product_id,product_sku,refund_num')->select();
foreach ($product_arr as $k => $v) { foreach ($product_arr as $k => $v) {
$this->import($v, $order); $this->import($v, $order);
// app(ProductRepository::class)->create($find, 0);
} }
// $productId = $this->import($params['order_product_id'], request()->userInfo());
// $product = $this->get($productId);
// $attrValue = ProductAttrValue::where('mer_id', $merId)->where('product_id', $productId)->find();
} }
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error($e->getMessage() . 'lien:' . $e->getLine()); Log::error($e->getMessage() . 'lien:' . $e->getLine());
@ -73,6 +68,7 @@ class OrderTake
Log::error('采购导入商品:已经导入过该规格了'); Log::error('采购导入商品:已经导入过该规格了');
return false; return false;
} }
/**查询原始商品的规格 */
$attrValue = Db::name('store_product_attr_value')->where(['product_id' => $find['product_id']]) $attrValue = Db::name('store_product_attr_value')->where(['product_id' => $find['product_id']])
->where('unique', $product['product_sku']) ->where('unique', $product['product_sku'])
->field('image,price,cost,ot_price,svip_price,stock,bar_code,weight,volume,detail,sku') ->field('image,price,cost,ot_price,svip_price,stock,bar_code,weight,volume,detail,sku')
@ -81,18 +77,21 @@ class OrderTake
}) })
->find(); ->find();
$find['attr'] = []; $find['attr'] = [];
$is_update=false;
if ($attrValue['detail']) { if ($attrValue['detail']) {
foreach ($attrValue['detail'] as $kk => $vv) { foreach ($attrValue['detail'] as $kk => $vv) {
/**查询当前规格是否存在 */
$attr_values = Db::name('store_product_attr')->where('product_id', $exist['product_id'])->where('attr_name', $kk) $attr_values_find = Db::name('store_product_attr')->where('product_id', $exist['product_id'])->where('attr_name', $kk)
->value('attr_values'); ->find();
if ($attr_values) { if ($attr_values_find) {
$attr_values= $attr_values_find['attr_values'];
$attr_values = explode('-!-', $attr_values); $attr_values = explode('-!-', $attr_values);
if (!in_array($vv, $attr_values)) { if (!in_array($vv, $attr_values)) {
$attr_values[] = $vv; $attr_values[] = $vv;
$attr_values = implode('-!-', $attr_values); $attr_values = implode('-!-', $attr_values);
Db::name('store_product_attr')->where('product_id', $exist['product_id'])->where('attr_name', $kk)->update(['attr_values' => $attr_values]); Db::name('store_product_attr')->where('product_id', $exist['product_id'])->where('attr_name', $kk)->update(['attr_values' => $attr_values]);
} }
$is_update=true;
} else { } else {
$attr_values = $vv; $attr_values = $vv;
@ -105,13 +104,20 @@ class OrderTake
} }
} }
} }
$attrValue['stock'] = $product['refund_num']; /**规格新增还是更新 */
$unique = app(ProductRepository::class)->setUnique($exist['product_id'], $attrValue['sku'], 0); if($is_update==false){
$attrValue['unique'] = $unique; $attrValue['stock'] = $product['refund_num'];
$attrValue['detail'] = json_encode($attrValue['detail']); $unique = app(ProductRepository::class)->setUnique($exist['product_id'], $attrValue['sku'], 0);
$attrValue['product_id'] = $exist['product_id']; $attrValue['unique'] = $unique;
$attrValue['mer_id'] = $mer_id; $attrValue['detail'] = json_encode($attrValue['detail']);
Db::name('store_product_attr_value')->insert($attrValue); $attrValue['product_id'] = $exist['product_id'];
$attrValue['mer_id'] = $mer_id;
Db::name('store_product_attr_value')->insert($attrValue);
}else{
Db::name('store_product_attr_value')->where(['unique'=>$attr_values_find['unique'],'product_id',
$attr_values_find['product_id'],'mer_id'=>$mer_id,])->update(['stock'=>$product['refund_num']+$attr_values_find['stock']]);
}
Db::name('store_product')->where('product_id',$exist['product_id'])->update(['stock'=>$product['refund_num']+$exist['stock']]); Db::name('store_product')->where('product_id',$exist['product_id'])->update(['stock'=>$product['refund_num']+$exist['stock']]);
$data = [ $data = [
'order_id' => $order['order_id'], 'order_product_id' => $order['product_id'], 'order_id' => $order['order_id'], 'order_product_id' => $order['product_id'],

View File

@ -23,7 +23,7 @@ class ProductCreate
if (empty($merchant)) { if (empty($merchant)) {
return false; return false;
} }
if($merchant['type_id']!=Merchant::TypeTownSupplyChain){ if ($merchant['type_id'] != Merchant::TypeTownSupplyChain) {
return false; return false;
} }
// 根据支持同步到云商的商户进行同步操作 // 根据支持同步到云商的商户进行同步操作
@ -49,17 +49,20 @@ class ProductCreate
return false; return false;
} }
//添加到云仓 //添加到云仓
$datas=[ $find = Db::name('cloud_product')->where('product_id', $product_id)->find();
'product_id'=>$product_id, if (!$find) {
'mer_id'=>$merchant['mer_id'], $datas = [
'source_mer_id'=>$cityMerchant['mer_id'], 'product_id' => $product_id,
'street_code'=>$merchant['street_id'], 'mer_id' => $merchant['mer_id'],
'type_id'=>$merchant['type_id'], 'source_mer_id' => $cityMerchant['mer_id'],
'category_id'=>$merchant['category_id'], 'street_code' => $merchant['street_id'],
'weight'=>1, 'type_id' => $merchant['type_id'],
'status'=>1, 'category_id' => $merchant['category_id'],
'create_time'=>date('Y-m-d H:i:s'), 'weight' => 1,
]; 'status' => 1,
Db::name('cloud_product')->insert($datas); 'create_time' => date('Y-m-d H:i:s'),
];
Db::name('cloud_product')->insert($datas);
}
} }
} }

View File

@ -23,7 +23,7 @@ class MerchantIntentionValidate extends Validate
'phone|手机号' => 'require|mobile', 'phone|手机号' => 'require|mobile',
'name|姓名' => 'require', 'name|姓名' => 'require',
'mer_name|姓名' => 'require|max:32', 'mer_name|姓名' => 'require|max:32',
'merchant_category_name|商户分类' => 'require', 'merchant_category_id|商户分类' => 'require',
'mer_type_id|店铺类型' => 'integer', 'mer_type_id|店铺类型' => 'integer',
'code|验证码' => 'require', 'code|验证码' => 'require',
'images|资质' => 'array', 'images|资质' => 'array',

View File

@ -59,7 +59,8 @@
"guzzlehttp/guzzle": "^6.5", "guzzlehttp/guzzle": "^6.5",
"topthink/think-api": "1.0.27", "topthink/think-api": "1.0.27",
"intervention/image": "^2.7", "intervention/image": "^2.7",
"fastknife/ajcaptcha": "^1.2" "fastknife/ajcaptcha": "^1.2",
"nelexa/zip": "^4.0"
}, },
"require-dev": { "require-dev": {
"symfony/var-dumper": "^4.2", "symfony/var-dumper": "^4.2",

65
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f75dd06462534352b6436e333bd0daeb", "content-hash": "60838a051e04cfb13dd75049f7540171",
"packages": [ "packages": [
{ {
"name": "adbario/php-dot-notation", "name": "adbario/php-dot-notation",
@ -2024,6 +2024,69 @@
], ],
"time": "2022-08-04T09:53:51+00:00" "time": "2022-08-04T09:53:51+00:00"
}, },
{
"name": "nelexa/zip",
"version": "4.0.2",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/nelexa/zip/4.0.2/nelexa-zip-4.0.2.zip",
"reference": "88a1b6549be813278ff2dd3b6b2ac188827634a7",
"shasum": ""
},
"require": {
"ext-zlib": "*",
"php": "^7.4 || ^8.0",
"psr/http-message": "*",
"symfony/finder": "*"
},
"require-dev": {
"ext-bz2": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-iconv": "*",
"ext-openssl": "*",
"ext-xml": "*",
"friendsofphp/php-cs-fixer": "^3.4.0",
"guzzlehttp/psr7": "^1.6",
"phpunit/phpunit": "^9",
"symfony/http-foundation": "*",
"symfony/var-dumper": "*",
"vimeo/psalm": "^4.6"
},
"suggest": {
"ext-bz2": "Needed to support BZIP2 compression",
"ext-fileinfo": "Needed to get mime-type file",
"ext-iconv": "Needed to support convert zip entry name to requested character encoding",
"ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpZip\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Ne-Lexa",
"email": "alexey@nelexa.ru",
"role": "Developer"
}
],
"description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.",
"homepage": "https://github.com/Ne-Lexa/php-zip",
"keywords": [
"archive",
"extract",
"unzip",
"winzip",
"zip",
"ziparchive"
],
"time": "2022-06-17T11:17:46+00:00"
},
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",
"version": "2.71.0", "version": "2.71.0",

View File

@ -32,7 +32,7 @@ return [
'task_max_request' => 2000, 'task_max_request' => 2000,
'enable_static_handler' => true, 'enable_static_handler' => true,
'document_root' => root_path('public'), 'document_root' => root_path('public'),
'package_max_length' => 50 * 1024 * 1024, 'package_max_length' => 100 * 1024 * 1024,
'buffer_output_size' => 10 * 1024 * 1024, 'buffer_output_size' => 10 * 1024 * 1024,
'socket_buffer_size' => 128 * 1024 * 1024, 'socket_buffer_size' => 128 * 1024 * 1024,
'max_request' => 3000, 'max_request' => 3000,

View File

@ -19,7 +19,7 @@ return [
//上传文件大小 //上传文件大小
'filesize' => 52428800, 'filesize' => 52428800,
//上传文件后缀类型 //上传文件后缀类型
'fileExt' => ['jpg', 'jpeg', 'png', 'gif', 'pem', 'mp3', 'wma', 'wav', 'amr', 'mp4', 'key', 'xlsx', 'xls', 'ico', 'apk', 'ipa'], 'fileExt' => ['jpg', 'jpeg', 'png', 'gif', 'pem', 'mp3', 'wma', 'wav', 'amr', 'mp4', 'key', 'xlsx', 'xls', 'ico', 'apk', 'ipa','wgt'],
//上传文件类型 //上传文件类型
'fileMime' => ['image/jpeg', 'image/gif', 'image/png', 'text/plain', 'audio/mpeg', 'image/vnd.microsoft.icon'], 'fileMime' => ['image/jpeg', 'image/gif', 'image/png', 'text/plain', 'audio/mpeg', 'image/vnd.microsoft.icon'],
//驱动模式 //驱动模式

148
crmeb/jobs/ImportPicJob.php Normal file
View File

@ -0,0 +1,148 @@
<?php
namespace crmeb\jobs;
use think\facade\Db;
use crmeb\services\UploadService;
use Exception;
use crmeb\interfaces\JobInterface;
use think\facade\Log;
class ImportPicJob implements JobInterface
{
public function fire($job, $data)
{
Log::error('开始导入商品图片:' . $job->attempts());
if ($job->attempts() > 3) {
$job->delete();
$this->failed($data);
}
$directory = $data['path'];
$mer_id = $data['mer_id'];
$files = scandir($directory);
$dir = 'def/' . date('Y-m-d');
$upload = UploadService::create();
try {
/**循环目录 */
foreach ($files as $file) {
if ($file === '.' || $file === '..' || $file === '__MACOSX') {
continue;
}
if (!is_dir($directory . '/' . $file)) {
continue;
}
$files_two = scandir($directory . '/' . $file);
$image_extensions = array('jpg', 'jpeg', 'png');
$image = '';
$slider_image = [];
$details = [];
$sku_arr = [];
/**清洗图片 */
foreach ($files_two as $file_two) {
if ($file_two === '.' || $file_two === '..' || $file_two === '__MACOSX') {
continue;
}
$arr = explode('.', $file_two);
if (in_array($arr[1], $image_extensions)) {
/**首图 */
$images[] = $file_two;
if ($image == '' && is_numeric($arr[0])) {
$image = $directory . '/' . $file . '/' . $file_two;
continue;
}
/**轮播图 */
if (is_numeric($arr[0]) && count($slider_image) < 4) {
$slider_image[] = $directory . '/' . $file . '/' . $file_two;
continue;
}
/**详情图 */
if (is_numeric($arr[0])) {
$details[] = $directory . '/' . $file_two;
continue;
}
/**sku图 */
$sku = explode('==', $arr[0]);
if ($sku) {
$sku = implode(',', $sku);
$sku_arr[$sku] = $directory . '/' . $file . '/' . $file_two;
}
}
}
$where = ['mer_id' => $mer_id, 'is_del' => 0];
$update = [];
$update_content['title'] = '';
$update_content['image'] = [];
$find = Db::name('store_product')->where($where)->where('store_name', $file)->find();
if ($find) {
/**更新商品图片 */
$image = $upload->to($dir)->stream(file_get_contents($image));
$update['image'] = $image->filePath;
foreach ($slider_image as $k => $v) {
$oss = $upload->to($dir)->stream(file_get_contents($v));
$update['slider_image'][] = $oss->filePath;
}
if (isset($update['slider_image'])) {
$update['slider_image'] = implode(',', $update['slider_image']);
}
Db::name('store_product')->where('product_id', $find['product_id'])->update($update);
/**更新规格图片 */
foreach ($sku_arr as $k => $v) {
$store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])->find();
if ($store_product_attr_value) {
$oss = $upload->to($dir)->stream(file_get_contents($v));
Db::name('store_product_attr_value')
->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])
->update(['image' => $oss->filePath]);
}
}
/**更新详情图片 */
$store_product_content = Db::name('store_product_content')->where(['product_id' => $find['product_id']])->find();
foreach ($details as $k => $v) {
$oss = $upload->to($dir)->stream(file_get_contents($v));
$update_content['image'][] = $oss->filePath;
}
if ($store_product_content) {
if (isset($update_content['image']) && !empty($update_content['image'])) {
Db::name('store_product_content')
->where(['product_id' => $find['product_id']])
->update(['content' => json_encode($update_content)]);
}
} else {
$update_content['product_id'] = $find['product_id'];
Db::name('store_product_content')
->insert(['product_id' => $find['product_id'], 'type' => 1, 'content' => json_encode($update_content)]);
}
}
}
} catch (Exception $e) {
$data['product_id'] = $find['product_id'];
$data['mer_id'] = $data['mer_id'];
$data['store_name'] = $find['store_name'];
$data['content'] = $e->getMessage();
$this->create_product_import_log($data, 0);
}
$job->delete();
}
public function failed($data)
{
Log::error('导入商品图片失败:' . json_encode($data));
// TODO: Implement failed() method.
}
public function create_product_import_log($data, $status = 1)
{
$data = [
'product_id' => $data['product_id'],
'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

@ -325,6 +325,7 @@ class SpreadsheetExcelService
$ret = []; $ret = [];
if (in_array($ext, ['Xlsx', 'Xls'])) { if (in_array($ext, ['Xlsx', 'Xls'])) {
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($ext); $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($ext);
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($filePath); $spreadsheet = $reader->load($filePath);
$sheet = $spreadsheet->getActiveSheet(); $sheet = $spreadsheet->getActiveSheet();
$row_count = $sheet->getHighestDataRow();//取得总行数 $row_count = $sheet->getHighestDataRow();//取得总行数

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.selWidth[data-v-5efee90a]{width:330px}.title[data-v-5efee90a]{margin-bottom:16px;color:#17233d;font-weight:500;font-size:14px}.head[data-v-2f11caa9]{padding:30px 35px 25px}.head .full[data-v-2f11caa9]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.head .full .order_icon[data-v-2f11caa9]{width:60px;height:60px}.head .full .iconfont[data-v-2f11caa9]{color:#1890ff}.head .full .iconfont.sale-after[data-v-2f11caa9]{color:#90add5}.head .full .text[data-v-2f11caa9]{-ms-flex-item-align:center;align-self:center;-webkit-box-flex:1;-ms-flex:1;flex:1;min-width:0;padding-left:12px;font-size:13px;color:#606266}.head .full .text .title[data-v-2f11caa9]{margin-bottom:10px;font-weight:500;font-size:16px;line-height:16px;color:rgba(0,0,0,.85)}.head .full .text .order-num[data-v-2f11caa9]{padding-top:10px;white-space:nowrap}.head .list[data-v-2f11caa9]{display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:20px;overflow:hidden;list-style:none;padding:0}.head .list .item[data-v-2f11caa9]{-webkit-box-flex:0;-ms-flex:none;flex:none;width:200px;font-size:14px;line-height:14px;color:rgba(0,0,0,.85)}.head .list .item .title[data-v-2f11caa9]{margin-bottom:12px;font-size:13px;line-height:13px;color:#666}.head .list .item .value1[data-v-2f11caa9]{color:#f56022}.head .list .item .value2[data-v-2f11caa9]{color:#1bbe6b}.head .list .item .value3[data-v-2f11caa9]{color:#1890ff}.head .list .item .value4[data-v-2f11caa9]{color:#6a7b9d}.head .list .item .value5[data-v-2f11caa9]{color:#f5222d}.el-tabs--border-card[data-v-2f11caa9]{-webkit-box-shadow:none;box-shadow:none;border-bottom:none}.section[data-v-2f11caa9]{padding:20px 0 5px;border-bottom:1px dashed #eee}.section .title[data-v-2f11caa9]{padding-left:10px;border-left:3px solid #1890ff;font-size:15px;line-height:15px;color:#303133}.section .list[data-v-2f11caa9]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;list-style:none;padding:0}.section .item[data-v-2f11caa9]{-webkit-box-flex:0;-ms-flex:0 0 33.33333%;flex:0 0 33.33333%;display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:16px;font-size:13px;color:#606266}.section .item[data-v-2f11caa9]:nth-child(3n+1){padding-right:20px}.section .item[data-v-2f11caa9]:nth-child(3n+2){padding-right:10px;padding-left:10px}.section .item[data-v-2f11caa9]:nth-child(3n+3){padding-left:20px}.section .value[data-v-2f11caa9]{-webkit-box-flex:1;-ms-flex:1;flex:1}.section .value image[data-v-2f11caa9]{display:inline-block;width:40px;height:40px;margin:0 12px 12px 0;vertical-align:middle}.tab[data-v-2f11caa9]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.tab .el-image[data-v-2f11caa9]{width:36px;height:36px;margin-right:10px}[data-v-2f11caa9] .el-drawer__body{overflow:auto}.gary[data-v-2f11caa9]{color:#aaa}.logistics[data-v-2f11caa9]{-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:10px 0}.logistics .logistics_img[data-v-2f11caa9]{width:45px;height:45px;margin-right:12px}.logistics .logistics_img img[data-v-2f11caa9]{width:100%;height:100%}.logistics .logistics_cent span[data-v-2f11caa9]{display:block;font-size:12px}.tabBox_tit[data-v-2f11caa9]{width:53%;font-size:12px!important;margin:0 2px 0 10px;letter-spacing:1px;padding:5px 0;-webkit-box-sizing:border-box;box-sizing:border-box}.title[data-v-96d4296a]{margin-bottom:16px;color:#17233d;font-weight:500;font-size:14px}.description-term[data-v-96d4296a]{display:table-cell;padding-bottom:10px;line-height:20px;width:50%;font-size:12px}.pictures[data-v-6419e29e]{max-width:100%}.area-desc[data-v-6419e29e]{margin:0;color:#999;font-size:12px}.selWidth[data-v-6419e29e]{width:300px}.spBlock[data-v-6419e29e]{cursor:pointer;display:block;padding:5px 0}.check[data-v-6419e29e]{color:#00a2d4}.el-dropdown-link[data-v-6419e29e]{cursor:pointer;color:#409eff;font-size:12px}.el-icon-arrow-down[data-v-6419e29e]{font-size:12px}.tabBox_tit[data-v-6419e29e]{width:53%;font-size:12px!important;margin:0 2px 0 10px;letter-spacing:1px;padding:5px 0;-webkit-box-sizing:border-box;box-sizing:border-box}[data-v-6419e29e] .row-bg .cell{color:red!important}.headTab[data-v-6419e29e]{position:relative}.headTab .headBtn[data-v-6419e29e]{position:absolute;right:0;top:-6px}.dropdown[data-v-6419e29e]{padding:0 10px;border:1px solid #409eff;margin-right:10px;line-height:28px;border-radius:4px} .selWidth[data-v-4c2bfa98]{width:330px}.title[data-v-4c2bfa98]{margin-bottom:16px;color:#17233d;font-weight:500;font-size:14px}.head[data-v-2f11caa9]{padding:30px 35px 25px}.head .full[data-v-2f11caa9]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.head .full .order_icon[data-v-2f11caa9]{width:60px;height:60px}.head .full .iconfont[data-v-2f11caa9]{color:#1890ff}.head .full .iconfont.sale-after[data-v-2f11caa9]{color:#90add5}.head .full .text[data-v-2f11caa9]{-ms-flex-item-align:center;align-self:center;-webkit-box-flex:1;-ms-flex:1;flex:1;min-width:0;padding-left:12px;font-size:13px;color:#606266}.head .full .text .title[data-v-2f11caa9]{margin-bottom:10px;font-weight:500;font-size:16px;line-height:16px;color:rgba(0,0,0,.85)}.head .full .text .order-num[data-v-2f11caa9]{padding-top:10px;white-space:nowrap}.head .list[data-v-2f11caa9]{display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:20px;overflow:hidden;list-style:none;padding:0}.head .list .item[data-v-2f11caa9]{-webkit-box-flex:0;-ms-flex:none;flex:none;width:200px;font-size:14px;line-height:14px;color:rgba(0,0,0,.85)}.head .list .item .title[data-v-2f11caa9]{margin-bottom:12px;font-size:13px;line-height:13px;color:#666}.head .list .item .value1[data-v-2f11caa9]{color:#f56022}.head .list .item .value2[data-v-2f11caa9]{color:#1bbe6b}.head .list .item .value3[data-v-2f11caa9]{color:#1890ff}.head .list .item .value4[data-v-2f11caa9]{color:#6a7b9d}.head .list .item .value5[data-v-2f11caa9]{color:#f5222d}.el-tabs--border-card[data-v-2f11caa9]{-webkit-box-shadow:none;box-shadow:none;border-bottom:none}.section[data-v-2f11caa9]{padding:20px 0 5px;border-bottom:1px dashed #eee}.section .title[data-v-2f11caa9]{padding-left:10px;border-left:3px solid #1890ff;font-size:15px;line-height:15px;color:#303133}.section .list[data-v-2f11caa9]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;list-style:none;padding:0}.section .item[data-v-2f11caa9]{-webkit-box-flex:0;-ms-flex:0 0 33.33333%;flex:0 0 33.33333%;display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:16px;font-size:13px;color:#606266}.section .item[data-v-2f11caa9]:nth-child(3n+1){padding-right:20px}.section .item[data-v-2f11caa9]:nth-child(3n+2){padding-right:10px;padding-left:10px}.section .item[data-v-2f11caa9]:nth-child(3n+3){padding-left:20px}.section .value[data-v-2f11caa9]{-webkit-box-flex:1;-ms-flex:1;flex:1}.section .value image[data-v-2f11caa9]{display:inline-block;width:40px;height:40px;margin:0 12px 12px 0;vertical-align:middle}.tab[data-v-2f11caa9]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.tab .el-image[data-v-2f11caa9]{width:36px;height:36px;margin-right:10px}[data-v-2f11caa9] .el-drawer__body{overflow:auto}.gary[data-v-2f11caa9]{color:#aaa}.logistics[data-v-2f11caa9]{-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:10px 0}.logistics .logistics_img[data-v-2f11caa9]{width:45px;height:45px;margin-right:12px}.logistics .logistics_img img[data-v-2f11caa9]{width:100%;height:100%}.logistics .logistics_cent span[data-v-2f11caa9]{display:block;font-size:12px}.tabBox_tit[data-v-2f11caa9]{width:53%;font-size:12px!important;margin:0 2px 0 10px;letter-spacing:1px;padding:5px 0;-webkit-box-sizing:border-box;box-sizing:border-box}.title[data-v-96d4296a]{margin-bottom:16px;color:#17233d;font-weight:500;font-size:14px}.description-term[data-v-96d4296a]{display:table-cell;padding-bottom:10px;line-height:20px;width:50%;font-size:12px}.pictures[data-v-488b8196]{max-width:100%}.area-desc[data-v-488b8196]{margin:0;color:#999;font-size:12px}.selWidth[data-v-488b8196]{width:300px}.spBlock[data-v-488b8196]{cursor:pointer;display:block;padding:5px 0}.check[data-v-488b8196]{color:#00a2d4}.el-dropdown-link[data-v-488b8196]{cursor:pointer;color:#409eff;font-size:12px}.el-icon-arrow-down[data-v-488b8196]{font-size:12px}.tabBox_tit[data-v-488b8196]{width:53%;font-size:12px!important;margin:0 2px 0 10px;letter-spacing:1px;padding:5px 0;-webkit-box-sizing:border-box;box-sizing:border-box}[data-v-488b8196] .row-bg .cell{color:red!important}.headTab[data-v-488b8196]{position:relative}.headTab .headBtn[data-v-488b8196]{position:absolute;right:0;top:-6px}.dropdown[data-v-488b8196]{padding:0 10px;border:1px solid #409eff;margin-right:10px;line-height:28px;border-radius:4px}

View File

@ -1 +1 @@
.title[data-v-3500ed7a]{margin-bottom:16px;color:#17233d;font-weight:500;font-size:14px}.description-term[data-v-3500ed7a]{display:table-cell;padding-bottom:10px;line-height:20px;width:50%;font-size:12px}[data-v-3cd1b9b0] .el-cascader{display:block}.dialog-scustom[data-v-3cd1b9b0]{width:1200px;height:600px}.ela-btn[data-v-3cd1b9b0]{color:#2d8cf0}.Box .ivu-radio-wrapper[data-v-3cd1b9b0]{margin-right:25px}.Box .numPut[data-v-3cd1b9b0]{width:80%!important}.lunBox[data-v-3cd1b9b0]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;border:1px solid #0bb20c}.pictrueBox[data-v-3cd1b9b0]{display:inline-block}.pictrue[data-v-3cd1b9b0]{width:50px;height:50px;border:1px dotted rgba(0,0,0,.1);display:inline-block;position:relative;cursor:pointer}.pictrue img[data-v-3cd1b9b0]{width:100%;height:100%}.pictrueTab[data-v-3cd1b9b0]{width:40px!important;height:40px!important}.upLoad[data-v-3cd1b9b0]{width:40px;height:40px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:rgba(0,0,0,.02);cursor:pointer}.ft[data-v-3cd1b9b0]{color:red}.buttonGroup[data-v-3cd1b9b0]{position:relative;display:inline-block;vertical-align:middle;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-tap-highlight-color:rgba(0,0,0,0)}.buttonGroup .small-btn[data-v-3cd1b9b0]{position:relative;float:left;height:24px;padding:0 7px;font-size:14px;border-radius:3px}.buttonGroup .small-btn[data-v-3cd1b9b0]:first-child{margin-left:0;border-bottom-right-radius:0;border-top-right-radius:0}.virtual_boder[data-v-3cd1b9b0]{border:1px solid #1890ff}.virtual_boder2[data-v-3cd1b9b0]{border:1px solid #e7e7e7}.virtual_san[data-v-3cd1b9b0]{position:absolute;bottom:0;right:0;width:0;height:0;border-bottom:26px solid #1890ff;border-left:26px solid transparent}.virtual_dui[data-v-3cd1b9b0]{position:absolute;bottom:-2px;right:2px;color:#fff;font-family:system-ui}.virtual[data-v-3cd1b9b0]{width:120px;height:60px;background:#fff;border-radius:3px;float:left;text-align:center;padding-top:8px;position:relative;cursor:pointer;line-height:23px}.virtual .virtual_top[data-v-3cd1b9b0]{font-size:14px;font-weight:600;color:rgba(0,0,0,.85)}.virtual .virtual_bottom[data-v-3cd1b9b0]{font-size:12px;font-weight:400;color:#999}.virtual[data-v-3cd1b9b0]:nth-child(2n){margin:0 12px}[data-v-7d87bc0d] .el-cascader{display:block}.ela-btn[data-v-7d87bc0d]{color:#2d8cf0}.priceBox[data-v-7d87bc0d]{width:80px}.pictrue[data-v-7d87bc0d]{width:50px;height:50px;border:1px dotted rgba(0,0,0,.1);display:inline-block;position:relative;cursor:pointer}.pictrue img[data-v-7d87bc0d]{width:100%;height:100%}[data-v-7d87bc0d] .el-input-number__decrease,[data-v-7d87bc0d] .el-input-number__increase{display:none}[data-v-7d87bc0d] .el-input-number.is-controls-right .el-input__inner,[data-v-7d87bc0d] .el-input__inner{padding:0 5px}.pictrueTab[data-v-7d87bc0d]{width:40px!important;height:40px!important}.upLoad[data-v-7d87bc0d]{width:40px;height:40px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:rgba(0,0,0,.02);cursor:pointer}.bg[data-v-08836151]{z-index:100;position:fixed;left:0;top:0;width:100%;height:100%;background:rgba(0,0,0,.5)}.goods_detail .goods_detail_wrapper[data-v-08836151]{z-index:-10}[data-v-08836151] table.el-input__inner{padding:0}.demo-table-expand[data-v-08836151]{font-size:0}.demo-table-expand1[data-v-08836151] label{width:77px!important;color:#99a9bf}.demo-table-expand .el-form-item[data-v-08836151]{margin-right:0;margin-bottom:0;width:33.33%}.selWidth[data-v-08836151]{width:350px!important}.seachTiele[data-v-08836151]{line-height:35px} .title[data-v-3500ed7a]{margin-bottom:16px;color:#17233d;font-weight:500;font-size:14px}.description-term[data-v-3500ed7a]{display:table-cell;padding-bottom:10px;line-height:20px;width:50%;font-size:12px}[data-v-3cd1b9b0] .el-cascader{display:block}.dialog-scustom[data-v-3cd1b9b0]{width:1200px;height:600px}.ela-btn[data-v-3cd1b9b0]{color:#2d8cf0}.Box .ivu-radio-wrapper[data-v-3cd1b9b0]{margin-right:25px}.Box .numPut[data-v-3cd1b9b0]{width:80%!important}.lunBox[data-v-3cd1b9b0]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;border:1px solid #0bb20c}.pictrueBox[data-v-3cd1b9b0]{display:inline-block}.pictrue[data-v-3cd1b9b0]{width:50px;height:50px;border:1px dotted rgba(0,0,0,.1);display:inline-block;position:relative;cursor:pointer}.pictrue img[data-v-3cd1b9b0]{width:100%;height:100%}.pictrueTab[data-v-3cd1b9b0]{width:40px!important;height:40px!important}.upLoad[data-v-3cd1b9b0]{width:40px;height:40px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:rgba(0,0,0,.02);cursor:pointer}.ft[data-v-3cd1b9b0]{color:red}.buttonGroup[data-v-3cd1b9b0]{position:relative;display:inline-block;vertical-align:middle;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-tap-highlight-color:rgba(0,0,0,0)}.buttonGroup .small-btn[data-v-3cd1b9b0]{position:relative;float:left;height:24px;padding:0 7px;font-size:14px;border-radius:3px}.buttonGroup .small-btn[data-v-3cd1b9b0]:first-child{margin-left:0;border-bottom-right-radius:0;border-top-right-radius:0}.virtual_boder[data-v-3cd1b9b0]{border:1px solid #1890ff}.virtual_boder2[data-v-3cd1b9b0]{border:1px solid #e7e7e7}.virtual_san[data-v-3cd1b9b0]{position:absolute;bottom:0;right:0;width:0;height:0;border-bottom:26px solid #1890ff;border-left:26px solid transparent}.virtual_dui[data-v-3cd1b9b0]{position:absolute;bottom:-2px;right:2px;color:#fff;font-family:system-ui}.virtual[data-v-3cd1b9b0]{width:120px;height:60px;background:#fff;border-radius:3px;float:left;text-align:center;padding-top:8px;position:relative;cursor:pointer;line-height:23px}.virtual .virtual_top[data-v-3cd1b9b0]{font-size:14px;font-weight:600;color:rgba(0,0,0,.85)}.virtual .virtual_bottom[data-v-3cd1b9b0]{font-size:12px;font-weight:400;color:#999}.virtual[data-v-3cd1b9b0]:nth-child(2n){margin:0 12px}[data-v-7d87bc0d] .el-cascader{display:block}.ela-btn[data-v-7d87bc0d]{color:#2d8cf0}.priceBox[data-v-7d87bc0d]{width:80px}.pictrue[data-v-7d87bc0d]{width:50px;height:50px;border:1px dotted rgba(0,0,0,.1);display:inline-block;position:relative;cursor:pointer}.pictrue img[data-v-7d87bc0d]{width:100%;height:100%}[data-v-7d87bc0d] .el-input-number__decrease,[data-v-7d87bc0d] .el-input-number__increase{display:none}[data-v-7d87bc0d] .el-input-number.is-controls-right .el-input__inner,[data-v-7d87bc0d] .el-input__inner{padding:0 5px}.pictrueTab[data-v-7d87bc0d]{width:40px!important;height:40px!important}.upLoad[data-v-7d87bc0d]{width:40px;height:40px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:rgba(0,0,0,.02);cursor:pointer}.bg[data-v-e9391b98]{z-index:100;position:fixed;left:0;top:0;width:100%;height:100%;background:rgba(0,0,0,.5)}.goods_detail .goods_detail_wrapper[data-v-e9391b98]{z-index:-10}[data-v-e9391b98] table.el-input__inner{padding:0}.demo-table-expand[data-v-e9391b98]{font-size:0}.demo-table-expand1[data-v-e9391b98] label{width:77px!important;color:#99a9bf}.demo-table-expand .el-form-item[data-v-e9391b98]{margin-right:0;margin-bottom:0;width:33.33%}.selWidth[data-v-e9391b98]{width:350px!important}.seachTiele[data-v-e9391b98]{line-height:35px}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-0d2c1415","chunk-2d0da983"],{4553:function(e,t,i){"use strict";i.r(t);var o=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",[i("div",{staticClass:"mt20 ml20"},[i("el-input",{staticStyle:{width:"300px"},attrs:{placeholder:"请输入视频链接"},model:{value:e.videoLink,callback:function(t){e.videoLink=t},expression:"videoLink"}}),e._v(" "),i("input",{ref:"refid",staticStyle:{display:"none"},attrs:{type:"file"},on:{change:e.zh_uploadFile_change}}),e._v(" "),i("el-button",{staticClass:"ml10",attrs:{type:"primary",icon:"ios-cloud-upload-outline"},on:{click:e.zh_uploadFile}},[e._v(e._s(e.videoLink?"确认添加":"上传视频"))]),e._v(" "),e.upload.videoIng?i("el-progress",{staticStyle:{"margin-top":"20px"},attrs:{"stroke-width":20,percentage:e.progress,"text-inside":!0}}):e._e(),e._v(" "),e.formValidate.video_link?i("div",{staticClass:"iview-video-style"},[i("video",{staticStyle:{width:"100%",height:"100%!important","border-radius":"10px"},attrs:{src:e.formValidate.video_link,controls:"controls"}},[e._v("\n 您的浏览器不支持 video 标签。\n ")]),e._v(" "),i("div",{staticClass:"mark"}),e._v(" "),i("i",{staticClass:"iconv el-icon-delete",on:{click:e.delVideo}})]):e._e()],1),e._v(" "),i("div",{staticClass:"mt50 ml20"},[i("el-button",{attrs:{type:"primary"},on:{click:e.uploads}},[e._v("确认")])],1)])},a=[],n=(i("7f7f"),i("c4c8")),s=(i("6bef"),{name:"Vide11o",props:{isDiy:{type:Boolean,default:!1}},data:function(){return{upload:{videoIng:!1},progress:20,videoLink:"",formValidate:{video_link:""}}},methods:{delVideo:function(){var e=this;e.$set(e.formValidate,"video_link","")},zh_uploadFile:function(){this.videoLink?this.formValidate.video_link=this.videoLink:this.$refs.refid.click()},zh_uploadFile_change:function(e){var t=this,i=e.target.files[0].name.substr(e.target.files[0].name.indexOf("."));if(".mp4"!==i)return t.$message.error("只能上传MP4文件");Object(n["db"])().then((function(i){t.$videoCloud.videoUpload({type:i.data.type,evfile:e,res:i,uploading:function(e,i){t.upload.videoIng=e,console.log(e,i)}}).then((function(e){t.formValidate.video_link=e.url||e.data.src,t.$message.success("视频上传成功"),t.progress=100,t.upload.videoIng=!1})).catch((function(e){t.$message.error(e)}))}))},uploads:function(){this.formValidate.video_link||this.videoLink?!this.videoLink||this.formValidate.video_link?this.isDiy?this.$emit("getVideo",this.formValidate.video_link):nowEditor&&(nowEditor.dialog.close(!0),nowEditor.editor.setContent("<video src='"+this.formValidate.video_link+"' controls='controls'></video>",!0)):this.$message.error("请点击确认添加按钮!"):this.$message.error("您还没有上传视频!")}}}),r=s,d=(i("8307"),i("2877")),l=Object(d["a"])(r,o,a,!1,null,"732b6bbd",null);t["default"]=l.exports},"6bef":function(e,t,i){"use strict";i.r(t);i("28a5"),i("a481");(function(){if(window.frameElement&&window.frameElement.id){var e=window.parent,t=e.$EDITORUI[window.frameElement.id.replace(/_iframe$/,"")],i=t.editor,o=e.UE,a=o.dom.domUtils,n=o.utils,s=(o.browser,o.ajax,function(e){return document.getElementById(e)});window.nowEditor={editor:i,dialog:t},n.loadFile(document,{href:i.options.themePath+i.options.theme+"/dialogbase.css?cache="+Math.random(),tag:"link",type:"text/css",rel:"stylesheet"});var r=i.getLang(t.className.split("-")[2]);r&&a.on(window,"load",(function(){var e=i.options.langPath+i.options.lang+"/images/";for(var t in r["static"]){var o=s(t);if(o){var d=o.tagName,l=r["static"][t];switch(l.src&&(l=n.extend({},l,!1),l.src=e+l.src),l.style&&(l=n.extend({},l,!1),l.style=l.style.replace(/url\s*\(/g,"url("+e)),d.toLowerCase()){case"var":o.parentNode.replaceChild(document.createTextNode(l),o);break;case"select":for(var c,u=o.options,v=0;c=u[v];)c.innerHTML=l.options[v++];for(var p in l)"options"!=p&&o.setAttribute(p,l[p]);break;default:a.setAttributes(o,l)}}}}))}})()},8307:function(e,t,i){"use strict";i("f5ee")},f5ee:function(e,t,i){}}]); (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-0d2c1415","chunk-2d0da983"],{4553:function(e,t,i){"use strict";i.r(t);var o=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",[i("div",{staticClass:"mt20 ml20"},[i("el-input",{staticStyle:{width:"300px"},attrs:{placeholder:"请输入视频链接"},model:{value:e.videoLink,callback:function(t){e.videoLink=t},expression:"videoLink"}}),e._v(" "),i("input",{ref:"refid",staticStyle:{display:"none"},attrs:{type:"file"},on:{change:e.zh_uploadFile_change}}),e._v(" "),i("el-button",{staticClass:"ml10",attrs:{type:"primary",icon:"ios-cloud-upload-outline"},on:{click:e.zh_uploadFile}},[e._v(e._s(e.videoLink?"确认添加":"上传视频"))]),e._v(" "),e.upload.videoIng?i("el-progress",{staticStyle:{"margin-top":"20px"},attrs:{"stroke-width":20,percentage:e.progress,"text-inside":!0}}):e._e(),e._v(" "),e.formValidate.video_link?i("div",{staticClass:"iview-video-style"},[i("video",{staticStyle:{width:"100%",height:"100%!important","border-radius":"10px"},attrs:{src:e.formValidate.video_link,controls:"controls"}},[e._v("\n 您的浏览器不支持 video 标签。\n ")]),e._v(" "),i("div",{staticClass:"mark"}),e._v(" "),i("i",{staticClass:"iconv el-icon-delete",on:{click:e.delVideo}})]):e._e()],1),e._v(" "),i("div",{staticClass:"mt50 ml20"},[i("el-button",{attrs:{type:"primary"},on:{click:e.uploads}},[e._v("确认")])],1)])},a=[],n=(i("7f7f"),i("c4c8")),s=(i("6bef"),{name:"Vide11o",props:{isDiy:{type:Boolean,default:!1}},data:function(){return{upload:{videoIng:!1},progress:20,videoLink:"",formValidate:{video_link:""}}},methods:{delVideo:function(){var e=this;e.$set(e.formValidate,"video_link","")},zh_uploadFile:function(){this.videoLink?this.formValidate.video_link=this.videoLink:this.$refs.refid.click()},zh_uploadFile_change:function(e){var t=this,i=e.target.files[0].name.substr(e.target.files[0].name.indexOf("."));if(".mp4"!==i)return t.$message.error("只能上传MP4文件");Object(n["fb"])().then((function(i){t.$videoCloud.videoUpload({type:i.data.type,evfile:e,res:i,uploading:function(e,i){t.upload.videoIng=e,console.log(e,i)}}).then((function(e){t.formValidate.video_link=e.url||e.data.src,t.$message.success("视频上传成功"),t.progress=100,t.upload.videoIng=!1})).catch((function(e){t.$message.error(e)}))}))},uploads:function(){this.formValidate.video_link||this.videoLink?!this.videoLink||this.formValidate.video_link?this.isDiy?this.$emit("getVideo",this.formValidate.video_link):nowEditor&&(nowEditor.dialog.close(!0),nowEditor.editor.setContent("<video src='"+this.formValidate.video_link+"' controls='controls'></video>",!0)):this.$message.error("请点击确认添加按钮!"):this.$message.error("您还没有上传视频!")}}}),r=s,d=(i("8307"),i("2877")),l=Object(d["a"])(r,o,a,!1,null,"732b6bbd",null);t["default"]=l.exports},"6bef":function(e,t,i){"use strict";i.r(t);i("28a5"),i("a481");(function(){if(window.frameElement&&window.frameElement.id){var e=window.parent,t=e.$EDITORUI[window.frameElement.id.replace(/_iframe$/,"")],i=t.editor,o=e.UE,a=o.dom.domUtils,n=o.utils,s=(o.browser,o.ajax,function(e){return document.getElementById(e)});window.nowEditor={editor:i,dialog:t},n.loadFile(document,{href:i.options.themePath+i.options.theme+"/dialogbase.css?cache="+Math.random(),tag:"link",type:"text/css",rel:"stylesheet"});var r=i.getLang(t.className.split("-")[2]);r&&a.on(window,"load",(function(){var e=i.options.langPath+i.options.lang+"/images/";for(var t in r["static"]){var o=s(t);if(o){var d=o.tagName,l=r["static"][t];switch(l.src&&(l=n.extend({},l,!1),l.src=e+l.src),l.style&&(l=n.extend({},l,!1),l.style=l.style.replace(/url\s*\(/g,"url("+e)),d.toLowerCase()){case"var":o.parentNode.replaceChild(document.createTextNode(l),o);break;case"select":for(var c,u=o.options,v=0;c=u[v];)c.innerHTML=l.options[v++];for(var f in l)"options"!=f&&o.setAttribute(f,l[f]);break;default:a.setAttributes(o,l)}}}}))}})()},8307:function(e,t,i){"use strict";i("f5ee")},f5ee:function(e,t,i){}}]);

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0c212a"],{"496e":function(t,e,a){"use strict";a.r(e);var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"divBox"},[a("el-card",{staticClass:"box-card"},[a("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:t.add}},[t._v("添加商品规格")])],1),t._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],staticStyle:{width:"100%"},attrs:{data:t.tableData.data,size:"small","highlight-current-row":""}},[a("el-table-column",{attrs:{prop:"attr_template_id",label:"ID","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"template_name",label:"规格名称","min-width":"150"}}),t._v(" "),a("el-table-column",{attrs:{label:"商品规格","min-width":"150"},scopedSlots:t._u([{key:"default",fn:function(e){return t._l(e.row.template_value,(function(e,n){return a("span",{key:n,staticClass:"mr10",domProps:{textContent:t._s(e.value)}})}))}}])}),t._v(" "),a("el-table-column",{attrs:{label:"商品属性","min-width":"300"},scopedSlots:t._u([{key:"default",fn:function(e){return t._l(e.row.template_value,(function(e,n){return a("div",{key:n,domProps:{textContent:t._s(e.detail.join(","))}})}))}}])}),t._v(" "),a("el-table-column",{attrs:{label:"操作","min-width":"100",fixed:"right"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.onEdit(e.row)}}},[t._v("编辑")]),t._v(" "),a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.handleDelete(e.row.attr_template_id,e.$index)}}},[t._v("删除\n ")])]}}])})],1),t._v(" "),a("div",{staticClass:"block"},[a("el-pagination",{attrs:{"page-sizes":[20,40,60,80],"page-size":t.tableFrom.limit,"current-page":t.tableFrom.page,layout:"total, sizes, prev, pager, next, jumper",total:t.tableData.total},on:{"size-change":t.handleSizeChange,"current-change":t.pageChange}})],1)],1)],1)},i=[],l=a("c4c8"),s={name:"ProductAttr",data:function(){return{formDynamic:{template_name:"",template_value:[]},tableFrom:{page:1,limit:20},tableData:{data:[],total:0},listLoading:!0}},mounted:function(){this.getList()},methods:{add:function(){var t=this;t.formDynamic={template_name:"",template_value:[]},this.$modalAttr(Object.assign({},t.formDynamic),(function(){t.getList()}))},getList:function(){var t=this;this.listLoading=!0,Object(l["Mb"])(this.tableFrom).then((function(e){t.tableData.data=e.data.list,t.tableData.total=e.data.count,t.listLoading=!1})).catch((function(e){t.listLoading=!1,t.$message.error(e.message)}))},pageChange:function(t){this.tableFrom.page=t,this.getList()},handleSizeChange:function(t){this.tableFrom.limit=t,this.getList()},handleDelete:function(t,e){var a=this;this.$modalSure().then((function(){Object(l["k"])(t).then((function(t){var n=t.message;a.$message.success(n),a.tableData.data.splice(e,1)})).catch((function(t){var e=t.message;a.$message.error(e)}))}))},onEdit:function(t){var e=this;this.$modalAttr(JSON.parse(JSON.stringify(t)),(function(){e.getList(),this.formDynamic={template_name:"",template_value:[]}}))}}},o=s,r=a("2877"),c=Object(r["a"])(o,n,i,!1,null,null,null);e["default"]=c.exports}}]); (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0c212a"],{"496e":function(t,e,a){"use strict";a.r(e);var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"divBox"},[a("el-card",{staticClass:"box-card"},[a("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:t.add}},[t._v("添加商品规格")])],1),t._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],staticStyle:{width:"100%"},attrs:{data:t.tableData.data,size:"small","highlight-current-row":""}},[a("el-table-column",{attrs:{prop:"attr_template_id",label:"ID","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"template_name",label:"规格名称","min-width":"150"}}),t._v(" "),a("el-table-column",{attrs:{label:"商品规格","min-width":"150"},scopedSlots:t._u([{key:"default",fn:function(e){return t._l(e.row.template_value,(function(e,n){return a("span",{key:n,staticClass:"mr10",domProps:{textContent:t._s(e.value)}})}))}}])}),t._v(" "),a("el-table-column",{attrs:{label:"商品属性","min-width":"300"},scopedSlots:t._u([{key:"default",fn:function(e){return t._l(e.row.template_value,(function(e,n){return a("div",{key:n,domProps:{textContent:t._s(e.detail.join(","))}})}))}}])}),t._v(" "),a("el-table-column",{attrs:{label:"操作","min-width":"100",fixed:"right"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.onEdit(e.row)}}},[t._v("编辑")]),t._v(" "),a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.handleDelete(e.row.attr_template_id,e.$index)}}},[t._v("删除\n ")])]}}])})],1),t._v(" "),a("div",{staticClass:"block"},[a("el-pagination",{attrs:{"page-sizes":[20,40,60,80],"page-size":t.tableFrom.limit,"current-page":t.tableFrom.page,layout:"total, sizes, prev, pager, next, jumper",total:t.tableData.total},on:{"size-change":t.handleSizeChange,"current-change":t.pageChange}})],1)],1)],1)},i=[],l=a("c4c8"),s={name:"ProductAttr",data:function(){return{formDynamic:{template_name:"",template_value:[]},tableFrom:{page:1,limit:20},tableData:{data:[],total:0},listLoading:!0}},mounted:function(){this.getList()},methods:{add:function(){var t=this;t.formDynamic={template_name:"",template_value:[]},this.$modalAttr(Object.assign({},t.formDynamic),(function(){t.getList()}))},getList:function(){var t=this;this.listLoading=!0,Object(l["Ob"])(this.tableFrom).then((function(e){t.tableData.data=e.data.list,t.tableData.total=e.data.count,t.listLoading=!1})).catch((function(e){t.listLoading=!1,t.$message.error(e.message)}))},pageChange:function(t){this.tableFrom.page=t,this.getList()},handleSizeChange:function(t){this.tableFrom.limit=t,this.getList()},handleDelete:function(t,e){var a=this;this.$modalSure().then((function(){Object(l["k"])(t).then((function(t){var n=t.message;a.$message.success(n),a.tableData.data.splice(e,1)})).catch((function(t){var e=t.message;a.$message.error(e)}))}))},onEdit:function(t){var e=this;this.$modalAttr(JSON.parse(JSON.stringify(t)),(function(){e.getList(),this.formDynamic={template_name:"",template_value:[]}}))}}},o=s,r=a("2877"),c=Object(r["a"])(o,n,i,!1,null,null,null);e["default"]=c.exports}}]);

View File

@ -1 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d209391"],{a7af:function(t,e,a){"use strict";a.r(e);var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"divBox"},[a("el-card",{staticClass:"box-card"},[a("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:t.onAdd}},[t._v("添加商品标签")])],1),t._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],staticStyle:{width:"100%"},attrs:{data:t.tableData.data,size:"small"}},[a("el-table-column",{attrs:{prop:"label_name",label:"标签名称","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"info",label:"标签说明","min-width":"150"}}),t._v(" "),a("el-table-column",{attrs:{prop:"sort",label:"排序","min-width":"50"}}),t._v(" "),a("el-table-column",{attrs:{prop:"status",label:"是否显示","min-width":"100"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-switch",{attrs:{"active-value":1,"inactive-value":0,"active-text":"显示","inactive-text":"隐藏"},on:{change:function(a){return t.onchangeIsShow(e.row)}},model:{value:e.row.status,callback:function(a){t.$set(e.row,"status",a)},expression:"scope.row.status"}})]}}])}),t._v(" "),a("el-table-column",{attrs:{prop:"create_time",label:"创建时间","min-width":"150"}}),t._v(" "),a("el-table-column",{attrs:{label:"操作","min-width":"100",fixed:"right"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.onEdit(e.row.product_label_id)}}},[t._v("编辑")]),t._v(" "),a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.handleDelete(e.row.product_label_id,e.$index)}}},[t._v("删除")])]}}])})],1),t._v(" "),a("div",{staticClass:"block"},[a("el-pagination",{attrs:{"page-sizes":[20,40,60,80],"page-size":t.tableFrom.limit,"current-page":t.tableFrom.page,layout:"total, sizes, prev, pager, next, jumper",total:t.tableData.total},on:{"size-change":t.handleSizeChange,"current-change":t.pageChange}})],1)],1)],1)},i=[],s=a("c4c8"),l={name:"LabelList",data:function(){return{tableFrom:{page:1,limit:20},tableData:{data:[],total:0},listLoading:!0}},mounted:function(){this.getList("")},methods:{add:function(){},getList:function(t){var e=this;this.listLoading=!0,this.tableFrom.page=t||this.tableFrom.page,Object(s["J"])(this.tableFrom).then((function(t){e.tableData.data=t.data.list,e.tableData.total=t.data.count,e.listLoading=!1})).catch((function(t){e.listLoading=!1,e.$message.error(t.message)}))},pageChange:function(t){this.tableFrom.page=t,this.getList("")},handleSizeChange:function(t){this.tableFrom.limit=t,this.getList("")},onAdd:function(){var t=this;this.$modalForm(Object(s["H"])()).then((function(){return t.getList("")}))},onEdit:function(t){var e=this;this.$modalForm(Object(s["L"])(t)).then((function(){return e.getList("")}))},handleDelete:function(t,e){var a=this;this.$modalSure("删除该标签").then((function(){Object(s["I"])(t).then((function(t){var e=t.message;a.$message.success(e),a.getList("")})).catch((function(t){var e=t.message;a.$message.error(e)}))}))},onchangeIsShow:function(t){var e=this;Object(s["K"])(t.product_label_id,t.status).then((function(t){var a=t.message;e.$message.success(a),e.getList("")})).catch((function(t){var a=t.message;e.$message.error(a)}))}}},o=l,r=a("2877"),c=Object(r["a"])(o,n,i,!1,null,null,null);e["default"]=c.exports}}]); (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d209391"],{a7af:function(t,e,a){"use strict";a.r(e);var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"divBox"},[a("el-card",{staticClass:"box-card"},[a("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:t.onAdd}},[t._v("添加商品标签")])],1),t._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],staticStyle:{width:"100%"},attrs:{data:t.tableData.data,size:"small"}},[a("el-table-column",{attrs:{prop:"label_name",label:"标签名称","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"info",label:"标签说明","min-width":"150"}}),t._v(" "),a("el-table-column",{attrs:{prop:"sort",label:"排序","min-width":"50"}}),t._v(" "),a("el-table-column",{attrs:{prop:"status",label:"是否显示","min-width":"100"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-switch",{attrs:{"active-value":1,"inactive-value":0,"active-text":"显示","inactive-text":"隐藏"},on:{change:function(a){return t.onchangeIsShow(e.row)}},model:{value:e.row.status,callback:function(a){t.$set(e.row,"status",a)},expression:"scope.row.status"}})]}}])}),t._v(" "),a("el-table-column",{attrs:{prop:"create_time",label:"创建时间","min-width":"150"}}),t._v(" "),a("el-table-column",{attrs:{label:"操作","min-width":"100",fixed:"right"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.onEdit(e.row.product_label_id)}}},[t._v("编辑")]),t._v(" "),a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.handleDelete(e.row.product_label_id,e.$index)}}},[t._v("删除")])]}}])})],1),t._v(" "),a("div",{staticClass:"block"},[a("el-pagination",{attrs:{"page-sizes":[20,40,60,80],"page-size":t.tableFrom.limit,"current-page":t.tableFrom.page,layout:"total, sizes, prev, pager, next, jumper",total:t.tableData.total},on:{"size-change":t.handleSizeChange,"current-change":t.pageChange}})],1)],1)],1)},i=[],s=a("c4c8"),l={name:"LabelList",data:function(){return{tableFrom:{page:1,limit:20},tableData:{data:[],total:0},listLoading:!0}},mounted:function(){this.getList("")},methods:{add:function(){},getList:function(t){var e=this;this.listLoading=!0,this.tableFrom.page=t||this.tableFrom.page,Object(s["L"])(this.tableFrom).then((function(t){e.tableData.data=t.data.list,e.tableData.total=t.data.count,e.listLoading=!1})).catch((function(t){e.listLoading=!1,e.$message.error(t.message)}))},pageChange:function(t){this.tableFrom.page=t,this.getList("")},handleSizeChange:function(t){this.tableFrom.limit=t,this.getList("")},onAdd:function(){var t=this;this.$modalForm(Object(s["J"])()).then((function(){return t.getList("")}))},onEdit:function(t){var e=this;this.$modalForm(Object(s["N"])(t)).then((function(){return e.getList("")}))},handleDelete:function(t,e){var a=this;this.$modalSure("删除该标签").then((function(){Object(s["K"])(t).then((function(t){var e=t.message;a.$message.success(e),a.getList("")})).catch((function(t){var e=t.message;a.$message.error(e)}))}))},onchangeIsShow:function(t){var e=this;Object(s["M"])(t.product_label_id,t.status).then((function(t){var a=t.message;e.$message.success(a),e.getList("")})).catch((function(t){var a=t.message;e.$message.error(a)}))}}},o=l,r=a("2877"),c=Object(r["a"])(o,n,i,!1,null,null,null);e["default"]=c.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-412d33f7"],{"12e6":function(t,e,a){"use strict";a.r(e);var i=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"divBox"},[a("el-card",{staticClass:"box-card"},[a("div",{attrs:{slot:"header"},slot:"header"},[a("div",{staticClass:"container"},[a("div",{staticClass:"demo-input-suffix acea-row"},[a("el-form",{attrs:{inline:"",size:"small","label-width":"100px"}},[a("el-form-item",{attrs:{label:"搜索:"}},[a("el-input",{staticClass:"selWidth",attrs:{placeholder:"请输入参数模板名称"},nativeOn:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.getList(1)}},model:{value:t.tableFrom.template_name,callback:function(e){t.$set(t.tableFrom,"template_name",e)},expression:"tableFrom.template_name"}},[a("el-button",{staticClass:"el-button-solt",attrs:{slot:"append",icon:"el-icon-search"},on:{click:function(e){return t.getList(1)}},slot:"append"})],1)],1)],1)],1)]),t._v(" "),a("el-button",{attrs:{size:"small",type:"primary"},on:{click:t.onAdd}},[t._v("添加参数模板")])],1),t._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],staticStyle:{width:"100%"},attrs:{data:t.tableData.data,size:"small"}},[a("el-table-column",{attrs:{prop:"template_id",label:"ID","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"template_name",label:"参数模板名称","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"sort",label:"排序","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"create_time",label:"创建时间","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{label:"操作","min-width":"100",fixed:"right"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.onEdit(e.row.template_id)}}},[t._v("编辑")]),t._v(" "),a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.onDetail(e.row.template_id)}}},[t._v("查看")]),t._v(" "),a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.handleDelete(e.row.template_id,e.$index)}}},[t._v("删除")])]}}])})],1),t._v(" "),a("div",{staticClass:"block"},[a("el-pagination",{attrs:{"page-sizes":[20,40,60,80],"page-size":t.tableFrom.limit,"current-page":t.tableFrom.page,layout:"total, sizes, prev, pager, next, jumper",total:t.tableData.total},on:{"size-change":t.handleSizeChange,"current-change":t.pageChange}})],1)],1),t._v(" "),a("el-dialog",{attrs:{title:t.title,visible:t.dialogVisible,width:"400px"},on:{"update:visible":function(e){t.dialogVisible=e}}},[a("div",{staticStyle:{"min-height":"500px"}},[a("div",{staticClass:"description"},[a("div",{staticClass:"acea-row"},t._l(t.specsInfo.parameter,(function(e,i){return a("div",{key:i,staticClass:"description-term"},[a("span",{staticClass:"name"},[t._v(t._s(e.name))]),t._v(" "),a("span",{staticClass:"value"},[t._v(t._s(e.value))])])})),0)])])])],1)},n=[],s=(a("ac6a"),a("83d6")),l=a("c4c8"),o={name:"SpecsList",data:function(){return{listLoading:!0,cateList:[],tableData:{data:[],total:0},tableFrom:{page:1,limit:20},specsInfo:{},dialogVisible:!1,title:""}},mounted:function(){this.getCategorySelect(),this.getList("")},methods:{getList:function(t){var e=this;this.listLoading=!0,this.tableFrom.page=t||this.tableFrom.page,Object(l["kb"])(this.tableFrom).then((function(t){t.data.list.forEach((function(t,e){t.cate_name=[],t.cateId.forEach((function(e,a){t.cate_name.push(e.category.cate_name)}))})),e.tableData.data=t.data.list,e.tableData.total=t.data.count,e.listLoading=!1})).catch((function(t){e.listLoading=!1,e.$message.error(t.message)}))},pageChange:function(t){this.tableFrom.page=t,this.getList("")},handleSizeChange:function(t){this.tableFrom.limit=t,this.getList("")},getCategorySelect:function(){var t=this;Object(l["q"])().then((function(e){t.cateList=e.data})).catch((function(e){t.$message.error(e.message)}))},onAdd:function(){this.$router.push("".concat(s["roterPre"],"/product/specs/create"))},onEdit:function(t){this.$router.push("".concat(s["roterPre"],"/product/specs/create/").concat(t))},onDetail:function(t){var e=this;Object(l["xb"])(t).then((function(t){e.specsInfo=t.data,e.title=t.data.template_name,e.dialogVisible=!0})).catch((function(t){e.$message.error(t.message)}))},handleDelete:function(t,e){var a=this;this.$modalSure("确定删除该模板").then((function(){Object(l["yb"])(t).then((function(t){var e=t.message;a.$message.success(e),a.getList("")})).catch((function(t){var e=t.message;a.$message.error(e)}))}))}}},c=o,r=(a("b28c"),a("2877")),u=Object(r["a"])(c,i,n,!1,null,"8e659c8e",null);e["default"]=u.exports},"5ef1":function(t,e,a){},b28c:function(t,e,a){"use strict";a("5ef1")}}]); (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-412d33f7"],{"12e6":function(t,e,a){"use strict";a.r(e);var i=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"divBox"},[a("el-card",{staticClass:"box-card"},[a("div",{attrs:{slot:"header"},slot:"header"},[a("div",{staticClass:"container"},[a("div",{staticClass:"demo-input-suffix acea-row"},[a("el-form",{attrs:{inline:"",size:"small","label-width":"100px"}},[a("el-form-item",{attrs:{label:"搜索:"}},[a("el-input",{staticClass:"selWidth",attrs:{placeholder:"请输入参数模板名称"},nativeOn:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.getList(1)}},model:{value:t.tableFrom.template_name,callback:function(e){t.$set(t.tableFrom,"template_name",e)},expression:"tableFrom.template_name"}},[a("el-button",{staticClass:"el-button-solt",attrs:{slot:"append",icon:"el-icon-search"},on:{click:function(e){return t.getList(1)}},slot:"append"})],1)],1)],1)],1)]),t._v(" "),a("el-button",{attrs:{size:"small",type:"primary"},on:{click:t.onAdd}},[t._v("添加参数模板")])],1),t._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],staticStyle:{width:"100%"},attrs:{data:t.tableData.data,size:"small"}},[a("el-table-column",{attrs:{prop:"template_id",label:"ID","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"template_name",label:"参数模板名称","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"sort",label:"排序","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{prop:"create_time",label:"创建时间","min-width":"60"}}),t._v(" "),a("el-table-column",{attrs:{label:"操作","min-width":"100",fixed:"right"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.onEdit(e.row.template_id)}}},[t._v("编辑")]),t._v(" "),a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.onDetail(e.row.template_id)}}},[t._v("查看")]),t._v(" "),a("el-button",{attrs:{type:"text",size:"small"},on:{click:function(a){return t.handleDelete(e.row.template_id,e.$index)}}},[t._v("删除")])]}}])})],1),t._v(" "),a("div",{staticClass:"block"},[a("el-pagination",{attrs:{"page-sizes":[20,40,60,80],"page-size":t.tableFrom.limit,"current-page":t.tableFrom.page,layout:"total, sizes, prev, pager, next, jumper",total:t.tableData.total},on:{"size-change":t.handleSizeChange,"current-change":t.pageChange}})],1)],1),t._v(" "),a("el-dialog",{attrs:{title:t.title,visible:t.dialogVisible,width:"400px"},on:{"update:visible":function(e){t.dialogVisible=e}}},[a("div",{staticStyle:{"min-height":"500px"}},[a("div",{staticClass:"description"},[a("div",{staticClass:"acea-row"},t._l(t.specsInfo.parameter,(function(e,i){return a("div",{key:i,staticClass:"description-term"},[a("span",{staticClass:"name"},[t._v(t._s(e.name))]),t._v(" "),a("span",{staticClass:"value"},[t._v(t._s(e.value))])])})),0)])])])],1)},n=[],s=(a("ac6a"),a("83d6")),l=a("c4c8"),o={name:"SpecsList",data:function(){return{listLoading:!0,cateList:[],tableData:{data:[],total:0},tableFrom:{page:1,limit:20},specsInfo:{},dialogVisible:!1,title:""}},mounted:function(){this.getCategorySelect(),this.getList("")},methods:{getList:function(t){var e=this;this.listLoading=!0,this.tableFrom.page=t||this.tableFrom.page,Object(l["mb"])(this.tableFrom).then((function(t){t.data.list.forEach((function(t,e){t.cate_name=[],t.cateId.forEach((function(e,a){t.cate_name.push(e.category.cate_name)}))})),e.tableData.data=t.data.list,e.tableData.total=t.data.count,e.listLoading=!1})).catch((function(t){e.listLoading=!1,e.$message.error(t.message)}))},pageChange:function(t){this.tableFrom.page=t,this.getList("")},handleSizeChange:function(t){this.tableFrom.limit=t,this.getList("")},getCategorySelect:function(){var t=this;Object(l["q"])().then((function(e){t.cateList=e.data})).catch((function(e){t.$message.error(e.message)}))},onAdd:function(){this.$router.push("".concat(s["roterPre"],"/product/specs/create"))},onEdit:function(t){this.$router.push("".concat(s["roterPre"],"/product/specs/create/").concat(t))},onDetail:function(t){var e=this;Object(l["zb"])(t).then((function(t){e.specsInfo=t.data,e.title=t.data.template_name,e.dialogVisible=!0})).catch((function(t){e.$message.error(t.message)}))},handleDelete:function(t,e){var a=this;this.$modalSure("确定删除该模板").then((function(){Object(l["Ab"])(t).then((function(t){var e=t.message;a.$message.success(e),a.getList("")})).catch((function(t){var e=t.message;a.$message.error(e)}))}))}}},c=o,r=(a("b28c"),a("2877")),u=Object(r["a"])(c,i,n,!1,null,"8e659c8e",null);e["default"]=u.exports},"5ef1":function(t,e,a){},b28c:function(t,e,a){"use strict";a("5ef1")}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-a0fbc2e4"],{3480:function(e,t,a){"use strict";a("f095")},9809:function(e,t,a){"use strict";a.r(t);var r=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"divBox"},[a("el-card",{staticClass:"box-card"},[a("div",{attrs:{slot:"header"},slot:"header"},[a("div",{staticClass:"container"},[a("div",{staticClass:"demo-input-suffix acea-row"},[a("el-form",{ref:"formValidate",attrs:{"label-width":"120px",rules:e.ruleValidate,model:e.formValidate}},[a("el-form-item",{attrs:{label:"参数模板名称:",prop:"template_name"}},[a("el-input",{staticClass:"selWidth",attrs:{placeholder:"请输入参数模板名称"},model:{value:e.formValidate.template_name,callback:function(t){e.$set(e.formValidate,"template_name",t)},expression:"formValidate.template_name"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"排序:"}},[a("el-input-number",{attrs:{label:"排序"},model:{value:e.formValidate.sort,callback:function(t){e.$set(e.formValidate,"sort",t)},expression:"formValidate.sort"}})],1),e._v(" "),a("el-form-item",{attrs:{label:""}},[a("el-table",{staticStyle:{width:"100%"},attrs:{data:e.data,border:"",size:"small"}},[a("el-table-column",{attrs:{align:"center",prop:"name",label:"参数名称","min-width":"200"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-input",{staticClass:"priceBox",attrs:{placeholder:"请输入参数名称"},model:{value:t.row.name,callback:function(a){e.$set(t.row,"name",a)},expression:"scope.row.name"}})]}}])}),e._v(" "),a("el-table-column",{attrs:{align:"center",label:"参数值","min-width":"200"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-input",{staticClass:"priceBox",attrs:{placeholder:"请输入参数值"},model:{value:t.row.value,callback:function(a){e.$set(t.row,"value",a)},expression:"scope.row.value"}})]}}])}),e._v(" "),a("el-table-column",{attrs:{align:"center",label:"排序","min-width":"300"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-input-number",{staticClass:"priceBox",attrs:{min:0,"controls-position":"right"},model:{value:t.row.sort,callback:function(a){e.$set(t.row,"sort",a)},expression:"scope.row.sort"}})]}}])}),e._v(" "),a("el-table-column",{attrs:{align:"center",label:"操作","min-width":"120"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-button",{staticClass:"submission",attrs:{type:"text"},on:{click:function(a){return e.delSpecs(t.$index)}}},[e._v("删除")])]}}])})],1)],1),e._v(" "),a("el-form-item",[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:e.onAdd}},[e._v("添加参数")])],1)],1)],1)])])]),e._v(" "),a("el-card",[a("el-form",[a("el-form-item",[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:function(t){return e.handleSubmit("formValidate")}}},[e._v("保存")])],1)],1)],1)],1)},s=[],l=(a("7f7f"),a("c4c8")),o=a("83d6"),n={name:"specsCreate",data:function(){return{listLoading:!0,ruleValidate:{template_name:[{required:!0,message:"请输入参数模板名称",trigger:"blur"}]},data:[],cateList:[],formValidate:{sort:0}}},created:function(){this.onAdd(),this.$route.params.id&&this.getInfo()},mounted:function(){},methods:{onAdd:function(){var e={name:"",value:"",sort:0,parameter_id:0};this.data.push(e)},onEdit:function(e){var t=this;this.$modalForm(levelUpdateApi(e)).then((function(){return t.getList("")}))},getInfo:function(){var e=this;Object(l["jb"])(this.$route.params.id).then((function(t){e.formValidate=t.data,e.data=t.data.parameter}))},delSpecs:function(e){this.data.splice(e,1)},handleSubmit:function(e){var t=this;this.$refs[e].validate((function(e){if(e){t.formValidate.params=t.data;for(var a=0;a<t.formValidate.params.length;a++){var r=t.formValidate.params[a];if(!r.name.trim())return t.$message.error("请输入参数名称");if(!r.value.trim())return t.$message.error("请输入参数值")}t.$route.params.id?Object(l["Ab"])(t.$route.params.id,t.formValidate).then((function(e){t.$message.success(e.message),t.$router.push({path:"".concat(o["roterPre"],"/product/specs")})})).catch((function(e){t.$message.error(e.message)})):Object(l["hb"])(t.formValidate).then((function(e){t.$message.success(e.message),t.$router.push({path:"".concat(o["roterPre"],"/product/specs")})})).catch((function(e){t.$message.error(e.message)}))}else t.$message.error("请输入参数模板名称")}))}}},i=n,c=(a("3480"),a("2877")),u=Object(c["a"])(i,r,s,!1,null,"2fe27228",null);t["default"]=u.exports},f095:function(e,t,a){}}]); (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-a0fbc2e4"],{3480:function(e,t,a){"use strict";a("f095")},9809:function(e,t,a){"use strict";a.r(t);var r=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"divBox"},[a("el-card",{staticClass:"box-card"},[a("div",{attrs:{slot:"header"},slot:"header"},[a("div",{staticClass:"container"},[a("div",{staticClass:"demo-input-suffix acea-row"},[a("el-form",{ref:"formValidate",attrs:{"label-width":"120px",rules:e.ruleValidate,model:e.formValidate}},[a("el-form-item",{attrs:{label:"参数模板名称:",prop:"template_name"}},[a("el-input",{staticClass:"selWidth",attrs:{placeholder:"请输入参数模板名称"},model:{value:e.formValidate.template_name,callback:function(t){e.$set(e.formValidate,"template_name",t)},expression:"formValidate.template_name"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"排序:"}},[a("el-input-number",{attrs:{label:"排序"},model:{value:e.formValidate.sort,callback:function(t){e.$set(e.formValidate,"sort",t)},expression:"formValidate.sort"}})],1),e._v(" "),a("el-form-item",{attrs:{label:""}},[a("el-table",{staticStyle:{width:"100%"},attrs:{data:e.data,border:"",size:"small"}},[a("el-table-column",{attrs:{align:"center",prop:"name",label:"参数名称","min-width":"200"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-input",{staticClass:"priceBox",attrs:{placeholder:"请输入参数名称"},model:{value:t.row.name,callback:function(a){e.$set(t.row,"name",a)},expression:"scope.row.name"}})]}}])}),e._v(" "),a("el-table-column",{attrs:{align:"center",label:"参数值","min-width":"200"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-input",{staticClass:"priceBox",attrs:{placeholder:"请输入参数值"},model:{value:t.row.value,callback:function(a){e.$set(t.row,"value",a)},expression:"scope.row.value"}})]}}])}),e._v(" "),a("el-table-column",{attrs:{align:"center",label:"排序","min-width":"300"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-input-number",{staticClass:"priceBox",attrs:{min:0,"controls-position":"right"},model:{value:t.row.sort,callback:function(a){e.$set(t.row,"sort",a)},expression:"scope.row.sort"}})]}}])}),e._v(" "),a("el-table-column",{attrs:{align:"center",label:"操作","min-width":"120"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-button",{staticClass:"submission",attrs:{type:"text"},on:{click:function(a){return e.delSpecs(t.$index)}}},[e._v("删除")])]}}])})],1)],1),e._v(" "),a("el-form-item",[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:e.onAdd}},[e._v("添加参数")])],1)],1)],1)])])]),e._v(" "),a("el-card",[a("el-form",[a("el-form-item",[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:function(t){return e.handleSubmit("formValidate")}}},[e._v("保存")])],1)],1)],1)],1)},s=[],l=(a("7f7f"),a("c4c8")),o=a("83d6"),n={name:"specsCreate",data:function(){return{listLoading:!0,ruleValidate:{template_name:[{required:!0,message:"请输入参数模板名称",trigger:"blur"}]},data:[],cateList:[],formValidate:{sort:0}}},created:function(){this.onAdd(),this.$route.params.id&&this.getInfo()},mounted:function(){},methods:{onAdd:function(){var e={name:"",value:"",sort:0,parameter_id:0};this.data.push(e)},onEdit:function(e){var t=this;this.$modalForm(levelUpdateApi(e)).then((function(){return t.getList("")}))},getInfo:function(){var e=this;Object(l["lb"])(this.$route.params.id).then((function(t){e.formValidate=t.data,e.data=t.data.parameter}))},delSpecs:function(e){this.data.splice(e,1)},handleSubmit:function(e){var t=this;this.$refs[e].validate((function(e){if(e){t.formValidate.params=t.data;for(var a=0;a<t.formValidate.params.length;a++){var r=t.formValidate.params[a];if(!r.name.trim())return t.$message.error("请输入参数名称");if(!r.value.trim())return t.$message.error("请输入参数值")}t.$route.params.id?Object(l["Cb"])(t.$route.params.id,t.formValidate).then((function(e){t.$message.success(e.message),t.$router.push({path:"".concat(o["roterPre"],"/product/specs")})})).catch((function(e){t.$message.error(e.message)})):Object(l["jb"])(t.formValidate).then((function(e){t.$message.success(e.message),t.$router.push({path:"".concat(o["roterPre"],"/product/specs")})})).catch((function(e){t.$message.error(e.message)}))}else t.$message.error("请输入参数模板名称")}))}}},i=n,c=(a("3480"),a("2877")),u=Object(c["a"])(i,r,s,!1,null,"2fe27228",null);t["default"]=u.exports},f095:function(e,t,a){}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -21,8 +21,10 @@ use think\facade\Route;
Route::group('api/', function () { Route::group('api/', function () {
Route::any('test', 'api.Auth/test'); Route::any('test', 'api.Auth/test');
Route::any('demo_ceshi', 'api.Demo/index');
Route::any('dotest', 'api.Auth/dotest'); Route::any('dotest', 'api.Auth/dotest');
Route::any('caiji', 'api.Auth/caiji'); Route::any('caiji', 'api.Auth/caiji');
Route::any('parse/token', 'api.Auth/parseToken');
Route::any('app/version', 'api.Auth/appVersion'); Route::any('app/version', 'api.Auth/appVersion');
Route::post('merchant/syncStatus/:id', 'api.Auth/merchantStatus'); Route::post('merchant/syncStatus/:id', 'api.Auth/merchantStatus');
Route::get('business/agree', 'api.Auth/businessAgree'); Route::get('business/agree', 'api.Auth/businessAgree');
@ -704,6 +706,7 @@ Route::group('api/', function () {
Route::get('supply_chain_product_price_count', '/SupplyChainProductPriceCount'); Route::get('supply_chain_product_price_count', '/SupplyChainProductPriceCount');
Route::get('supply_chain_street_product_price_count', '/SupplyChainStreetProductPriceCount'); Route::get('supply_chain_street_product_price_count', '/SupplyChainStreetProductPriceCount');
Route::get('supply_chain_breeding_street_product_count', '/SupplyChainBreedingStreetProductCount'); Route::get('supply_chain_breeding_street_product_count', '/SupplyChainBreedingStreetProductCount');
Route::get('supply_chain_village_breeding_price_count', '/SupplyChainVillageBreedingPriceCount');
Route::get('store_order_user_trade_amount', '/StoreOrderUserTradeAmount'); Route::get('store_order_user_trade_amount', '/StoreOrderUserTradeAmount');
})->prefix('api.Statistics'); })->prefix('api.Statistics');

View File

@ -109,6 +109,9 @@ Route::group(function () {
Route::get('children/:id', 'Order/childrenList')->name('merchantStoreOrderChildrenList')->option([ Route::get('children/:id', 'Order/childrenList')->name('merchantStoreOrderChildrenList')->option([
'_alias' => '关联订单', '_alias' => '关联订单',
]); ]);
Route::get('logistics_code/:id', 'Order/logisticsCode')->name('merchantStoreOrderLogisticsCode')->option([
'_alias' => '生成取货码',
]);
})->prefix('merchant.store.order.')->option([ })->prefix('merchant.store.order.')->option([
'_path' => '/order/list', '_path' => '/order/list',
'_auth' => true, '_auth' => true,

View File

@ -45,6 +45,7 @@ return array(
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
'Psr\\Clock\\' => array($vendorDir . '/psr/clock/src'), 'Psr\\Clock\\' => array($vendorDir . '/psr/clock/src'),
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
'PhpZip\\' => array($vendorDir . '/nelexa/zip/src'),
'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'), 'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'),
'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'), 'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'),
'Payment\\' => array($vendorDir . '/riverslei/payment/src'), 'Payment\\' => array($vendorDir . '/riverslei/payment/src'),

View File

@ -101,6 +101,7 @@ class ComposerStaticInitb1229d2685c190533aa1234015613f09
'Psr\\Container\\' => 14, 'Psr\\Container\\' => 14,
'Psr\\Clock\\' => 10, 'Psr\\Clock\\' => 10,
'Psr\\Cache\\' => 10, 'Psr\\Cache\\' => 10,
'PhpZip\\' => 7,
'PhpOption\\' => 10, 'PhpOption\\' => 10,
'PhpOffice\\PhpSpreadsheet\\' => 25, 'PhpOffice\\PhpSpreadsheet\\' => 25,
'Payment\\' => 8, 'Payment\\' => 8,
@ -347,6 +348,10 @@ class ComposerStaticInitb1229d2685c190533aa1234015613f09
array ( array (
0 => __DIR__ . '/..' . '/psr/cache/src', 0 => __DIR__ . '/..' . '/psr/cache/src',
), ),
'PhpZip\\' =>
array (
0 => __DIR__ . '/..' . '/nelexa/zip/src',
),
'PhpOption\\' => 'PhpOption\\' =>
array ( array (
0 => __DIR__ . '/..' . '/phpoption/phpoption/src/PhpOption', 0 => __DIR__ . '/..' . '/phpoption/phpoption/src/PhpOption',

View File

@ -2141,6 +2141,72 @@
], ],
"install-path": "../myclabs/php-enum" "install-path": "../myclabs/php-enum"
}, },
{
"name": "nelexa/zip",
"version": "4.0.2",
"version_normalized": "4.0.2.0",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/nelexa/zip/4.0.2/nelexa-zip-4.0.2.zip",
"reference": "88a1b6549be813278ff2dd3b6b2ac188827634a7",
"shasum": ""
},
"require": {
"ext-zlib": "*",
"php": "^7.4 || ^8.0",
"psr/http-message": "*",
"symfony/finder": "*"
},
"require-dev": {
"ext-bz2": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-iconv": "*",
"ext-openssl": "*",
"ext-xml": "*",
"friendsofphp/php-cs-fixer": "^3.4.0",
"guzzlehttp/psr7": "^1.6",
"phpunit/phpunit": "^9",
"symfony/http-foundation": "*",
"symfony/var-dumper": "*",
"vimeo/psalm": "^4.6"
},
"suggest": {
"ext-bz2": "Needed to support BZIP2 compression",
"ext-fileinfo": "Needed to get mime-type file",
"ext-iconv": "Needed to support convert zip entry name to requested character encoding",
"ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt"
},
"time": "2022-06-17T11:17:46+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"PhpZip\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Ne-Lexa",
"email": "alexey@nelexa.ru",
"role": "Developer"
}
],
"description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.",
"homepage": "https://github.com/Ne-Lexa/php-zip",
"keywords": [
"archive",
"extract",
"unzip",
"winzip",
"zip",
"ziparchive"
],
"install-path": "../nelexa/zip"
},
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",
"version": "2.71.0", "version": "2.71.0",

View File

@ -3,7 +3,7 @@
'name' => 'topthink/think', 'name' => 'topthink/think',
'pretty_version' => 'dev-master', 'pretty_version' => 'dev-master',
'version' => 'dev-master', 'version' => 'dev-master',
'reference' => '86f2a7dbf8d77a9e0bb9de64b2446c573cdc6788', 'reference' => '0224f6113a669845fb3455cadb381a6931e9c508',
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@ -511,6 +511,15 @@
'aliases' => array(), 'aliases' => array(),
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'nelexa/zip' => array(
'pretty_version' => '4.0.2',
'version' => '4.0.2.0',
'reference' => '88a1b6549be813278ff2dd3b6b2ac188827634a7',
'type' => 'library',
'install_path' => __DIR__ . '/../nelexa/zip',
'aliases' => array(),
'dev_requirement' => false,
),
'nesbot/carbon' => array( 'nesbot/carbon' => array(
'pretty_version' => '2.71.0', 'pretty_version' => '2.71.0',
'version' => '2.71.0.0', 'version' => '2.71.0.0',
@ -970,7 +979,7 @@
'topthink/think' => array( 'topthink/think' => array(
'pretty_version' => 'dev-master', 'pretty_version' => 'dev-master',
'version' => 'dev-master', 'version' => 'dev-master',
'reference' => '86f2a7dbf8d77a9e0bb9de64b2446c573cdc6788', 'reference' => '0224f6113a669845fb3455cadb381a6931e9c508',
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),

View File

@ -138,6 +138,7 @@ class JWT
// Check the nbf if it is defined. This is the time that the // Check the nbf if it is defined. This is the time that the
// token can actually be used. If it's not yet that time, abort. // token can actually be used. If it's not yet that time, abort.
// 取消时间验证
if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) { if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
throw new BeforeValidException( throw new BeforeValidException(
'Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->nbf) 'Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->nbf)

1766
vendor/nelexa/zip/.php-cs-fixer.php vendored Normal file

File diff suppressed because it is too large Load Diff

21
vendor/nelexa/zip/LICENSE vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016-2020 Ne-Lexa
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

884
vendor/nelexa/zip/README.RU.md vendored Normal file
View File

@ -0,0 +1,884 @@
<h1 align="center"><img src="logo.svg" alt="PhpZip" width="250" height="51"></h1>
`PhpZip` - php библиотека для продвинутой работы с ZIP-архивами.
[![Packagist Version](https://img.shields.io/packagist/v/nelexa/zip.svg)](https://packagist.org/packages/nelexa/zip)
[![Packagist Downloads](https://img.shields.io/packagist/dt/nelexa/zip.svg?color=%23ff007f)](https://packagist.org/packages/nelexa/zip)
[![Code Coverage](https://scrutinizer-ci.com/g/Ne-Lexa/php-zip/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Ne-Lexa/php-zip/?branch=master)
[![Build Status](https://github.com/Ne-Lexa/php-zip/workflows/build/badge.svg)](https://github.com/Ne-Lexa/php-zip/actions)
[![License](https://img.shields.io/packagist/l/nelexa/zip.svg)](https://github.com/Ne-Lexa/php-zip/blob/master/LICENSE)
[English Documentation](README.md)
Содержание
----------
- [Функционал](#функционал)
- [Требования](#требования)
- [Установка](#установка)
- [Примеры](#примеры)
- [Глоссарий](#глоссарий)
- [Документация](#документация)
+ [Обзор методов класса `\PhpZip\ZipFile`](#обзор-методов-класса-phpzipzipfile)
+ [Создание/Открытие ZIP-архива](#созданиеоткрытие-zip-архива)
+ [Чтение записей из архива](#чтение-записей-из-архива)
+ [Перебор записей/Итератор](#перебор-записейитератор)
+ [Получение информации о записях](#получение-информации-о-записях)
+ [Добавление записей в архив](#добавление-записей-в-архив)
+ [Удаление записей из архива](#удаление-записей-из-архива)
+ [Работа с записями и с архивом](#работа-с-записями-и-с-архивом)
+ [Работа с паролями](#работа-с-паролями)
+ [Отмена изменений](#отмена-изменений)
+ [Сохранение файла или вывод в браузер](#сохранение-файла-или-вывод-в-браузер)
+ [Закрытие архива](#закрытие-архива)
- [Запуск тестов](#запуск-тестов)
- [История изменений](#история-изменений)
- [Обновление версий](#обновление-версий)
+ [Обновление с версии 3 до версии 4](#обновление-с-версии-3-до-версии-4)
+ [Обновление с версии 2 до версии 3](#обновление-с-версии-2-до-версии-3)
### Функционал
- Открытие и разархивирование ZIP-архивов.
- Создание ZIP-архивов.
- Модификация ZIP-архивов.
- Чистый php (не требуется расширение `php-zip` и класс `\ZipArchive`).
- Поддерживается сохранение архива в файл, вывод архива в браузер или вывод в виде строки, без сохранения в файл.
- Поддерживаются комментарии архива и комментарии отдельных записей.
- Получение подробной информации о каждой записи в архиве.
- Поддерживаются только следующие методы сжатия:
+ Без сжатия (Stored).
+ Deflate сжатие.
+ BZIP2 сжатие при наличии расширения `php-bz2`.
- Поддержка `ZIP64` (размер файла более 4 GB или количество записей в архиве более 65535).
- Работа с паролями
> **Внимание!**
>
> Для 32-bit систем, в данный момент не поддерживается метод шифрование `Traditional PKWARE Encryption (ZipCrypto)`.
> Используйте метод шифрования `WinZIP AES Encryption`, когда это возможно.
+ Установка пароля для чтения архива глобально или для некоторых записей.
+ Изменение пароля архива, в том числе и для отдельных записей.
+ Удаление пароля архива глобально или для отдельных записей.
+ Установка пароля и/или метода шифрования, как для всех, так и для отдельных записей в архиве.
+ Установка разных паролей и методов шифрования для разных записей.
+ Удаление пароля для всех или для некоторых записей.
+ Поддержка методов шифрования `Traditional PKWARE Encryption (ZipCrypto)` и `WinZIP AES Encryption (128, 192 или 256 bit)`.
+ Установка метода шифрования для всех или для отдельных записей в архиве.
### Требования
- `PHP` 7.4 или ^8.0 (предпочтительно 64-bit).
- Опционально php-расширение `bzip2` для поддержки BZIP2 компрессии.
- Опционально php-расширение `openssl` для `WinZip Aes Encryption` шифрования.
### Установка
`composer require nelexa/zip`
Последняя стабильная версия: [![Latest Stable Version](https://poser.pugx.org/nelexa/zip/v/stable)](https://packagist.org/packages/nelexa/zip)
### Примеры
```php
// создание нового архива
$zipFile = new \PhpZip\ZipFile();
try{
$zipFile
->addFromString('zip/entry/filename', "Is file content") // добавить запись из строки
->addFile('/path/to/file', 'data/tofile') // добавить запись из файла
->addDir(__DIR__, 'to/path/') // добавить файлы из директории
->saveAsFile($outputFilename) // сохранить архив в файл
->close(); // закрыть архив
// открытие архива, извлечение файлов, удаление файлов, добавление файлов, установка пароля и вывод архива в браузер.
$zipFile
->openFile($outputFilename) // открыть архив из файла
->extractTo($outputDirExtract) // извлечь файлы в заданную директорию
->deleteFromRegex('~^\.~') // удалить все скрытые (Unix) файлы
->addFromString('dir/file.txt', 'Test file') // добавить новую запись из строки
->setPassword('password') // установить пароль на все записи
->outputAsAttachment('library.jar'); // вывести в браузер без сохранения в файл
}
catch(\PhpZip\Exception\ZipException $e){
// обработка исключения
}
finally{
$zipFile->close();
}
```
Другие примеры можно посмотреть в папке `tests/`.
### Глоссарий
**Запись в ZIP-архиве (Zip Entry)** - файл или папка в ZIP-архиве. У каждой записи в архиве есть определённые свойства, например: имя файла, метод сжатия, метод шифрования, размер файла до сжатия, размер файла после сжатия, CRC32 и другие.
### Документация
#### Обзор методов класса `\PhpZip\ZipFile`
- [ZipFile::__construct](#zipfile__construct) - инициализирует ZIP-архив.
- [ZipFile::addAll](#zipfileaddall) - добавляет все записи из массива.
- [ZipFile::addDir](#zipfileadddir) - добавляет файлы из директории по указанному пути без вложенных директорий.
- [ZipFile::addDirRecursive](#zipfileadddirrecursive) - добавляет файлы из директории по указанному пути с вложенными директориями.
- [ZipFile::addEmptyDir](#zipfileaddemptydir) - добавляет в ZIP-архив новую директорию.
- [ZipFile::addFile](#zipfileaddfile) - добавляет в ZIP-архив файл по указанному пути.
- [ZipFile::addSplFile](#zipfileaddsplfile) - добавляет объект `\SplFileInfo` в zip-архив.
- [ZipFile::addFromFinder](#zipfileaddfromfinder) - добавляет файлы из `Symfony\Component\Finder\Finder` в zip архив.
- [ZipFile::addFilesFromIterator](#zipfileaddfilesfromiterator) - добавляет файлы из итератора директорий.
- [ZipFile::addFilesFromGlob](#zipfileaddfilesfromglob) - добавляет файлы из директории в соответствии с glob шаблоном без вложенных директорий.
- [ZipFile::addFilesFromGlobRecursive](#zipfileaddfilesfromglobrecursive) - добавляет файлы из директории в соответствии с glob шаблоном c вложенными директориями.
- [ZipFile::addFilesFromRegex](#zipfileaddfilesfromregex) - добавляет файлы из директории в соответствии с регулярным выражением без вложенных директорий.
- [ZipFile::addFilesFromRegexRecursive](#zipfileaddfilesfromregexrecursive) - добавляет файлы из директории в соответствии с регулярным выражением с вложенными директориями.
- [ZipFile::addFromStream](#zipfileaddfromstream) - добавляет в ZIP-архив запись из потока.
- [ZipFile::addFromString](#zipfileaddfromstring) - добавляет файл в ZIP-архив, используя его содержимое в виде строки.
- [ZipFile::close](#zipfileclose) - закрывает ZIP-архив.
- [ZipFile::count](#zipfilecount) - возвращает количество записей в архиве.
- [ZipFile::deleteFromName](#zipfiledeletefromname) - удаляет запись по имени.
- [ZipFile::deleteFromGlob](#zipfiledeletefromglob) - удаляет записи в соответствии с glob шаблоном.
- [ZipFile::deleteFromRegex](#zipfiledeletefromregex) - удаляет записи в соответствии с регулярным выражением.
- [ZipFile::deleteAll](#zipfiledeleteall) - удаляет все записи в ZIP-архиве.
- [ZipFile::disableEncryption](#zipfiledisableencryption) - отключает шифрования всех записей, находящихся в архиве.
- [ZipFile::disableEncryptionEntry](#zipfiledisableencryptionentry) - отключает шифрование записи по её имени.
- [ZipFile::extractTo](#zipfileextractto) - извлекает содержимое архива в заданную директорию.
- [ZipFile::getArchiveComment](#zipfilegetarchivecomment) - возвращает комментарий ZIP-архива.
- [ZipFile::getEntryComment](#zipfilegetentrycomment) - возвращает комментарий к записи, используя её имя.
- [ZipFile::getEntryContent](#zipfilegetentrycontent) - возвращает содержимое записи.
- [ZipFile::getListFiles](#zipfilegetlistfiles) - возвращает список файлов архива.
- [ZipFile::hasEntry](#zipfilehasentry) - проверяет, присутствует ли запись в архиве.
- [ZipFile::isDirectory](#zipfileisdirectory) - проверяет, является ли запись в архиве директорией.
- [ZipFile::matcher](#zipfilematcher) - выборка записей в архиве для проведения операций над выбранными записями.
- [ZipFile::openFile](#zipfileopenfile) - открывает ZIP-архив из файла.
- [ZipFile::openFromString](#zipfileopenfromstring) - открывает ZIP-архив из строки.
- [ZipFile::openFromStream](#zipfileopenfromstream) - открывает ZIP-архив из потока.
- [ZipFile::outputAsAttachment](#zipfileoutputasattachment) - выводит ZIP-архив в браузер.
- [ZipFile::outputAsPsr7Response](#zipfileoutputaspsr7response) - выводит ZIP-архив, как PSR-7 Response.
- [ZipFile::outputAsSymfonyResponse](#zipfileoutputassymfonyresponse) - выводит ZIP-архив, как Symfony Response.
- [ZipFile::outputAsString](#zipfileoutputasstring) - выводит ZIP-архив в виде строки.
- [ZipFile::rename](#zipfilerename) - переименовывает запись по имени.
- [ZipFile::rewrite](#zipfilerewrite) - сохраняет изменения и заново открывает изменившийся архив.
- [ZipFile::saveAsFile](#zipfilesaveasfile) - сохраняет архив в файл.
- [ZipFile::saveAsStream](#zipfilesaveasstream) - записывает архив в поток.
- [ZipFile::setArchiveComment](#zipfilesetarchivecomment) - устанавливает комментарий к ZIP-архиву.
- [ZipFile::setCompressionLevel](#zipfilesetcompressionlevel) - устанавливает уровень сжатия для всех файлов, находящихся в архиве.
- [ZipFile::setCompressionLevelEntry](#zipfilesetcompressionlevelentry) - устанавливает уровень сжатия для определённой записи в архиве.
- [ZipFile::setCompressionMethodEntry](#zipfilesetcompressionmethodentry) - устанавливает метод сжатия для определённой записи в архиве.
- [ZipFile::setEntryComment](#zipfilesetentrycomment) - устанавливает комментарий к записи, используя её имя.
- [ZipFile::setReadPassword](#zipfilesetreadpassword) - устанавливает пароль на чтение открытого запароленного архива для всех зашифрованных записей.
- [ZipFile::setReadPasswordEntry](#zipfilesetreadpasswordentry) - устанавливает пароль на чтение конкретной зашифрованной записи открытого запароленного архива.
- [ZipFile::setPassword](#zipfilesetpassword) - устанавливает новый пароль для всех файлов, находящихся в архиве.
- [ZipFile::setPasswordEntry](#zipfilesetpasswordentry) - устанавливает новый пароль для конкретного файла.
- [ZipFile::unchangeAll](#zipfileunchangeall) - отменяет все изменения, сделанные в архиве.
- [ZipFile::unchangeArchiveComment](#zipfileunchangearchivecomment) - отменяет изменения в комментарии к архиву.
- [ZipFile::unchangeEntry](#zipfileunchangeentry) - отменяет изменения для конкретной записи архива.
#### Создание/Открытие ZIP-архива
##### ZipFile::__construct
Инициализирует ZIP-архив.
```php
$zipFile = new \PhpZip\ZipFile();
```
##### ZipFile::openFile
Открывает ZIP-архив из файла.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->openFile('file.zip');
```
##### ZipFile::openFromString
Открывает ZIP-архив из строки.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->openFromString($stringContents);
```
##### ZipFile::openFromStream
Открывает ZIP-архив из потока.
```php
$stream = fopen('file.zip', 'rb');
$zipFile = new \PhpZip\ZipFile();
$zipFile->openFromStream($stream);
```
#### Чтение записей из архива
##### ZipFile::count
Возвращает количество записей в архиве.
```php
$zipFile = new \PhpZip\ZipFile();
$count = count($zipFile);
// или
$count = $zipFile->count();
```
##### ZipFile::getListFiles
Возвращает список файлов архива.
```php
$zipFile = new \PhpZip\ZipFile();
$listFiles = $zipFile->getListFiles();
// Пример содержимого массива:
// array (
// 0 => 'info.txt',
// 1 => 'path/to/file.jpg',
// 2 => 'another path/',
// )
```
##### ZipFile::getEntryContent
Возвращает содержимое записи.
```php
// $entryName = 'path/to/example-entry-name.txt';
$zipFile = new \PhpZip\ZipFile();
$contents = $zipFile[$entryName];
// или
$contents = $zipFile->getEntryContents($entryName);
```
##### ZipFile::hasEntry
Проверяет, присутствует ли запись в архиве.
```php
// $entryName = 'path/to/example-entry-name.txt';
$zipFile = new \PhpZip\ZipFile();
$hasEntry = isset($zipFile[$entryName]);
// или
$hasEntry = $zipFile->hasEntry($entryName);
```
##### ZipFile::isDirectory
Проверяет, является ли запись в архиве директорией.
```php
// $entryName = 'path/to/';
$zipFile = new \PhpZip\ZipFile();
$isDirectory = $zipFile->isDirectory($entryName);
```
##### ZipFile::extractTo
Извлекает содержимое архива в заданную директорию.
Директория должна существовать.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->extractTo($directory);
```
Можно извлечь только некоторые записи в заданную директорию.
Директория должна существовать.
```php
$extractOnlyFiles = [
'filename1',
'filename2',
'dir/dir/dir/'
];
$zipFile = new \PhpZip\ZipFile();
$zipFile->extractTo($toDirectory, $extractOnlyFiles);
```
#### Перебор записей/Итератор
`ZipFile` является итератором.
Можно перебрать все записи, через цикл `foreach`.
```php
foreach($zipFile as $entryName => $contents){
echo "Файл: $entryName" . PHP_EOL;
echo "Содержимое: $contents" . PHP_EOL;
echo '-----------------------------' . PHP_EOL;
}
```
Можно использовать паттерн `Iterator`.
```php
$iterator = new \ArrayIterator($zipFile);
while ($iterator->valid())
{
$entryName = $iterator->key();
$contents = $iterator->current();
echo "Файл: $entryName" . PHP_EOL;
echo "Содержимое: $contents" . PHP_EOL;
echo '-----------------------------' . PHP_EOL;
$iterator->next();
}
```
#### Получение информации о записях
##### ZipFile::getArchiveComment
Возвращает комментарий ZIP-архива.
```php
$commentArchive = $zipFile->getArchiveComment();
```
##### ZipFile::getEntryComment
Возвращает комментарий к записи, используя её имя.
```php
$commentEntry = $zipFile->getEntryComment($entryName);
```
#### Добавление записей в архив
Все методы добавления записей в ZIP-архив позволяют указать метод сжатия содержимого.
Доступны следующие методы сжатия:
- `\PhpZip\Constants\ZipCompressionMethod::STORED` - без сжатия
- `\PhpZip\Constants\ZipCompressionMethod::DEFLATED` - Deflate сжатие
- `\PhpZip\Constants\ZipCompressionMethod::BZIP2` - Bzip2 сжатие при наличии расширения `ext-bz2`
##### ZipFile::addFile
Добавляет в ZIP-архив файл по указанному пути из файловой системы.
```php
$zipFile = new \PhpZip\ZipFile();
// $file = '...../file.ext';
$zipFile->addFile($file);
// можно указать имя записи в архиве (если null, то используется последний компонент из имени файла)
$zipFile->addFile($file, $entryName);
// можно указать метод сжатия
$zipFile->addFile($file, $entryName, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addFile($file, $entryName, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addFile($file, $entryName, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
##### ZipFile::addSplFile"
Добавляет объект `\SplFileInfo` в zip-архив.
```php
// $file = '...../file.ext';
// $entryName = 'file2.ext'
$zipFile = new \PhpZip\ZipFile();
$splFile = new \SplFileInfo('README.md');
$zipFile->addSplFile($splFile);
$zipFile->addSplFile($splFile, $entryName);
// or
$zipFile[$entryName] = new \SplFileInfo($file);
// установить метод сжатия
$zipFile->addSplFile($splFile, $entryName, $options = [
\PhpZip\Constants\ZipOptions::COMPRESSION_METHOD => \PhpZip\Constants\ZipCompressionMethod::DEFLATED,
]);
```
##### ZipFile::addFromFinder"
Добавляет файлы из [`Symfony\Component\Finder\Finder`](https://symfony.com/doc/current/components/finder.html) в zip архив.
```php
$finder = new \Symfony\Component\Finder\Finder();
$finder
->files()
->name('*.{jpg,jpeg,gif,png}')
->name('/^[0-9a-f]\./')
->contains('/lorem\s+ipsum$/i')
->in('path');
$zipFile = new \PhpZip\ZipFile();
$zipFile->addFromFinder($finder, $options = [
\PhpZip\Constants\ZipOptions::COMPRESSION_METHOD => \PhpZip\Constants\ZipCompressionMethod::DEFLATED,
\PhpZip\Constants\ZipOptions::MODIFIED_TIME => new \DateTimeImmutable('-1 day 5 min')
]);
```
##### ZipFile::addFromString
Добавляет файл в ZIP-архив, используя его содержимое в виде строки.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile[$entryName] = $contents;
// или
$zipFile->addFromString($entryName, $contents);
// можно указать метод сжатия
$zipFile->addFromString($entryName, $contents, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addFromString($entryName, $contents, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addFromString($entryName, $contents, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
##### ZipFile::addFromStream
Добавляет в ZIP-архив запись из потока.
```php
// $stream = fopen(..., 'rb');
$zipFile->addFromStream($stream, $entryName);
// можно указать метод сжатия
$zipFile->addFromStream($stream, $entryName, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addFromStream($stream, $entryName, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addFromStream($stream, $entryName, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
##### ZipFile::addEmptyDir
Добавляет в ZIP-архив новую (пустую) директорию.
```php
// $path = "path/to/";
$zipFile->addEmptyDir($path);
// или
$zipFile[$path] = null;
```
##### ZipFile::addAll
Добавляет все записи из массива.
```php
$entries = [
'file.txt' => 'file contents', // запись из строки данных
'empty dir/' => null, // пустой каталог
'path/to/file.jpg' => fopen('..../filename', 'rb'), // запись из потока
'path/to/file.dat' => new \SplFileInfo('..../filename'), // запись из файла
];
$zipFile->addAll($entries);
```
##### ZipFile::addDir
Добавляет файлы из директории по указанному пути без вложенных директорий.
```php
$zipFile->addDir($dirName);
// можно указать путь в архиве в который необходимо поместить записи
$localPath = "to/path/";
$zipFile->addDir($dirName, $localPath);
// можно указать метод сжатия
$zipFile->addDir($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addDir($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addDir($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
##### ZipFile::addDirRecursive
Добавляет файлы из директории по указанному пути c вложенными директориями.
```php
$zipFile->addDirRecursive($dirName);
// можно указать путь в архиве в который необходимо поместить записи
$localPath = "to/path/";
$zipFile->addDirRecursive($dirName, $localPath);
// можно указать метод сжатия
$zipFile->addDirRecursive($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addDirRecursive($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addDirRecursive($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
##### ZipFile::addFilesFromIterator
Добавляет файлы из итератора директорий.
```php
// $directoryIterator = new \DirectoryIterator($dir); // без вложенных директорий
// $directoryIterator = new \RecursiveDirectoryIterator($dir); // с вложенными директориями
$zipFile->addFilesFromIterator($directoryIterator);
// можно указать путь в архиве в который необходимо поместить записи
$localPath = "to/path/";
$zipFile->addFilesFromIterator($directoryIterator, $localPath);
// или
$zipFile[$localPath] = $directoryIterator;
// можно указать метод сжатия
$zipFile->addFilesFromIterator($directoryIterator, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addFilesFromIterator($directoryIterator, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addFilesFromIterator($directoryIterator, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
Пример добавления файлов из директории в архив с игнорированием некоторых файлов при помощи итератора директорий.
```php
$ignoreFiles = [
"file_ignore.txt",
"dir_ignore/sub dir ignore/"
];
// $directoryIterator = new \DirectoryIterator($dir); // без вложенных директорий
// $directoryIterator = new \RecursiveDirectoryIterator($dir); // с вложенными директориями
// используйте \PhpZip\Util\Iterator\IgnoreFilesFilterIterator для не рекурсивного поиска
$ignoreIterator = new \PhpZip\Util\Iterator\IgnoreFilesRecursiveFilterIterator(
$directoryIterator,
$ignoreFiles
);
$zipFile->addFilesFromIterator($ignoreIterator);
```
##### ZipFile::addFilesFromGlob
Добавляет файлы из директории в соответствии с [glob шаблоном](https://en.wikipedia.org/wiki/Glob_(programming)) без вложенных директорий.
```php
$globPattern = '**.{jpg,jpeg,png,gif}'; // пример glob шаблона -> добавить все .jpg, .jpeg, .png и .gif файлы
$zipFile->addFilesFromGlob($dir, $globPattern);
// можно указать путь в архиве в который необходимо поместить записи
$localPath = "to/path/";
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath);
// можно указать метод сжатия
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
##### ZipFile::addFilesFromGlobRecursive
Добавляет файлы из директории в соответствии с [glob шаблоном](https://en.wikipedia.org/wiki/Glob_(programming)) c вложенными директориями.
```php
$globPattern = '**.{jpg,jpeg,png,gif}'; // пример glob шаблона -> добавить все .jpg, .jpeg, .png и .gif файлы
$zipFile->addFilesFromGlobRecursive($dir, $globPattern);
// можно указать путь в архиве в который необходимо поместить записи
$localPath = "to/path/";
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath);
// можно указать метод сжатия
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
##### ZipFile::addFilesFromRegex
Добавляет файлы из директории в соответствии с [регулярным выражением](https://en.wikipedia.org/wiki/Regular_expression) без вложенных директорий.
```php
$regexPattern = '/\.(jpe?g|png|gif)$/si'; // пример регулярного выражения -> добавить все .jpg, .jpeg, .png и .gif файлы
$zipFile->addFilesFromRegex($dir, $regexPattern);
// можно указать путь в архиве в который необходимо поместить записи
$localPath = "to/path/";
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath);
// можно указать метод сжатия
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
##### ZipFile::addFilesFromRegexRecursive
Добавляет файлы из директории в соответствии с [регулярным выражением](https://en.wikipedia.org/wiki/Regular_expression) с вложенными директориями.
```php
$regexPattern = '/\.(jpe?g|png|gif)$/si'; // пример регулярного выражения -> добавить все .jpg, .jpeg, .png и .gif файлы
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern);
// можно указать путь в архиве в который необходимо поместить записи
$localPath = "to/path/";
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath);
// можно указать метод сжатия
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // Без сжатия
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate сжатие
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 сжатие
```
#### Удаление записей из архива
##### ZipFile::deleteFromName
Удаляет запись по имени.
```php
$zipFile->deleteFromName($entryName);
```
##### ZipFile::deleteFromGlob
Удаляет записи в соответствии с [glob шаблоном](https://en.wikipedia.org/wiki/Glob_(programming)).
```php
$globPattern = '**.{jpg,jpeg,png,gif}'; // пример glob шаблона -> удалить все .jpg, .jpeg, .png и .gif файлы
$zipFile->deleteFromGlob($globPattern);
```
##### ZipFile::deleteFromRegex
Удаляет записи в соответствии с [регулярным выражением](https://en.wikipedia.org/wiki/Regular_expression).
```php
$regexPattern = '/\.(jpe?g|png|gif)$/si'; // пример регулярному выражения -> удалить все .jpg, .jpeg, .png и .gif файлы
$zipFile->deleteFromRegex($regexPattern);
```
##### ZipFile::deleteAll
Удаляет все записи в ZIP-архиве.
```php
$zipFile->deleteAll();
```
#### Работа с записями и с архивом
##### ZipFile::rename
Переименовывает запись по имени.
```php
$zipFile->rename($oldName, $newName);
```
##### ZipFile::setCompressionLevel
Устанавливает уровень сжатия для всех файлов, находящихся в архиве.
> _Обратите внимание, что действие данного метода не распространяется на записи, добавленные после выполнения этого метода._
По умолчанию используется уровень сжатия 5 (`\PhpZip\Constants\ZipCompressionLevel::NORMAL`) или уровень сжатия, определённый в архиве для Deflate сжатия.
Поддерживаются диапазон значений от 1 (`\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST`) до 9 (`\PhpZip\Constants\ZipCompressionLevel::MAXIMUM`). Чем выше число, тем лучше и дольше сжатие.
```php
$zipFile->setCompressionLevel(\PhpZip\Constants\ZipCompressionLevel::MAXIMUM);
```
##### ZipFile::setCompressionLevelEntry
Устанавливает уровень сжатия для определённой записи в архиве.
Поддерживаются диапазон значений от 1 (`\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST`) до 9 (`\PhpZip\Constants\ZipCompressionLevel::MAXIMUM`). Чем выше число, тем лучше и дольше сжатие.
```php
$zipFile->setCompressionLevelEntry($entryName, \PhpZip\Constants\ZipCompressionLevel::MAXIMUM);
```
##### ZipFile::setCompressionMethodEntry
Устанавливает метод сжатия для определённой записи в архиве.
Доступны следующие методы сжатия:
- `\PhpZip\Constants\ZipCompressionMethod::STORED` - без сжатия
- `\PhpZip\Constants\ZipCompressionMethod::DEFLATED` - Deflate сжатие
- `\PhpZip\Constants\ZipCompressionMethod::BZIP2` - Bzip2 сжатие при наличии расширения `ext-bz2`
```php
$zipFile->setCompressionMethodEntry($entryName, \PhpZip\Constants\ZipCompressionMethod::DEFLATED);
```
##### ZipFile::setArchiveComment
Устанавливает комментарий к ZIP-архиву.
```php
$zipFile->setArchiveComment($commentArchive);
```
##### ZipFile::setEntryComment
Устанавливает комментарий к записи, используя её имя.
```php
$zipFile->setEntryComment($entryName, $comment);
```
##### ZipFile::matcher
Выборка записей в архиве для проведения операций над выбранными записями.
```php
$matcher = $zipFile->matcher();
```
Выбор файлов из архива по одному:
```php
$matcher
->add('entry name')
->add('another entry');
```
Выбор нескольких файлов в архиве:
```php
$matcher->add([
'entry name',
'another entry name',
'path/'
]);
```
Выбор файлов по регулярному выражению:
```php
$matcher->match('~\.jpe?g$~i');
```
Выбор всех файлов в архиве:
```php
$matcher->all();
```
count() - получает количество выбранных записей:
```php
$count = count($matcher);
// или
$count = $matcher->count();
```
getMatches() - получает список выбранных записей:
```php
$entries = $matcher->getMatches();
// пример содержимого: ['entry name', 'another entry name'];
```
invoke() - выполняет пользовательскую функцию над выбранными записями:
```php
// пример
$matcher->invoke(function($entryName) use($zipFile) {
$newName = preg_replace('~\.(jpe?g)$~i', '.no_optimize.$1', $entryName);
$zipFile->rename($entryName, $newName);
});
```
Функции для работы над выбранными записями:
```php
$matcher->delete(); // удалет выбранные записи из ZIP-архива
$matcher->setPassword($password); // устанавливает новый пароль на выбранные записи
$matcher->setPassword($password, $encryptionMethod); // устанавливает новый пароль и метод шифрования на выбранные записи
$matcher->setEncryptionMethod($encryptionMethod); // устанавливает метод шифрования на выбранные записи
$matcher->disableEncryption(); // отключает шифрование для выбранных записей
```
#### Работа с паролями
Реализована поддержка методов шифрования:
- `\PhpZip\Constants\ZipEncryptionMethod::PKWARE` - Traditional PKWARE encryption
- `\PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256` - WinZip AES encryption 256 bit (рекомендуемое)
- `\PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_192` - WinZip AES encryption 192 bit
- `\PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_128` - WinZip AES encryption 128 bit
##### ZipFile::setReadPassword
Устанавливает пароль на чтение открытого запароленного архива для всех зашифрованных записей.
> _Установка пароля не является обязательной для добавления новых записей или удаления существующих, но если вы захотите извлечь контент или изменить метод/уровень сжатия, метод шифрования или изменить пароль, то в этом случае пароль необходимо указать._
```php
$zipFile->setReadPassword($password);
```
##### ZipFile::setReadPasswordEntry
Устанавливает пароль на чтение конкретной зашифрованной записи открытого запароленного архива.
```php
$zipFile->setReadPasswordEntry($entryName, $password);
```
##### ZipFile::setPassword
Устанавливает новый пароль для всех файлов, находящихся в архиве.
> _Обратите внимание, что действие данного метода не распространяется на записи, добавленные после выполнения этого метода._
```php
$zipFile->setPassword($password);
```
Можно установить метод шифрования:
```php
$encryptionMethod = \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256;
$zipFile->setPassword($password, $encryptionMethod);
```
##### ZipFile::setPasswordEntry
Устанавливает новый пароль для конкретного файла.
```php
$zipFile->setPasswordEntry($entryName, $password);
```
Можно установить метод шифрования:
```php
$encryptionMethod = \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256;
$zipFile->setPasswordEntry($entryName, $password, $encryptionMethod);
```
##### ZipFile::disableEncryption
Отключает шифрования всех записей, находящихся в архиве.
> _Обратите внимание, что действие данного метода не распространяется на записи, добавленные после выполнения этого метода._
```php
$zipFile->disableEncryption();
```
##### ZipFile::disableEncryptionEntry
Отключает шифрование записи по её имени.
```php
$zipFile->disableEncryptionEntry($entryName);
```
#### Отмена изменений
##### ZipFile::unchangeAll
Отменяет все изменения, сделанные в архиве.
```php
$zipFile->unchangeAll();
```
##### ZipFile::unchangeArchiveComment
Отменяет изменения в комментарии к архиву.
```php
$zipFile->unchangeArchiveComment();
```
##### ZipFile::unchangeEntry
Отменяет изменения для конкретной записи архива.
```php
$zipFile->unchangeEntry($entryName);
```
#### Сохранение файла или вывод в браузер
##### ZipFile::saveAsFile
Сохраняет архив в файл.
```php
$zipFile->saveAsFile($filename);
```
##### ZipFile::saveAsStream
Записывает архив в поток.
```php
// $fp = fopen($filename, 'w+b');
$zipFile->saveAsStream($fp);
```
##### ZipFile::outputAsString
Выводит ZIP-архив в виде строки.
```php
$rawZipArchiveBytes = $zipFile->outputAsString();
```
##### ZipFile::outputAsAttachment
Выводит ZIP-архив в браузер.
При выводе устанавливаются необходимые заголовки, а после вывода завершается работа скрипта.
```php
$zipFile->outputAsAttachment($outputFilename);
```
Можно установить MIME-тип:
```php
$mimeType = 'application/zip';
$zipFile->outputAsAttachment($outputFilename, $mimeType);
```
##### ZipFile::outputAsPsr7Response
Выводит ZIP-архив, как [PSR-7 Response](http://www.php-fig.org/psr/psr-7/).
Метод вывода может использоваться в любом PSR-7 совместимом фреймворке.
```php
// $response = ....; // instance Psr\Http\Message\ResponseInterface
$zipFile->outputAsPsr7Response($response, $outputFilename);
```
Можно установить MIME-тип:
```php
$mimeType = 'application/zip';
$zipFile->outputAsPsr7Response($response, $outputFilename, $mimeType);
```
##### ZipFile::outputAsSymfonyResponse
Выводит ZIP-архив, как [Symfony Response](https://symfony.com/doc/current/components/http_foundation.html#response).
Метод вывода можно использовать в фреймворке Symfony.
```php
$response = $zipFile->outputAsSymfonyResponse($outputFilename);
```
Вы можете установить Mime-Type:
```php
$mimeType = 'application/zip';
$response = $zipFile->outputAsSymfonyResponse($outputFilename, $mimeType);
```
Пример использования в Symfony Controller:
```php
<?php
namespace App\Controller;
use PhpZip\ZipFile;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class DownloadZipController
{
/**
* @Route("/downloads/{id}")
*
* @throws \PhpZip\Exception\ZipException
*/
public function __invoke(string $id): Response
{
$zipFile = new ZipFile();
$zipFile['file'] = 'contents';
$outputFilename = $id . '.zip';
return $zipFile->outputAsSymfonyResponse($outputFilename);
}
}
```
##### ZipFile::rewrite
Сохраняет изменения и заново открывает изменившийся архив.
```php
$zipFile->rewrite();
```
#### Закрытие архива
##### ZipFile::close
Закрывает ZIP-архив.
```php
$zipFile->close();
```
### Запуск тестов
Установите зависимости для разработки.
```bash
composer install --dev
```
Запустите тесты:
```bash
vendor/bin/phpunit -v -c phpunit.xml
```
### История изменений
История изменений на [странице релизов](https://github.com/Ne-Lexa/php-zip/releases).
### Обновление версий
#### Обновление с версии 3 до версии 4
Обновите мажорную версию в файле `composer.json` до `^4.0`.
```json
{
"require": {
"nelexa/zip": "^4.0"
}
}
```
Затем установите обновления с помощью `Composer`:
```bash
composer update nelexa/zip
```
Обновите ваш код для работы с новой версией:
- удалены устаревшие метроды
- удалён zipalign функционал (он будет помещен в отдельный пакет nelexa/apkfile)
#### Обновление с версии 2 до версии 3
Обновите мажорную версию в файле `composer.json` до `^3.0`.
```json
{
"require": {
"nelexa/zip": "^3.0"
}
}
```
Затем установите обновления с помощью `Composer`:
```bash
composer update nelexa/zip
```
Обновите ваш код для работы с новой версией:
- Класс `ZipOutputFile` объединён с `ZipFile` и удалён.
+ Замените `new \PhpZip\ZipOutputFile()` на `new \PhpZip\ZipFile()`
- Статичиская инициализация методов стала не статической.
+ Замените `\PhpZip\ZipFile::openFromFile($filename);` на `(new \PhpZip\ZipFile())->openFile($filename);`
+ Замените `\PhpZip\ZipOutputFile::openFromFile($filename);` на `(new \PhpZip\ZipFile())->openFile($filename);`
+ Замените `\PhpZip\ZipFile::openFromString($contents);` на `(new \PhpZip\ZipFile())->openFromString($contents);`
+ Замените `\PhpZip\ZipFile::openFromStream($stream);` на `(new \PhpZip\ZipFile())->openFromStream($stream);`
+ Замените `\PhpZip\ZipOutputFile::create()` на `new \PhpZip\ZipFile()`
+ Замените `\PhpZip\ZipOutputFile::openFromZipFile($zipFile)` на `(new \PhpZip\ZipFile())->openFile($filename);`
- Переименуйте методы:
+ `addFromFile` в `addFile`
+ `setLevel` в `setCompressionLevel`
+ `ZipFile::setPassword` в `ZipFile::withReadPassword`
+ `ZipOutputFile::setPassword` в `ZipFile::withNewPassword`
+ `ZipOutputFile::disableEncryptionAllEntries` в `ZipFile::withoutPassword`
+ `ZipOutputFile::setComment` в `ZipFile::setArchiveComment`
+ `ZipFile::getComment` в `ZipFile::getArchiveComment`
- Изменились сигнатуры для методов `addDir`, `addFilesFromGlob`, `addFilesFromRegex`.
- Удалены методы:
+ `getLevel`
+ `setCompressionMethod`
+ `setEntryPassword`

915
vendor/nelexa/zip/README.md vendored Normal file
View File

@ -0,0 +1,915 @@
<h1 align="center"><img src="logo.svg" alt="PhpZip" width="250" height="51"></h1>
`PhpZip` is a php-library for extended work with ZIP-archives.
[![Packagist Version](https://img.shields.io/packagist/v/nelexa/zip.svg)](https://packagist.org/packages/nelexa/zip)
[![Packagist Downloads](https://img.shields.io/packagist/dt/nelexa/zip.svg?color=%23ff007f)](https://packagist.org/packages/nelexa/zip)
[![Code Coverage](https://scrutinizer-ci.com/g/Ne-Lexa/php-zip/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Ne-Lexa/php-zip/?branch=master)
[![Build Status](https://github.com/Ne-Lexa/php-zip/workflows/build/badge.svg)](https://github.com/Ne-Lexa/php-zip/actions)
[![License](https://img.shields.io/packagist/l/nelexa/zip.svg)](https://github.com/Ne-Lexa/php-zip/blob/master/LICENSE)
[Russian Documentation](README.RU.md)
### Versions & Dependencies
| Version | PHP | Documentation |
| ------------------- | ---------- | -------------------------------------------------------------------- |
| ^4.0 (master) | ^7.4\|^8.0 | current |
| ^3.0 | ^5.5\|^7.0 | [Docs v3.3](https://github.com/Ne-Lexa/php-zip/blob/3.3.3/README.md) |
Table of contents
-----------------
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Examples](#examples)
- [Glossary](#glossary)
- [Documentation](#documentation)
+ [Overview of methods of the class `\PhpZip\ZipFile`](#overview-of-methods-of-the-class-phpzipzipfile)
+ [Creation/Opening of ZIP-archive](#creationopening-of-zip-archive)
+ [Reading entries from the archive](#reading-entries-from-the-archive)
+ [Iterating entries](#iterating-entries)
+ [Getting information about entries](#getting-information-about-entries)
+ [Adding entries to the archive](#adding-entries-to-the-archive)
+ [Deleting entries from the archive](#deleting-entries-from-the-archive)
+ [Working with entries and archive](#working-with-entries-and-archive)
+ [Working with passwords](#working-with-passwords)
+ [Undo changes](#undo-changes)
+ [Saving a file or output to a browser](#saving-a-file-or-output-to-a-browser)
+ [Closing the archive](#closing-the-archive)
- [Running the tests](#running-the-tests)
- [Changelog](#changelog)
- [Upgrade](#upgrade)
+ [Upgrade version 3 to version 4](#upgrade-version-3-to-version-4)
+ [Upgrade version 2 to version 3](#upgrade-version-2-to-version-3)
### Features
- Opening and unzipping zip files.
- Creating ZIP-archives.
- Modifying ZIP archives.
- Pure php (not require extension `php-zip` and class `\ZipArchive`).
- It supports saving the archive to a file, outputting the archive to the browser, or outputting it as a string without saving it to a file.
- Archival comments and comments of individual entry are supported.
- Get information about each entry in the archive.
- Only the following compression methods are supported:
+ No compressed (Stored).
+ Deflate compression.
+ BZIP2 compression with the extension `php-bz2`.
- Support for `ZIP64` (file size is more than 4 GB or the number of entries in the archive is more than 65535).
- Working with passwords
> **Attention!**
>
> For 32-bit systems, the `Traditional PKWARE Encryption (ZipCrypto)` encryption method is not currently supported.
> Use the encryption method `WinZIP AES Encryption`, whenever possible.
+ Set the password to read the archive for all entries or only for some.
+ Change the password for the archive, including for individual entries.
+ Delete the archive password for all or individual entries.
+ Set the password and/or the encryption method, both for all, and for individual entries in the archive.
+ Set different passwords and encryption methods for different entries.
+ Delete the password for all or some entries.
+ Support `Traditional PKWARE Encryption (ZipCrypto)` and `WinZIP AES Encryption` encryption methods.
+ Set the encryption method for all or individual entries in the archive.
### Requirements
- `PHP` >= 7.4 or `PHP` >= 8.0 (preferably 64-bit).
- Optional php-extension `bzip2` for BZIP2 compression.
- Optional php-extension `openssl` for `WinZip Aes Encryption` support.
### Installation
`composer require nelexa/zip`
Latest stable version: [![Latest Stable Version](https://poser.pugx.org/nelexa/zip/v/stable)](https://packagist.org/packages/nelexa/zip)
### Examples
```php
// create new archive
$zipFile = new \PhpZip\ZipFile();
try{
$zipFile
->addFromString('zip/entry/filename', 'Is file content') // add an entry from the string
->addFile('/path/to/file', 'data/tofile') // add an entry from the file
->addDir(__DIR__, 'to/path/') // add files from the directory
->saveAsFile($outputFilename) // save the archive to a file
->close(); // close archive
// open archive, extract, add files, set password and output to browser.
$zipFile
->openFile($outputFilename) // open archive from file
->extractTo($outputDirExtract) // extract files to the specified directory
->deleteFromRegex('~^\.~') // delete all hidden (Unix) files
->addFromString('dir/file.txt', 'Test file') // add a new entry from the string
->setPassword('password') // set password for all entries
->outputAsAttachment('library.jar'); // output to the browser without saving to a file
}
catch(\PhpZip\Exception\ZipException $e){
// handle exception
}
finally{
$zipFile->close();
}
```
Other examples can be found in the `tests/` folder
### Glossary
**Zip Entry** - file or folder in a ZIP-archive. Each entry in the archive has certain properties, for example: file name, compression method, encryption method, file size before compression, file size after compression, CRC32 and others.
### Documentation:
#### Overview of methods of the class `\PhpZip\ZipFile`
- [ZipFile::__construct](#zipfile__construct) - initializes the ZIP archive.
- [ZipFile::addAll](#zipfileaddall) - adds all entries from an array.
- [ZipFile::addDir](#zipfileadddir) - adds files to the archive from the directory on the specified path without subdirectories.
- [ZipFile::addDirRecursive](#zipfileadddirrecursive) - adds files to the archive from the directory on the specified path with subdirectories.
- [ZipFile::addEmptyDir](#zipfileaddemptydir) - add a new directory.
- [ZipFile::addFile](#zipfileaddfile) - adds a file to a ZIP archive from the given path.
- [ZipFile::addSplFile](#zipfileaddsplfile) - adds a `\SplFileInfo` to a ZIP archive.
- [ZipFile::addFromFinder](#zipfileaddfromfinder) - adds files from the `Symfony\Component\Finder\Finder` to a ZIP archive.
- [ZipFile::addFilesFromIterator](#zipfileaddfilesfromiterator) - adds files from the iterator of directories.
- [ZipFile::addFilesFromGlob](#zipfileaddfilesfromglob) - adds files from a directory by glob pattern without subdirectories.
- [ZipFile::addFilesFromGlobRecursive](#zipfileaddfilesfromglobrecursive) - adds files from a directory by glob pattern with subdirectories.
- [ZipFile::addFilesFromRegex](#zipfileaddfilesfromregex) - adds files from a directory by PCRE pattern without subdirectories.
- [ZipFile::addFilesFromRegexRecursive](#zipfileaddfilesfromregexrecursive) - adds files from a directory by PCRE pattern with subdirectories.
- [ZipFile::addFromStream](#zipfileaddfromstream) - adds an entry from the stream to the ZIP archive.
- [ZipFile::addFromString](#zipfileaddfromstring) - adds a file to a ZIP archive using its contents.
- [ZipFile::close](#zipfileclose) - close the archive.
- [ZipFile::count](#zipfilecount) - returns the number of entries in the archive.
- [ZipFile::deleteFromName](#zipfiledeletefromname) - deletes an entry in the archive using its name.
- [ZipFile::deleteFromGlob](#zipfiledeletefromglob) - deletes an entries in the archive using glob pattern.
- [ZipFile::deleteFromRegex](#zipfiledeletefromregex) - deletes an entries in the archive using PCRE pattern.
- [ZipFile::deleteAll](#zipfiledeleteall) - deletes all entries in the ZIP archive.
- [ZipFile::disableEncryption](#zipfiledisableencryption) - disable encryption for all entries that are already in the archive.
- [ZipFile::disableEncryptionEntry](#zipfiledisableencryptionentry) - disable encryption of an entry defined by its name.
- [ZipFile::extractTo](#zipfileextractto) - extract the archive contents.
- [ZipFile::getArchiveComment](#zipfilegetarchivecomment) - returns the Zip archive comment.
- [ZipFile::getEntryComment](#zipfilegetentrycomment) - returns the comment of an entry using the entry name.
- [ZipFile::getEntryContent](#zipfilegetentrycontent) - returns the entry contents using its name.
- [ZipFile::getListFiles](#zipfilegetlistfiles) - returns list of archive files.
- [ZipFile::hasEntry](#zipfilehasentry) - checks if there is an entry in the archive.
- [ZipFile::isDirectory](#zipfileisdirectory) - checks that the entry in the archive is a directory.
- [ZipFile::matcher](#zipfilematcher) - selecting entries in the archive to perform operations on them.
- [ZipFile::openFile](#zipfileopenfile) - opens a zip-archive from a file.
- [ZipFile::openFromString](#zipfileopenfromstring) - opens a zip-archive from a string.
- [ZipFile::openFromStream](#zipfileopenfromstream) - opens a zip-archive from the stream.
- [ZipFile::outputAsAttachment](#zipfileoutputasattachment) - outputs a ZIP-archive to the browser.
- [ZipFile::outputAsPsr7Response](#zipfileoutputaspsr7response) - outputs a ZIP-archive as PSR-7 Response.
- [ZipFile::outputAsSymfonyResponse](#zipfileoutputaspsr7response) - outputs a ZIP-archive as Symfony Response.
- [ZipFile::outputAsString](#zipfileoutputasstring) - outputs a ZIP-archive as string.
- [ZipFile::rename](#zipfilerename) - renames an entry defined by its name.
- [ZipFile::rewrite](#zipfilerewrite) - save changes and re-open the changed archive.
- [ZipFile::saveAsFile](#zipfilesaveasfile) - saves the archive to a file.
- [ZipFile::saveAsStream](#zipfilesaveasstream) - writes the archive to the stream.
- [ZipFile::setArchiveComment](#zipfilesetarchivecomment) - set the comment of a ZIP archive.
- [ZipFile::setCompressionLevel](#zipfilesetcompressionlevel) - set the compression level for all files in the archive.
- [ZipFile::setCompressionLevelEntry](#zipfilesetcompressionlevelentry) - sets the compression level for the entry by its name.
- [ZipFile::setCompressionMethodEntry](#zipfilesetcompressionmethodentry) - sets the compression method for the entry by its name.
- [ZipFile::setEntryComment](#zipfilesetentrycomment) - set the comment of an entry defined by its name.
- [ZipFile::setReadPassword](#zipfilesetreadpassword) - set the password for the open archive.
- [ZipFile::setReadPasswordEntry](#zipfilesetreadpasswordentry) - sets a password for reading of an entry defined by its name.
- [ZipFile::setPassword](#zipfilesetpassword) - sets a new password for all files in the archive.
- [ZipFile::setPasswordEntry](#zipfilesetpasswordentry) - sets a new password of an entry defined by its name.
- [ZipFile::unchangeAll](#zipfileunchangeall) - undo all changes done in the archive.
- [ZipFile::unchangeArchiveComment](#zipfileunchangearchivecomment) - undo changes to the archive comment.
- [ZipFile::unchangeEntry](#zipfileunchangeentry) - undo changes of an entry defined by its name.
#### Creation/Opening of ZIP-archive
##### ZipFile::__construct**
Initializes the ZIP archive
```php
$zipFile = new \PhpZip\ZipFile();
```
##### ZipFile::openFile
Opens a zip-archive from a file.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->openFile('file.zip');
```
##### ZipFile::openFromString
Opens a zip-archive from a string.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->openFromString($stringContents);
```
##### ZipFile::openFromStream
Opens a zip-archive from the stream.
```php
$stream = fopen('file.zip', 'rb');
$zipFile = new \PhpZip\ZipFile();
$zipFile->openFromStream($stream);
```
#### Reading entries from the archive
##### ZipFile::count
Returns the number of entries in the archive.
```php
$zipFile = new \PhpZip\ZipFile();
$count = count($zipFile);
// or
$count = $zipFile->count();
```
##### ZipFile::getListFiles
Returns list of archive files.
```php
$zipFile = new \PhpZip\ZipFile();
$listFiles = $zipFile->getListFiles();
// example array contents:
// array (
// 0 => 'info.txt',
// 1 => 'path/to/file.jpg',
// 2 => 'another path/',
// 3 => '0',
// )
```
##### ZipFile::getEntryContent
Returns the entry contents using its name.
```php
// $entryName = 'path/to/example-entry-name.txt';
$zipFile = new \PhpZip\ZipFile();
$contents = $zipFile[$entryName];
// or
$contents = $zipFile->getEntryContents($entryName);
```
##### ZipFile::hasEntry
Checks if there is an entry in the archive.
```php
// $entryName = 'path/to/example-entry-name.txt';
$zipFile = new \PhpZip\ZipFile();
$hasEntry = isset($zipFile[$entryName]);
// or
$hasEntry = $zipFile->hasEntry($entryName);
```
##### ZipFile::isDirectory
Checks that the entry in the archive is a directory.
```php
// $entryName = 'path/to/';
$zipFile = new \PhpZip\ZipFile();
$isDirectory = $zipFile->isDirectory($entryName);
```
##### ZipFile::extractTo
Extract the archive contents.
The directory must exist.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->extractTo($directory);
```
Extract some files to the directory.
The directory must exist.
```php
// $toDirectory = '/tmp';
$extractOnlyFiles = [
'filename1',
'filename2',
'dir/dir/dir/'
];
$zipFile = new \PhpZip\ZipFile();
$zipFile->extractTo($toDirectory, $extractOnlyFiles);
```
#### Iterating entries
`ZipFile` is an iterator.
Can iterate all the entries in the `foreach` loop.
```php
foreach($zipFile as $entryName => $contents){
echo "Filename: $entryName" . PHP_EOL;
echo "Contents: $contents" . PHP_EOL;
echo '-----------------------------' . PHP_EOL;
}
```
Can iterate through the `Iterator`.
```php
$iterator = new \ArrayIterator($zipFile);
while ($iterator->valid())
{
$entryName = $iterator->key();
$contents = $iterator->current();
echo "Filename: $entryName" . PHP_EOL;
echo "Contents: $contents" . PHP_EOL;
echo '-----------------------------' . PHP_EOL;
$iterator->next();
}
```
#### Getting information about entries
##### ZipFile::getArchiveComment
Returns the Zip archive comment.
```php
$zipFile = new \PhpZip\ZipFile();
$commentArchive = $zipFile->getArchiveComment();
```
##### ZipFile::getEntryComment
Returns the comment of an entry using the entry name.
```php
$zipFile = new \PhpZip\ZipFile();
$commentEntry = $zipFile->getEntryComment($entryName);
```
#### Adding entries to the archive
All methods of adding entries to a ZIP archive allow you to specify a method for compressing content.
The following methods of compression are available:
- `\PhpZip\Constants\ZipCompressionMethod::STORED` - no compression
- `\PhpZip\Constants\ZipCompressionMethod::DEFLATED` - Deflate compression
- `\PhpZip\Constants\ZipCompressionMethod::BZIP2` - Bzip2 compression with the extension `ext-bz2`
##### ZipFile::addFile
Adds a file to a ZIP archive from the given path.
```php
$zipFile = new \PhpZip\ZipFile();
// $file = '...../file.ext';
// $entryName = 'file2.ext'
$zipFile->addFile($file);
// you can specify the name of the entry in the archive (if null, then the last component from the file name is used)
$zipFile->addFile($file, $entryName);
// you can specify a compression method
$zipFile->addFile($file, $entryName, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addFile($file, $entryName, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFile($file, $entryName, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
##### ZipFile::addSplFile
Adds a `\SplFileInfo` to a ZIP archive.
```php
// $file = '...../file.ext';
// $entryName = 'file2.ext'
$zipFile = new \PhpZip\ZipFile();
$splFile = new \SplFileInfo('README.md');
$zipFile->addSplFile($splFile);
$zipFile->addSplFile($splFile, $entryName);
// or
$zipFile[$entryName] = new \SplFileInfo($file);
// set compression method
$zipFile->addSplFile($splFile, $entryName, $options = [
\PhpZip\Constants\ZipOptions::COMPRESSION_METHOD => \PhpZip\Constants\ZipCompressionMethod::DEFLATED,
]);
```
##### ZipFile::addFromFinder
Adds files from the [`Symfony\Component\Finder\Finder`](https://symfony.com/doc/current/components/finder.html) to a ZIP archive.
```php
$finder = new \Symfony\Component\Finder\Finder();
$finder
->files()
->name('*.{jpg,jpeg,gif,png}')
->name('/^[0-9a-f]\./')
->contains('/lorem\s+ipsum$/i')
->in('path');
$zipFile = new \PhpZip\ZipFile();
$zipFile->addFromFinder($finder, $options = [
\PhpZip\Constants\ZipOptions::COMPRESSION_METHOD => \PhpZip\Constants\ZipCompressionMethod::DEFLATED,
\PhpZip\Constants\ZipOptions::MODIFIED_TIME => new \DateTimeImmutable('-1 day 5 min')
]);
```
##### ZipFile::addFromString
Adds a file to a ZIP archive using its contents.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile[$entryName] = $contents;
// or
$zipFile->addFromString($entryName, $contents);
// you can specify a compression method
$zipFile->addFromString($entryName, $contents, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addFromString($entryName, $contents, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFromString($entryName, $contents, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
##### ZipFile::addFromStream
Adds an entry from the stream to the ZIP archive.
```php
$zipFile = new \PhpZip\ZipFile();
// $stream = fopen(..., 'rb');
$zipFile->addFromStream($stream, $entryName);
// or
$zipFile[$entryName] = $stream;
// you can specify a compression method
$zipFile->addFromStream($stream, $entryName, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addFromStream($stream, $entryName, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFromStream($stream, $entryName, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
##### ZipFile::addEmptyDir
Add a new directory.
```php
$zipFile = new \PhpZip\ZipFile();
// $path = "path/to/";
$zipFile->addEmptyDir($path);
// or
$zipFile[$path] = null;
```
##### ZipFile::addAll
Adds all entries from an array.
```php
$entries = [
'file.txt' => 'file contents', // add an entry from the string contents
'empty dir/' => null, // add empty directory
'path/to/file.jpg' => fopen('..../filename', 'rb'), // add an entry from the stream
'path/to/file.dat' => new \SplFileInfo('..../filename'), // add an entry from the file
];
$zipFile = new \PhpZip\ZipFile();
$zipFile->addAll($entries);
```
##### ZipFile::addDir
Adds files to the archive from the directory on the specified path without subdirectories.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->addDir($dirName);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addDir($dirName, $localPath);
// you can specify a compression method
$zipFile->addDir($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addDir($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addDir($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
##### ZipFile::addDirRecursive
Adds files to the archive from the directory on the specified path with subdirectories.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->addDirRecursive($dirName);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addDirRecursive($dirName, $localPath);
// you can specify a compression method
$zipFile->addDirRecursive($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addDirRecursive($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addDirRecursive($dirName, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
##### ZipFile::addFilesFromIterator
Adds files from the iterator of directories.
```php
// $directoryIterator = new \DirectoryIterator($dir); // without subdirectories
// $directoryIterator = new \RecursiveDirectoryIterator($dir); // with subdirectories
$zipFile = new \PhpZip\ZipFile();
$zipFile->addFilesFromIterator($directoryIterator);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromIterator($directoryIterator, $localPath);
// or
$zipFile[$localPath] = $directoryIterator;
// you can specify a compression method
$zipFile->addFilesFromIterator($directoryIterator, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromIterator($directoryIterator, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromIterator($directoryIterator, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
Example with some files ignoring:
```php
$ignoreFiles = [
'file_ignore.txt',
'dir_ignore/sub dir ignore/'
];
// $directoryIterator = new \DirectoryIterator($dir); // without subdirectories
// $directoryIterator = new \RecursiveDirectoryIterator($dir); // with subdirectories
// use \PhpZip\Util\Iterator\IgnoreFilesFilterIterator for non-recursive search
$zipFile = new \PhpZip\ZipFile();
$ignoreIterator = new \PhpZip\Util\Iterator\IgnoreFilesRecursiveFilterIterator(
$directoryIterator,
$ignoreFiles
);
$zipFile->addFilesFromIterator($ignoreIterator);
```
##### ZipFile::addFilesFromGlob
Adds files from a directory by [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) without subdirectories.
```php
$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern -> add all .jpg, .jpeg, .png and .gif files
$zipFile = new \PhpZip\ZipFile();
$zipFile->addFilesFromGlob($dir, $globPattern);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath);
// you can specify a compression method
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
##### ZipFile::addFilesFromGlobRecursive
Adds files from a directory by [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) with subdirectories.
```php
$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern -> add all .jpg, .jpeg, .png and .gif files
$zipFile = new \PhpZip\ZipFile();
$zipFile->addFilesFromGlobRecursive($dir, $globPattern);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath);
// you can specify a compression method
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
##### ZipFile::addFilesFromRegex
Adds files from a directory by [PCRE pattern](https://en.wikipedia.org/wiki/Regular_expression) without subdirectories.
```php
$regexPattern = '/\.(jpe?g|png|gif)$/si'; // example regex pattern -> add all .jpg, .jpeg, .png and .gif files
$zipFile = new \PhpZip\ZipFile();
$zipFile->addFilesFromRegex($dir, $regexPattern);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath);
// you can specify a compression method
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
##### ZipFile::addFilesFromRegexRecursive
Adds files from a directory by [PCRE pattern](https://en.wikipedia.org/wiki/Regular_expression) with subdirectories.
```php
$regexPattern = '/\.(jpe?g|png|gif)$/si'; // example regex pattern -> add all .jpg, .jpeg, .png and .gif files
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath);
// you can specify a compression method
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
```
#### Deleting entries from the archive
##### ZipFile::deleteFromName
Deletes an entry in the archive using its name.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->deleteFromName($entryName);
```
##### ZipFile::deleteFromGlob
Deletes a entries in the archive using [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)).
```php
$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern -> delete all .jpg, .jpeg, .png and .gif files
$zipFile = new \PhpZip\ZipFile();
$zipFile->deleteFromGlob($globPattern);
```
##### ZipFile::deleteFromRegex
Deletes a entries in the archive using [PCRE pattern](https://en.wikipedia.org/wiki/Regular_expression).
```php
$regexPattern = '/\.(jpe?g|png|gif)$/si'; // example regex pattern -> delete all .jpg, .jpeg, .png and .gif files
$zipFile = new \PhpZip\ZipFile();
$zipFile->deleteFromRegex($regexPattern);
```
##### ZipFile::deleteAll
Deletes all entries in the ZIP archive.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->deleteAll();
```
#### Working with entries and archive
##### ZipFile::rename
Renames an entry defined by its name.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->rename($oldName, $newName);
```
##### ZipFile::setCompressionLevel
Set the compression level for all files in the archive.
> _Note that this method does not apply to entries that are added after this method is run._
By default, the compression level is 5 (`\PhpZip\Constants\ZipCompressionLevel::NORMAL`) or the compression level specified in the archive for Deflate compression.
The values range from 1 (`\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST`) to 9 (`\PhpZip\Constants\ZipCompressionLevel::MAXIMUM`) are supported. The higher the number, the better and longer the compression.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->setCompressionLevel(\PhpZip\Constants\ZipCompressionLevel::MAXIMUM);
```
##### ZipFile::setCompressionLevelEntry
Sets the compression level for the entry by its name.
The values range from 1 (`\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST`) to 9 (`\PhpZip\Constants\ZipCompressionLevel::MAXIMUM`) are supported. The higher the number, the better and longer the compression.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->setCompressionLevelEntry($entryName, \PhpZip\Constants\ZipCompressionLevel::FAST);
```
##### ZipFile::setCompressionMethodEntry
Sets the compression method for the entry by its name.
The following compression methods are available:
- `\PhpZip\Constants\ZipCompressionMethod::STORED` - No compression
- `\PhpZip\Constants\ZipCompressionMethod::DEFLATED` - Deflate compression
- `\PhpZip\Constants\ZipCompressionMethod::BZIP2` - Bzip2 compression with the extension `ext-bz2`
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->setCompressionMethodEntry($entryName, \PhpZip\Constants\ZipCompressionMethod::DEFLATED);
```
##### ZipFile::setArchiveComment
Set the comment of a ZIP archive.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->setArchiveComment($commentArchive);
```
##### ZipFile::setEntryComment
Set the comment of an entry defined by its name.
```php
$zipFile = new \PhpZip\ZipFile();
$zipFile->setEntryComment($entryName, $comment);
```
##### ZipFile::matcher
Selecting entries in the archive to perform operations on them.
```php
$zipFile = new \PhpZip\ZipFile();
$matcher = $zipFile->matcher();
```
Selecting files from the archive one at a time:
```php
$matcher
->add('entry name')
->add('another entry');
```
Select multiple files in the archive:
```php
$matcher->add([
'entry name',
'another entry name',
'path/'
]);
```
Selecting files by regular expression:
```php
$matcher->match('~\.jpe?g$~i');
```
Select all files in the archive:
```php
$matcher->all();
```
count() - gets the number of selected entries:
```php
$count = count($matcher);
// or
$count = $matcher->count();
```
getMatches() - returns a list of selected entries:
```php
$entries = $matcher->getMatches();
// example array contents: ['entry name', 'another entry name'];
```
invoke() - invoke a callable function on selected entries:
```php
// example
$matcher->invoke(static function($entryName) use($zipFile) {
$newName = preg_replace('~\.(jpe?g)$~i', '.no_optimize.$1', $entryName);
$zipFile->rename($entryName, $newName);
});
```
Functions for working on the selected entries:
```php
$matcher->delete(); // remove selected entries from a ZIP archive
$matcher->setPassword($password); // sets a new password for the selected entries
$matcher->setPassword($password, $encryptionMethod); // sets a new password and encryption method to selected entries
$matcher->setEncryptionMethod($encryptionMethod); // sets the encryption method to the selected entries
$matcher->disableEncryption(); // disables encryption for selected entries
```
#### Working with passwords
Implemented support for encryption methods:
- `\PhpZip\Constants\ZipEncryptionMethod::PKWARE` - Traditional PKWARE encryption (legacy)
- `\PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256` - WinZip AES encryption 256 bit (recommended)
- `\PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_192` - WinZip AES encryption 192 bit
- `\PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_128` - WinZip AES encryption 128 bit
##### ZipFile::setReadPassword
Set the password for the open archive.
> _Setting a password is not required for adding new entries or deleting existing ones, but if you want to extract the content or change the method / compression level, the encryption method, or change the password, in this case the password must be specified._
```php
$zipFile->setReadPassword($password);
```
##### ZipFile::setReadPasswordEntry
Gets a password for reading of an entry defined by its name.
```php
$zipFile->setReadPasswordEntry($entryName, $password);
```
##### ZipFile::setPassword
Sets a new password for all files in the archive.
> _Note that this method does not apply to entries that are added after this method is run._
```php
$zipFile->setPassword($password);
```
You can set the encryption method:
```php
$encryptionMethod = \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256;
$zipFile->setPassword($password, $encryptionMethod);
```
##### ZipFile::setPasswordEntry
Sets a new password of an entry defined by its name.
```php
$zipFile->setPasswordEntry($entryName, $password);
```
You can set the encryption method:
```php
$encryptionMethod = \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256;
$zipFile->setPasswordEntry($entryName, $password, $encryptionMethod);
```
##### ZipFile::disableEncryption
Disable encryption for all entries that are already in the archive.
> _Note that this method does not apply to entries that are added after this method is run._
```php
$zipFile->disableEncryption();
```
##### ZipFile::disableEncryptionEntry
Disable encryption of an entry defined by its name.
```php
$zipFile->disableEncryptionEntry($entryName);
```
#### Undo changes
##### ZipFile::unchangeAll
Undo all changes done in the archive.
```php
$zipFile->unchangeAll();
```
##### ZipFile::unchangeArchiveComment
Undo changes to the archive comment.
```php
$zipFile->unchangeArchiveComment();
```
##### ZipFile::unchangeEntry
Undo changes of an entry defined by its name.
```php
$zipFile->unchangeEntry($entryName);
```
#### Saving a file or output to a browser
##### ZipFile::saveAsFile
Saves the archive to a file.
```php
$zipFile->saveAsFile($filename);
```
##### ZipFile::saveAsStream
Writes the archive to the stream.
```php
// $fp = fopen($filename, 'w+b');
$zipFile->saveAsStream($fp);
```
##### ZipFile::outputAsString
Outputs a ZIP-archive as string.
```php
$rawZipArchiveBytes = $zipFile->outputAsString();
```
##### ZipFile::outputAsAttachment
Outputs a ZIP-archive to the browser.
```php
$zipFile->outputAsAttachment($outputFilename);
```
You can set the Mime-Type:
```php
$mimeType = 'application/zip';
$zipFile->outputAsAttachment($outputFilename, $mimeType);
```
##### ZipFile::outputAsPsr7Response
Outputs a ZIP-archive as [PSR-7 Response](http://www.php-fig.org/psr/psr-7/).
The output method can be used in any PSR-7 compatible framework.
```php
// $response = ....; // instance Psr\Http\Message\ResponseInterface
$zipFile->outputAsPsr7Response($response, $outputFilename);
```
You can set the Mime-Type:
```php
$mimeType = 'application/zip';
$zipFile->outputAsPsr7Response($response, $outputFilename, $mimeType);
```
##### ZipFile::outputAsSymfonyResponse
Outputs a ZIP-archive as [Symfony Response](https://symfony.com/doc/current/components/http_foundation.html#response).
The output method can be used in Symfony framework.
```php
$response = $zipFile->outputAsSymfonyResponse($outputFilename);
```
You can set the Mime-Type:
```php
$mimeType = 'application/zip';
$response = $zipFile->outputAsSymfonyResponse($outputFilename, $mimeType);
```
Example use in Symfony Controller:
```php
<?php
namespace App\Controller;
use PhpZip\ZipFile;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class DownloadZipController
{
/**
* @Route("/downloads/{id}")
*
* @throws \PhpZip\Exception\ZipException
*/
public function __invoke(string $id): Response
{
$zipFile = new ZipFile();
$zipFile['file'] = 'contents';
$outputFilename = $id . '.zip';
return $zipFile->outputAsSymfonyResponse($outputFilename);
}
}
```
##### ZipFile::rewrite
Save changes and re-open the changed archive.
```php
$zipFile->rewrite();
```
#### Closing the archive
##### ZipFile::close
Close the archive.
```php
$zipFile->close();
```
### Running the tests
Install the dependencies for the development:
```bash
composer install --dev
```
Run the tests:
```bash
vendor/bin/phpunit
```
### Changelog
Changes are documented in the [releases page](https://github.com/Ne-Lexa/php-zip/releases).
### Upgrade
#### Upgrade version 3 to version 4
Update the major version in the file `composer.json` to `^4.0`.
```json
{
"require": {
"nelexa/zip": "^4.0"
}
}
```
Then install updates using `Composer`:
```bash
composer update nelexa/zip
```
Update your code to work with the new version:
**BC**
- removed deprecated classes and methods.
- removed `zipalign` functional. This functionality will be placed in a separate package `nelexa/apkfile`.
#### Upgrade version 2 to version 3
Update the major version in the file `composer.json` to `^3.0`.
```json
{
"require": {
"nelexa/zip": "^3.0"
}
}
```
Then install updates using `Composer`:
```bash
composer update nelexa/zip
```
Update your code to work with the new version:
- Class `ZipOutputFile` merged to `ZipFile` and removed.
+ `new \PhpZip\ZipOutputFile()` to `new \PhpZip\ZipFile()`
- Static initialization methods are now not static.
+ `\PhpZip\ZipFile::openFromFile($filename);` to `(new \PhpZip\ZipFile())->openFile($filename);`
+ `\PhpZip\ZipOutputFile::openFromFile($filename);` to `(new \PhpZip\ZipFile())->openFile($filename);`
+ `\PhpZip\ZipFile::openFromString($contents);` to `(new \PhpZip\ZipFile())->openFromString($contents);`
+ `\PhpZip\ZipFile::openFromStream($stream);` to `(new \PhpZip\ZipFile())->openFromStream($stream);`
+ `\PhpZip\ZipOutputFile::create()` to `new \PhpZip\ZipFile()`
+ `\PhpZip\ZipOutputFile::openFromZipFile(\PhpZip\ZipFile $zipFile)` &gt; `(new \PhpZip\ZipFile())->openFile($filename);`
- Rename methods:
+ `addFromFile` to `addFile`
+ `setLevel` to `setCompressionLevel`
+ `ZipFile::setPassword` to `ZipFile::withReadPassword`
+ `ZipOutputFile::setPassword` to `ZipFile::withNewPassword`
+ `ZipOutputFile::disableEncryptionAllEntries` to `ZipFile::withoutPassword`
+ `ZipOutputFile::setComment` to `ZipFile::setArchiveComment`
+ `ZipFile::getComment` to `ZipFile::getArchiveComment`
- Changed signature for methods `addDir`, `addFilesFromGlob`, `addFilesFromRegex`.
- Remove methods:
+ `getLevel`
+ `setCompressionMethod`
+ `setEntryPassword`

64
vendor/nelexa/zip/composer.json vendored Normal file
View File

@ -0,0 +1,64 @@
{
"name": "nelexa/zip",
"type": "library",
"description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.",
"keywords": [
"zip",
"unzip",
"archive",
"extract",
"winzip",
"ziparchive"
],
"homepage": "https://github.com/Ne-Lexa/php-zip",
"license": "MIT",
"authors": [
{
"name": "Ne-Lexa",
"email": "alexey@nelexa.ru",
"role": "Developer"
}
],
"require": {
"php": "^7.4 || ^8.0",
"ext-zlib": "*",
"psr/http-message": "*",
"symfony/finder": "*"
},
"require-dev": {
"ext-iconv": "*",
"ext-bz2": "*",
"ext-openssl": "*",
"ext-fileinfo": "*",
"ext-xml": "*",
"ext-dom": "*",
"guzzlehttp/psr7": "^1.6",
"phpunit/phpunit": "^9",
"symfony/var-dumper": "*",
"friendsofphp/php-cs-fixer": "^3.4.0",
"vimeo/psalm": "^4.6",
"symfony/http-foundation": "*"
},
"autoload": {
"psr-4": {
"PhpZip\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"PhpZip\\Tests\\": "tests/"
}
},
"suggest": {
"ext-iconv": "Needed to support convert zip entry name to requested character encoding",
"ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt",
"ext-bz2": "Needed to support BZIP2 compression",
"ext-fileinfo": "Needed to get mime-type file"
},
"minimum-stability": "stable",
"scripts": {
"php:fix": "php .php_cs --force",
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
"test:coverage": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
}
}

View File

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
interface DosAttrs
{
/** @var int DOS File Attribute Read Only */
public const DOS_READ_ONLY = 0x01;
/** @var int DOS File Attribute Hidden */
public const DOS_HIDDEN = 0x02;
/** @var int DOS File Attribute System */
public const DOS_SYSTEM = 0x04;
/** @var int DOS File Attribute Label */
public const DOS_LABEL = 0x08;
/** @var int DOS File Attribute Directory */
public const DOS_DIRECTORY = 0x10;
/** @var int DOS File Attribute Archive */
public const DOS_ARCHIVE = 0x20;
/** @var int DOS File Attribute Link */
public const DOS_LINK = 0x40;
/** @var int DOS File Attribute Execute */
public const DOS_EXE = 0x80;
}

View File

@ -0,0 +1,103 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
final class DosCodePage
{
public const CP_LATIN_US = 'cp437';
public const CP_GREEK = 'cp737';
public const CP_BALT_RIM = 'cp775';
public const CP_LATIN1 = 'cp850';
public const CP_LATIN2 = 'cp852';
public const CP_CYRILLIC = 'cp855';
public const CP_TURKISH = 'cp857';
public const CP_PORTUGUESE = 'cp860';
public const CP_ICELANDIC = 'cp861';
public const CP_HEBREW = 'cp862';
public const CP_CANADA = 'cp863';
public const CP_ARABIC = 'cp864';
public const CP_NORDIC = 'cp865';
public const CP_CYRILLIC_RUSSIAN = 'cp866';
public const CP_GREEK2 = 'cp869';
public const CP_THAI = 'cp874';
/** @var string[] */
private const CP_CHARSETS = [
self::CP_LATIN_US,
self::CP_GREEK,
self::CP_BALT_RIM,
self::CP_LATIN1,
self::CP_LATIN2,
self::CP_CYRILLIC,
self::CP_TURKISH,
self::CP_PORTUGUESE,
self::CP_ICELANDIC,
self::CP_HEBREW,
self::CP_CANADA,
self::CP_ARABIC,
self::CP_NORDIC,
self::CP_CYRILLIC_RUSSIAN,
self::CP_GREEK2,
self::CP_THAI,
];
/**
* @noinspection PhpComposerExtensionStubsInspection
*/
public static function toUTF8(string $str, string $sourceEncoding): string
{
$s = iconv($sourceEncoding, 'UTF-8', $str);
if ($s === false) {
return $str;
}
return $s;
}
/**
* @noinspection PhpComposerExtensionStubsInspection
*/
public static function fromUTF8(string $str, string $destEncoding): string
{
$s = iconv('UTF-8', $destEncoding, $str);
if ($s === false) {
return $str;
}
return $s;
}
/**
* @return string[]
*/
public static function getCodePages(): array
{
return self::CP_CHARSETS;
}
}

View File

@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
interface GeneralPurposeBitFlag
{
/**
* General Purpose Bit Flag mask for encrypted data.
* Bit 0: If set, indicates that the file is encrypted.
*/
public const ENCRYPTION = 1 << 0;
/**
* Compression Flag Bit 1 for method Deflating.
*
* Bit 2 Bit 1
* 0 0 Normal compression
* 0 1 Maximum compression
* 1 0 Fast compression
* 1 1 Super Fast compression
*
* @see GeneralPurposeBitFlag::COMPRESSION_FLAG2
*/
public const COMPRESSION_FLAG1 = 1 << 1;
/**
* Compression Flag Bit 2 for method Deflating.
*
* Bit 2 Bit 1
* 0 0 Normal compression
* 0 1 Maximum compression
* 1 0 Fast compression
* 1 1 Super Fast compression
*
* @see GeneralPurposeBitFlag::COMPRESSION_FLAG1
*/
public const COMPRESSION_FLAG2 = 1 << 2;
/**
* General Purpose Bit Flag mask for data descriptor.
*
* Bit 3: If this bit is set, the fields crc-32, compressed
* size and uncompressed size are set to zero in the
* local header. The correct values are put in the data
* descriptor immediately following the compressed data.
*/
public const DATA_DESCRIPTOR = 1 << 3;
/**
* General Purpose Bit Flag mask for strong encryption.
*
* Bit 6: Strong encryption.
* If this bit is set, you MUST set the version needed to extract
* value to at least 50 and you MUST also set bit 0.
* If AES encryption is used, the version needed to extract value
* MUST be at least 51.
*/
public const STRONG_ENCRYPTION = 1 << 6;
/**
* General Purpose Bit Flag mask for UTF-8.
*
* Bit 11: Language encoding flag (EFS).
* If this bit is set, the filename and comment fields
* for this file MUST be encoded using UTF-8. (see APPENDIX D)
*/
public const UTF8 = 1 << 11;
}

View File

@ -0,0 +1,90 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
/**
* Unix stat constants.
*/
interface UnixStat
{
/** @var int unix file type mask */
public const UNX_IFMT = 0170000;
/** @var int unix regular file */
public const UNX_IFREG = 0100000;
/** @var int unix socket (BSD, not SysV or Amiga) */
public const UNX_IFSOCK = 0140000;
/** @var int unix symbolic link (not SysV, Amiga) */
public const UNX_IFLNK = 0120000;
/** @var int unix block special (not Amiga) */
public const UNX_IFBLK = 0060000;
/** @var int unix directory */
public const UNX_IFDIR = 0040000;
/** @var int unix character special (not Amiga) */
public const UNX_IFCHR = 0020000;
/** @var int unix fifo (BCC, not MSC or Amiga) */
public const UNX_IFIFO = 0010000;
/** @var int unix set user id on execution */
public const UNX_ISUID = 04000;
/** @var int unix set group id on execution */
public const UNX_ISGID = 02000;
/** @var int unix directory permissions control */
public const UNX_ISVTX = 01000;
/** @var int unix record locking enforcement flag */
public const UNX_ENFMT = 02000;
/** @var int unix read, write, execute: owner */
public const UNX_IRWXU = 00700;
/** @var int unix read permission: owner */
public const UNX_IRUSR = 00400;
/** @var int unix write permission: owner */
public const UNX_IWUSR = 00200;
/** @var int unix execute permission: owner */
public const UNX_IXUSR = 00100;
/** @var int unix read, write, execute: group */
public const UNX_IRWXG = 00070;
/** @var int unix read permission: group */
public const UNX_IRGRP = 00040;
/** @var int unix write permission: group */
public const UNX_IWGRP = 00020;
/** @var int unix execute permission: group */
public const UNX_IXGRP = 00010;
/** @var int unix read, write, execute: other */
public const UNX_IRWXO = 00007;
/** @var int unix read permission: other */
public const UNX_IROTH = 00004;
/** @var int unix write permission: other */
public const UNX_IWOTH = 00002;
/** @var int unix execute permission: other */
public const UNX_IXOTH = 00001;
}

View File

@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
/**
* Compression levels for Deflate and BZIP2.
*
* {@see https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT} Section 4.4.4:
*
* For Methods 8 and 9 - Deflating
* -------------------------------
* Bit 2 Bit 1
* 0 0 Normal (-en) compression option was used.
* 0 1 Maximum (-exx/-ex) compression option was used.
* 1 0 Fast (-ef) compression option was used.
* 1 1 Super Fast (-es) compression option was used.
*
* Different programs encode compression level information in different ways:
*
* Deflate Compress Level pkzip zip 7z, WinRAR WinZip
* ---------------------- ---------------- ------- ---------- ------
* Super Fast compression 1 1
* Fast compression 2 1, 2
* Normal Compression 3 - 8 (5 default) 3 - 7 1 - 9
* Maximum compression 9 8, 9 9
*/
interface ZipCompressionLevel
{
/** @var int Compression level for super fast compression. */
public const SUPER_FAST = 1;
/** @var int compression level for fast compression */
public const FAST = 2;
/** @var int compression level for normal compression */
public const NORMAL = 5;
/** @var int compression level for maximum compression */
public const MAXIMUM = 9;
/**
* @var int int Minimum compression level
*
* @internal
*/
public const LEVEL_MIN = self::SUPER_FAST;
/**
* @var int int Maximum compression level
*
* @internal
*/
public const LEVEL_MAX = self::MAXIMUM;
}

View File

@ -0,0 +1,97 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
use PhpZip\Exception\ZipUnsupportMethodException;
final class ZipCompressionMethod
{
/** @var int Compression method Store */
public const STORED = 0;
/** @var int Compression method Deflate */
public const DEFLATED = 8;
/** @var int Compression method Bzip2 */
public const BZIP2 = 12;
/** @var int Compression method AES-Encryption */
public const WINZIP_AES = 99;
/** @var array Compression Methods */
private const ZIP_COMPRESSION_METHODS = [
self::STORED => 'Stored',
1 => 'Shrunk',
2 => 'Reduced compression factor 1',
3 => 'Reduced compression factor 2',
4 => 'Reduced compression factor 3',
5 => 'Reduced compression factor 4',
6 => 'Imploded',
7 => 'Reserved for Tokenizing compression algorithm',
self::DEFLATED => 'Deflated',
9 => 'Enhanced Deflating using Deflate64(tm)',
10 => 'PKWARE Data Compression Library Imploding',
11 => 'Reserved by PKWARE',
self::BZIP2 => 'BZIP2',
13 => 'Reserved by PKWARE',
14 => 'LZMA',
15 => 'Reserved by PKWARE',
16 => 'Reserved by PKWARE',
17 => 'Reserved by PKWARE',
18 => 'File is compressed using IBM TERSE (new)',
19 => 'IBM LZ77 z Architecture (PFS)',
96 => 'WinZip JPEG Compression',
97 => 'WavPack compressed data',
98 => 'PPMd version I, Rev 1',
self::WINZIP_AES => 'AES Encryption',
];
public static function getCompressionMethodName(int $value): string
{
return self::ZIP_COMPRESSION_METHODS[$value] ?? 'Unknown Method';
}
/**
* @return int[]
*/
public static function getSupportMethods(): array
{
static $methods;
if ($methods === null) {
$methods = [
self::STORED,
self::DEFLATED,
];
if (\extension_loaded('bz2')) {
$methods[] = self::BZIP2;
}
}
return $methods;
}
/**
* @throws ZipUnsupportMethodException
*/
public static function checkSupport(int $compressionMethod): void
{
if (!\in_array($compressionMethod, self::getSupportMethods(), true)) {
throw new ZipUnsupportMethodException(sprintf(
'Compression method %d (%s) is not supported.',
$compressionMethod,
self::getCompressionMethodName($compressionMethod)
));
}
}
}

View File

@ -0,0 +1,105 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
/**
* Zip Constants.
*/
interface ZipConstants
{
/** @var int End Of Central Directory Record signature. */
public const END_CD = 0x06054B50; // "PK\005\006"
/** @var int Zip64 End Of Central Directory Record. */
public const ZIP64_END_CD = 0x06064B50; // "PK\006\006"
/** @var int Zip64 End Of Central Directory Locator. */
public const ZIP64_END_CD_LOC = 0x07064B50; // "PK\006\007"
/** @var int Central File Header signature. */
public const CENTRAL_FILE_HEADER = 0x02014B50; // "PK\001\002"
/** @var int Local File Header signature. */
public const LOCAL_FILE_HEADER = 0x04034B50; // "PK\003\004"
/** @var int Data Descriptor signature. */
public const DATA_DESCRIPTOR = 0x08074B50; // "PK\007\008"
/**
* @var int value stored in four-byte size and similar fields
* if ZIP64 extensions are used
*/
public const ZIP64_MAGIC = 0xFFFFFFFF;
/**
* Local File Header signature 4
* Version Needed To Extract 2
* General Purpose Bit Flags 2
* Compression Method 2
* Last Mod File Time 2
* Last Mod File Date 2
* CRC-32 4
* Compressed Size 4
* Uncompressed Size 4.
*
* @var int Local File Header filename position
*/
public const LFH_FILENAME_LENGTH_POS = 26;
/**
* The minimum length of the Local File Header record.
*
* local file header signature 4
* version needed to extract 2
* general purpose bit flag 2
* compression method 2
* last mod file time 2
* last mod file date 2
* crc-32 4
* compressed size 4
* uncompressed size 4
* file name length 2
* extra field length 2
*/
public const LFH_FILENAME_POS = 30;
/** @var int the length of the Zip64 End Of Central Directory Locator */
public const ZIP64_END_CD_LOC_LEN = 20;
/** @var int the minimum length of the End Of Central Directory Record */
public const END_CD_MIN_LEN = 22;
/**
* The minimum length of the Zip64 End Of Central Directory Record.
*
* zip64 end of central dir
* signature 4
* size of zip64 end of central
* directory record 8
* version made by 2
* version needed to extract 2
* number of this disk 4
* number of the disk with the
* start of the central directory 4
* total number of entries in the
* central directory on this disk 8
* total number of entries in
* the central directory 8
* size of the central directory 8
* offset of start of central
* directory with respect to
* the starting disk number 8
*
* @var int ZIP64 End Of Central Directory length
*/
public const ZIP64_END_OF_CD_LEN = 56;
}

View File

@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
use PhpZip\Exception\InvalidArgumentException;
final class ZipEncryptionMethod
{
public const NONE = -1;
/** @var int Traditional PKWARE encryption. */
public const PKWARE = 0;
/** @var int WinZip AES-256 */
public const WINZIP_AES_256 = 1;
/** @var int WinZip AES-128 */
public const WINZIP_AES_128 = 2;
/** @var int WinZip AES-192 */
public const WINZIP_AES_192 = 3;
/** @var array<int, string> */
private const ENCRYPTION_METHODS = [
self::NONE => 'no encryption',
self::PKWARE => 'Traditional PKWARE encryption',
self::WINZIP_AES_128 => 'WinZip AES-128',
self::WINZIP_AES_192 => 'WinZip AES-192',
self::WINZIP_AES_256 => 'WinZip AES-256',
];
public static function getEncryptionMethodName(int $value): string
{
return self::ENCRYPTION_METHODS[$value] ?? 'Unknown Encryption Method';
}
public static function hasEncryptionMethod(int $encryptionMethod): bool
{
return isset(self::ENCRYPTION_METHODS[$encryptionMethod]);
}
public static function isWinZipAesMethod(int $encryptionMethod): bool
{
return \in_array(
$encryptionMethod,
[
self::WINZIP_AES_256,
self::WINZIP_AES_192,
self::WINZIP_AES_128,
],
true
);
}
/**
* @throws InvalidArgumentException
*/
public static function checkSupport(int $encryptionMethod): void
{
if (!self::hasEncryptionMethod($encryptionMethod)) {
throw new InvalidArgumentException(sprintf(
'Encryption method %d is not supported.',
$encryptionMethod
));
}
}
}

View File

@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
use PhpZip\IO\ZipReader;
use PhpZip\ZipFile;
interface ZipOptions
{
/**
* Boolean option for store just file names (skip directory names).
*
* @see ZipFile::addFromFinder()
*/
public const STORE_ONLY_FILES = 'only_files';
/**
* Uses the specified compression method.
*
* @see ZipFile::addFromFinder()
* @see ZipFile::addSplFile()
*/
public const COMPRESSION_METHOD = 'compression_method';
/**
* Set the specified record modification time.
* The value can be {@see \DateTimeInterface}, integer timestamp
* or a string of any format.
*
* @see ZipFile::addFromFinder()
* @see ZipFile::addSplFile()
*/
public const MODIFIED_TIME = 'mtime';
/**
* Specifies the encoding of the record name for cases when the UTF-8
* usage flag is not set.
*
* The most commonly used encodings are compiled into the constants
* of the {@see DosCodePage} class.
*
* @see ZipFile::openFile()
* @see ZipFile::openFromString()
* @see ZipFile::openFromStream()
* @see ZipReader::getDefaultOptions()
* @see DosCodePage::getCodePages()
*/
public const CHARSET = 'charset';
/**
* Allows ({@see true}) or denies ({@see false}) unpacking unix symlinks.
*
* This is a potentially dangerous operation for uncontrolled zip files.
* By default is ({@see false}).
*
* @see https://josipfranjkovic.blogspot.com/2014/12/reading-local-files-from-facebooks.html
*/
public const EXTRACT_SYMLINKS = 'extract_symlinks';
}

View File

@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
final class ZipPlatform
{
/** @var int MS-DOS OS */
public const OS_DOS = 0;
/** @var int Unix OS */
public const OS_UNIX = 3;
/** @var int MacOS platform */
public const OS_MAC_OSX = 19;
/** @var array Zip Platforms */
private const PLATFORMS = [
self::OS_DOS => 'MS-DOS',
1 => 'Amiga',
2 => 'OpenVMS',
self::OS_UNIX => 'Unix',
4 => 'VM/CMS',
5 => 'Atari ST',
6 => 'HPFS (OS/2, NT 3.x)',
7 => 'Macintosh',
8 => 'Z-System',
9 => 'CP/M',
10 => 'Windows NTFS or TOPS-20',
11 => 'MVS or NTFS',
12 => 'VSE or SMS/QDOS',
13 => 'Acorn RISC OS',
14 => 'VFAT',
15 => 'alternate MVS',
16 => 'BeOS',
17 => 'Tandem',
18 => 'OS/400',
self::OS_MAC_OSX => 'OS/X (Darwin)',
30 => 'AtheOS/Syllable',
];
public static function getPlatformName(int $platform): string
{
return self::PLATFORMS[$platform] ?? 'Unknown';
}
}

View File

@ -0,0 +1,87 @@
<?php
declare(strict_types=1);
/*
* This file is part of the nelexa/zip package.
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpZip\Constants;
/**
* Version needed to extract or software version.
*
* @see https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT Section 4.4.3
*/
interface ZipVersion
{
/** @var int 1.0 - Default value */
public const v10_DEFAULT_MIN = 10;
/** @var int 1.1 - File is a volume label */
public const v11_FILE_VOLUME_LABEL = 11;
/**
* 2.0 - File is a folder (directory)
* 2.0 - File is compressed using Deflate compression
* 2.0 - File is encrypted using traditional PKWARE encryption.
*
* @var int
*/
public const v20_DEFLATED_FOLDER_ZIPCRYPTO = 20;
/** @var int 2.1 - File is compressed using Deflate64(tm) */
public const v21_DEFLATED64 = 21;
/** @var int 2.5 - File is compressed using PKWARE DCL Implode */
public const v25_IMPLODED = 25;
/** @var int 2.7 - File is a patch data set */
public const v27_PATCH_DATA = 27;
/** @var int 4.5 - File uses ZIP64 format extensions */
public const v45_ZIP64_EXT = 45;
/** @var int 4.6 - File is compressed using BZIP2 compression */
public const v46_BZIP2 = 46;
/**
* 5.0 - File is encrypted using DES
* 5.0 - File is encrypted using 3DES
* 5.0 - File is encrypted using original RC2 encryption
* 5.0 - File is encrypted using RC4 encryption.
*
* @var int
*/
public const v50_ENCR_DES_3DES_RC2_ORIG_RC4 = 50;
/**
* 5.1 - File is encrypted using AES encryption
* 5.1 - File is encrypted using corrected RC2 encryption**.
*
* @var int
*/
public const v51_ENCR_AES_RC2_CORRECT = 51;
/** @var int 5.2 - File is encrypted using corrected RC2-64 encryption** */
public const v52_ENCR_RC2_64_CORRECT = 52;
/** @var int 6.1 - File is encrypted using non-OAEP key wrapping*** */
public const v61_ENCR_NON_OAE_KEY_WRAP = 61;
/** @var int 6.2 - Central directory encryption */
public const v62_ENCR_CENTRAL_DIR = 62;
/**
* 6.3 - File is compressed using LZMA
* 6.3 - File is compressed using PPMd+
* 6.3 - File is encrypted using Blowfish
* 6.3 - File is encrypted using Twofish.
*
* @var int
*/
public const v63_LZMA_PPMD_BLOWFISH_TWOFISH = 63;
}

Some files were not shown because too many files have changed in this diff Show More