| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- /**
- * @package merchant
- * Author: Qinii
- * Date: 2020/5/6
- * Time: 14:21
- */
- namespace app\common\dao\store\shipping;
- use app\entity\data\shipping\ShippingTemplateRegionEntity;
- use think\facade\Db;
- use app\common\dao\BaseDao;
- use app\common\model\store\shipping\ShippingTemplateRegion as model;
- class ShippingTemplateRegionDao extends BaseDao
- {
- /**
- * @Author:Qinii
- * @Date: 2020/5/8
- * @return string
- */
- protected function getModel(): string
- {
- return model::class;
- }
- /**
- * @Author:Qinii
- * @Date: 2020/5/8
- * @param $field
- * @param $value
- * @param null $except
- * @return bool
- */
- public function merFieldExists($field, $value, $except = null)
- {
- return ($this->getModel())::getDB()->when($except, function ($query, $except) use ($field) {
- $query->where($field, '<>', $except);
- })->where($field, $value)->count() > 0;
- }
- /**
- * 批量删除
- * @Author:Qinii
- * @Date: 2020/5/8
- * @param array $id
- * @param array $temp_id
- */
- public function batchRemove(array $id,array $temp_id)
- {
- if($id)
- ($this->getModel())::getDB()->where($this->getPk(),'in',$id)->delete();
- if($temp_id)
- ($this->getModel())::getDB()->where('temp_id','in',$temp_id)->delete();
- }
- /**
- * @Author:Qinii
- * @Date: 2020/5/13
- * @param array $data
- * @return mixed
- */
- public function insertAll(array $data)
- {
- return ($this->getModel()::getDB())->insertAll($data);
- }
- /**
- * @param int $tempId
- * @return ShippingTemplateRegionEntity[]
- */
- public function getShippingTemplateRegionEntityListByTempId(int $tempId): array
- {
- $entityList = [];
- try {
- /** @var model $model */
- $model = $this->getModel();
- $dataListRes = $model::getDB()
- ->where('temp_id', '=', $tempId)
- ->order('shipping_template_region_id DESC')
- ->select()
- ->toArray();
- if (!empty($dataListRes)) {
- foreach ($dataListRes as $data) {
- $entityList[] = ShippingTemplateRegionEntity::newInstance($data);
- }
- }
- } catch (\Exception $e) {
- }
- return $entityList;
- }
- }
|