Преглед изворни кода

地址判断不能重复添加相同地址

evoxwht пре 4 година
родитељ
комит
ea03b1fc43
1 измењених фајлова са 15 додато и 0 уклоњено
  1. 15 0
      crmeb/app/services/user/UserAddressServices.php

+ 15 - 0
crmeb/app/services/user/UserAddressServices.php

@@ -164,6 +164,21 @@ class UserAddressServices extends BaseServices
      */
      */
     public function editAddress(int $uid, array $addressInfo)
     public function editAddress(int $uid, array $addressInfo)
     {
     {
+        if ($addressInfo['id'] == 0) {
+            if (isset($addressInfo['address']['city_id'])) {
+                $where['city_id'] = $addressInfo['address']['city_id'];
+            } else {
+                $where = [];
+            }
+            $res = $this->dao->getCount([
+                    ['uid', '=', $uid],
+                    ['real_name', '=', $addressInfo['real_name']],
+                    ['phone', '=', $addressInfo['phone']],
+                    ['detail', '=', $addressInfo['detail']]
+                ] + $where);
+            if ($res) throw new ValidateException('地址已存在,请勿重复添加');
+        }
+
         if ($addressInfo['type'] == 1 && !$addressInfo['id']) {
         if ($addressInfo['type'] == 1 && !$addressInfo['id']) {
             $city = $addressInfo['address']['city'];
             $city = $addressInfo['address']['city'];
             /** @var SystemCityServices $systemCity */
             /** @var SystemCityServices $systemCity */