|
@@ -5,6 +5,7 @@ namespace app\admin\controller\medical;
|
|
|
use app\admin\validate\medical\ShopValidate;
|
|
|
use app\controller\Curd;
|
|
|
use app\model\MedicalShop;
|
|
|
+use support\exception\BusinessException;
|
|
|
use support\Request;
|
|
|
use support\Response;
|
|
|
|
|
@@ -36,6 +37,64 @@ class ShopController extends Curd
|
|
|
return $this->doFormat($query, $format, $limit);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Desc 插入数据处理
|
|
|
+ * @Author Gorden
|
|
|
+ * @Date 2024/3/19 13:37
|
|
|
+ *
|
|
|
+ * @param Request $request
|
|
|
+ * @return array
|
|
|
+ * @throws \support\exception\BusinessException
|
|
|
+ */
|
|
|
+ protected function insertInput(Request $request): array
|
|
|
+ {
|
|
|
+ $data = $this->inputFilter($request->post());
|
|
|
+
|
|
|
+ $data['shop_logo'] = str_replace(getenv("STORAGE_DOMAIN"), '', $data['shop_logo']);
|
|
|
+ if ($data['shop_business_hours']){
|
|
|
+ $shopBusinessHoursStart = date('H:i', strtotime(explode(',', $data['shop_business_hours'])[0]));
|
|
|
+ $shopBusinessHoursEnd = date('H:i', strtotime(explode(',', $data['shop_business_hours'])[1]));
|
|
|
+ $data['shop_business_hours'] = $shopBusinessHoursStart . '~' . $shopBusinessHoursEnd;
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function updateInput(Request $request): array
|
|
|
+ {
|
|
|
+ $primary_key = $this->model->getKeyName();
|
|
|
+ $id = $request->post($primary_key);
|
|
|
+ $data = $this->inputFilter($request->post());
|
|
|
+ $model = $this->model->find($id);
|
|
|
+ if (!$model) {
|
|
|
+ throw new BusinessException('记录不存在', 2);
|
|
|
+ }
|
|
|
+ unset($data[$primary_key]);
|
|
|
+ // 头像
|
|
|
+ $data['shop_logo'] = str_replace(getenv("STORAGE_DOMAIN"), '', $data['shop_logo']);
|
|
|
+ if ($data['shop_business_hours']){
|
|
|
+ $shopBusinessHoursStart = date('H:i', strtotime(explode(',', $data['shop_business_hours'])[0]));
|
|
|
+ $shopBusinessHoursEnd = date('H:i', strtotime(explode(',', $data['shop_business_hours'])[1]));
|
|
|
+ $data['shop_business_hours'] = $shopBusinessHoursStart . '~' . $shopBusinessHoursEnd;
|
|
|
+ }
|
|
|
+
|
|
|
+ return [$id, $data];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function afterQuery($items)
|
|
|
+ {
|
|
|
+ foreach ($items as &$item) {
|
|
|
+ $item->shop_logo = getenv('STORAGE_DOMAIN').$item->shop_logo;
|
|
|
+ $shopBusinessHoursArr = explode('~', $item->shop_business_hours);
|
|
|
+ foreach ($shopBusinessHoursArr as $key => $v){
|
|
|
+ $shopBusinessHoursArr[$key] = date("Y-m-d\TH:i:s\Z",strtotime(date('Y-m-d ').$v)-8*3600);
|
|
|
+ }
|
|
|
+ $item->shop_business_hours = $shopBusinessHoursArr;
|
|
|
+ $item->shop_label = !empty($item->shop_label) ? explode(',',$item->shop_label) : [];
|
|
|
+ }
|
|
|
+ return $items;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Desc 删除
|
|
|
* @Author Gorden
|