Commit 35f2a74c07537ed3f5bf7007c3cf908beaccfc56
1 parent
407413ee
Exists in
master
1.查看商品信息物理返回到扫码验证首页。
2.去除多余代码。 3.用户地址缓存BUG修复。
Showing
4 changed files
with
21 additions
and
73 deletions
Show diff stats
app-wx/modules/smart/controllers/DefaultController.php
... | ... | @@ -5,7 +5,6 @@ namespace app\wx\modules\smart\controllers; |
5 | 5 | use Yii; |
6 | 6 | use common\helpers\CheckActiveHelper; |
7 | 7 | use common\helpers\ImageManager; |
8 | -use common\helpers\ImageUtils; | |
9 | 8 | use common\helpers\WxHelper; |
10 | 9 | use domain\smart\ScanRecords; |
11 | 10 | use domain\system\message\SmsMessage; |
... | ... | @@ -19,7 +18,6 @@ use stdClass; |
19 | 18 | */ |
20 | 19 | class DefaultController extends BaseController |
21 | 20 | { |
22 | - const CHANGE_PHONE_TIMES = 3; | |
23 | 21 | /** |
24 | 22 | * 账号设置 |
25 | 23 | */ |
... | ... | @@ -29,54 +27,6 @@ class DefaultController extends BaseController |
29 | 27 | } |
30 | 28 | |
31 | 29 | /** |
32 | - * @return string | |
33 | - */ | |
34 | - public function actionUploadImg() | |
35 | - { | |
36 | - $e = new stdClass(); | |
37 | - $e->success = false; | |
38 | - $e->message = 'ok'; | |
39 | - $engineerId = $this->getUserId(); | |
40 | - | |
41 | - if (empty($_FILES["file"])) { | |
42 | - $e->message = '文件为空'; | |
43 | - return $this->renderJson($e); | |
44 | - } | |
45 | - if (empty($_FILES["file"]['tmp_name'])) { | |
46 | - $e->message = '文件为空'; | |
47 | - return $this->renderJson($e); | |
48 | - } | |
49 | - $type = $_FILES["file"]["type"]; | |
50 | - $typeArr = explode('/', $type); | |
51 | - if ('image' !== $typeArr[0]) { | |
52 | - $e->message = '只能上传 png, jpg 等文件'; | |
53 | - return $this->renderJson($e); | |
54 | - } | |
55 | - | |
56 | - $dir = Yii::getAlias('@app/wx') . "/web/tmp"; | |
57 | - $fileArr = explode('.', $_FILES["file"]['name']); | |
58 | - $tt = time(); | |
59 | - $filename = 'smart_'.$tt.md5($_FILES["file"]['name']).'.'.end($fileArr); | |
60 | - $minFileName = 'smart_'.$tt.md5($_FILES["file"]['name']).'_min'.'.'.end($fileArr); | |
61 | - $saveFilePath = $dir.'/'.$filename; | |
62 | - move_uploaded_file($_FILES["file"]['tmp_name'], $saveFilePath); | |
63 | - $tmpUrl = $tmpMinFile= $this->site->base_url.'/tmp/'.$filename; | |
64 | - $imgSource = $this->_imageCreateFromPath($saveFilePath); | |
65 | - if ($imgSource) { | |
66 | - ImageUtils::resizeImage($imgSource, 100, 100, $dir.'/'.$minFileName); | |
67 | - $tmpMinFile = $this->site->base_url.'/tmp/'.$minFileName; | |
68 | - } | |
69 | - | |
70 | - $e->success = true; | |
71 | - $e->tmpFile = $filename; | |
72 | - $e->tmpMinUrl = $tmpMinFile; | |
73 | - $e->tmpUrl = $tmpUrl; | |
74 | - $e->message = 'ok'; | |
75 | - | |
76 | - return $this->renderJson($e); | |
77 | - } | |
78 | - | |
79 | - /** | |
80 | 30 | * 提交激活 - (enter-controller.js提交激活页面用到) |
81 | 31 | */ |
82 | 32 | public function actionSubmit() |
... | ... | @@ -98,7 +48,7 @@ class DefaultController extends BaseController |
98 | 48 | } |
99 | 49 | |
100 | 50 | if (empty($fileData) || empty($address) || empty($content) || empty($phone) || empty($uuid)) { |
101 | - $e->msg = '保存失败缺少不要参数'; | |
51 | + $e->msg = '保存失败缺少必要参数'; | |
102 | 52 | return $this->renderJson($e); |
103 | 53 | } |
104 | 54 | $productImagePath = ""; |
... | ... | @@ -312,21 +262,4 @@ class DefaultController extends BaseController |
312 | 262 | return $this->renderJson($e); |
313 | 263 | |
314 | 264 | } |
315 | - | |
316 | - /** | |
317 | - * @param $imgPath | |
318 | - * @return null|resource | |
319 | - */ | |
320 | - private function _imageCreateFromPath($imgPath) | |
321 | - { | |
322 | - list($width, $height, $type, $attr) = getimagesize($imgPath); | |
323 | - switch ($type) { | |
324 | - case 3: // png | |
325 | - return imagecreatefrompng($imgPath); | |
326 | - case 2: // jpeg | |
327 | - return imagecreatefromjpeg($imgPath); | |
328 | - default: | |
329 | - return null; | |
330 | - } | |
331 | - } | |
332 | 265 | } |
333 | 266 | \ No newline at end of file | ... | ... |
app-wx/web/dist/js/check-app.js
1 | -define("check-app",["mk7/app"],function(n){var e=Dom7,t=function(){var n=e(".ui-loading-block");0==n.length&&(e(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var n=document.getElementById("loader-inner"),e=document.createElement("p");e.className="notice",n&&(e.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',n.appendChild(e))},window.waitingTime))},o=!0;return n.name="check",n.routes={index:function(){return o=!1,t(),n.runController("index")},"*":function(){return o=!1,t(),n.runController("index")},"scan-count/:uuid/:scancount":function(e,i){return o=!1,t(),n.runController("scan-count",{uuid:e,scancount:i})},"warning/:uuid":function(e){return o=!1,t(),n.runController("warning",{uuid:e})},"submit/:uuid":function(e){return o=!1,t(),n.runController("submit",{uuid:e})},"error/:uuid":function(e){return o=!1,t(),n.runController("error",{uuid:e})},"success/:uuid":function(e){return o=!1,t(),n.runController("success",{uuid:e})},"info/:uuid/:number_code":function(e,i){return o=!1,t(),n.runController("info",{uuid:e,number_code:i})}},n}),define("check/error-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7;Template7;return n.run=function(){var n=this;n.setPageTitle("验证结果"),n.render()},n.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)})},n}),define("check/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7,r=(Template7,1),a=0,u=2,s=0;return n.run=function(){var n=this;n.setPageTitle("验证标签"),i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["openLocation","getLocation","scanQRCode"]}),n.scanQrcode(),n.render(),c(".scan-button").attr("disabled","disabled"),c(".scan-button").text("正在调起扫码……")},n.bindEvents=function(){var n=this;c(".scan-button").click(function(){n.scanQrcode()})},n.scanQrcode=function(){var n=this;i.ready(function(){i.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(o){var i=o.resultStr,d=c.parseUrlQuery(i);if(null!=d&&void 0!==d&&null!=d.uuid&&void 0!==d.uuid){if(d.uuid.indexOf("@")==-1)return t.toast({content:"该智能防伪二维码无效"}),!1;var d=d.uuid.split("@"),l=e.to("smart#enter/"+d[0]),m=e.to("check#scan-count/"+d[0]+"/"+s),f=e.to("check#warning/"+d[0]);c.ajax({method:"POST",url:e.to("check/default/check-active"),data:{uuid:d[0]},dataType:"json",beforeSend:function(){n.showIndicator()},success:function(n){s=n.scan_count,m=e.to("check#scan-count/"+d[0]+"/"+s),n.success==r?window.location.href=m:n.success==a?window.location.href=l:n.success==u?window.location.href=f:window.location.href=f},error:function(n){},complete:function(e){n.hideIndicator()}})}else t.toast({content:"请扫描智能防伪二维码"})}}),setTimeout(function(){c(".scan-button").removeAttr("disabled"),c(".scan-button").text("点击扫描标签")},1e3)})},n}),define("check/info-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7;Template7;return n.run=function(){var n=this;n.setPageTitle("隐私信息"),n.loadData(n.params.uuid,n.params.number_code)},n.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)})},n.loadData=function(n,o){var i=this;c.ajax({method:"POST",url:e.to("check/default/get-info"),data:{uuid:n,number_code:o},dataType:"json",beforeSend:function(){i.showIndicator()},success:function(n){try{n.success?i.render(n.data):t.toast({content:n.message,closeDelay:3e3})}catch(e){t.toast({content:"出错",closeDelay:3e3})}},error:function(n){t.toast({content:"提交出错,请联系系统管理员"})},complete:function(n){i.hideIndicator()}})},n}),define("check/scan-count-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7,r=(Template7,0),a="";return n.run=function(){var n=this;r=parseInt(n.params.scancount),a=n.params.uuid,n.setPageTitle("验证标签"),n.render(),c(".count-num").html(r)},n.bindEvents=function(){c(".scan-button").click(function(){""!=a&&void 0!=a?window.location.href=e.to("check#submit/"+a):window.location.href=e.to("check#index")})},n}),define("check/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7,r=(Template7,"");return n.run=function(){var n=this;r=n.params.uuid,n.setPageTitle("验证标签"),i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["chooseImage","previewImage","uploadImage","getLocalImgData"]}),n.render()},n.bindEvents=function(){var n=this;c(".scan-image").click(function(){n.uploadImg(c(this))}),c(".scan-button").click(function(){var o=c(".scan-image").attr("data");return t.isEmpty(o)?(t.toast({content:"请拍照文件上传后再试!"}),!1):void c.ajax({method:"POST",url:e.to("check/default/check-actived"),data:{upload_file:o,uuid:r},dataType:"json",beforeSend:function(){n.showIndicator()},success:function(n){try{n.success?window.location.href=e.to("check#success/"+r):window.location.href=e.to("check#error/"+r)}catch(o){t.toast({content:"出错",closeDelay:3e3})}},error:function(n){t.toast({content:"提交出错,请联系系统管理员"})},complete:function(e){n.hideIndicator()}})})},n.uploadImg=function(n){var e=this;i.ready(function(){i.chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(t){t.localIds.length>0&&e.upload(t.localIds,n)}})})},n.upload=function(n,o){var a=this;return void 0==n[0]?"":void i.uploadImage({localId:n[0],isShowProgressTips:1,success:function(n){c.ajax({method:"POST",url:e.to("check/default/update-serviceid"),data:{service_id:n.serverId,uuid:r},dataType:"json",beforeSend:function(){a.showIndicator()},success:function(n){try{if(n.success){var e=n.img_path;o.attr("data",e),o.attr("src",n.show_path)}else t.toast({content:n.message,closeDelay:3e3})}catch(i){t.toast({content:"出错",closeDelay:3e3})}},error:function(n){t.toast({content:"提交出错,请联系系统管理员"})},complete:function(n){a.hideIndicator()}})},fail:function(n){a.app.alert(JSON.stringify(n))}})},n}),define("check/success-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7,r=(Template7,"");return n.run=function(){var n=this;r=n.params.uuid,n.setPageTitle("验证结果"),n.render()},n.bindEvents=function(){var n=this;c(".btn-submit").click(function(){var o=c(".input-num").val();return t.isEmpty(o)?(t.toast({content:"请填写提取码"}),c(".input-num").focus(),!1):t.isEmpty(r)?(t.toast({content:"缺少必要参数请退出重试"}),!1):void c.ajax({method:"POST",url:e.to("check/default/get-info"),data:{uuid:r,number_code:o},dataType:"json",beforeSend:function(){n.showIndicator()},success:function(n){try{n.success?window.location.href=e.to("check#info/"+r+"/"+o):t.toast({content:n.message,closeDelay:3e3})}catch(i){t.toast({content:"出错",closeDelay:3e3})}},error:function(n){t.toast({content:"提交出错,请联系系统管理员"})},complete:function(e){n.hideIndicator()}})})},n}),define("check/warning-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7,r=(Template7,"");return n.run=function(){var n=this;r=n.params.uuid,n.setPageTitle("验证标签"),n.render()},n.bindEvents=function(){c(".scan-jump-button").click(function(){""!=r&&void 0!=r?window.location.href=e.to("smart#enter/"+r):window.location.href=e.to("check#index")})},n}); | |
2 | 1 | \ No newline at end of file |
2 | +define("check-app",["mk7/app"],function(n){var t=Dom7,e=function(){var n=t(".ui-loading-block");0==n.length&&(t(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var n=document.getElementById("loader-inner"),t=document.createElement("p");t.className="notice",n&&(t.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',n.appendChild(t))},window.waitingTime))},o=!0;return n.name="check",n.routes={index:function(){return o=!1,e(),n.runController("index")},"*":function(){return o=!1,e(),n.runController("index")},"scan-count/:uuid/:scancount":function(t,i){return o=!1,e(),n.runController("scan-count",{uuid:t,scancount:i})},"warning/:uuid":function(t){return o=!1,e(),n.runController("warning",{uuid:t})},"submit/:uuid":function(t){return o=!1,e(),n.runController("submit",{uuid:t})},"error/:uuid":function(t){return o=!1,e(),n.runController("error",{uuid:t})},"success/:uuid":function(t){return o=!1,e(),n.runController("success",{uuid:t})},"info/:uuid/:number_code":function(t,i){return o=!1,e(),n.runController("info",{uuid:t,number_code:i})}},n}),define("check/error-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,t,e,o,i){var n=new n,c=Dom7;Template7;return n.run=function(){var n=this;n.setPageTitle("验证结果"),n.render()},n.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)})},n}),define("check/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,t,e,o,i){var n=new n,c=Dom7,r=(Template7,1),a=0,u=2,s=0;return n.run=function(){var n=this;n.setPageTitle("验证标签"),i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["openLocation","getLocation","scanQRCode"]}),n.scanQrcode(),n.render(),c(".scan-button").attr("disabled","disabled"),c(".scan-button").text("正在调起扫码……")},n.bindEvents=function(){var n=this;c(".scan-button").click(function(){n.scanQrcode()})},n.scanQrcode=function(){var n=this;i.ready(function(){i.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(o){var i=o.resultStr,d=c.parseUrlQuery(i);if(null!=d&&void 0!==d&&null!=d.uuid&&void 0!==d.uuid){if(d.uuid.indexOf("@")==-1)return e.toast({content:"该智能防伪二维码无效"}),!1;var d=d.uuid.split("@"),l=t.to("smart#enter/"+d[0]),m=t.to("check#scan-count/"+d[0]+"/"+s),f=t.to("check#warning/"+d[0]);c.ajax({method:"POST",url:t.to("check/default/check-active"),data:{uuid:d[0]},dataType:"json",beforeSend:function(){n.showIndicator()},success:function(n){s=n.scan_count,m=t.to("check#scan-count/"+d[0]+"/"+s),n.success==r?window.location.href=m:n.success==a?window.location.href=l:n.success==u?window.location.href=f:window.location.href=f},error:function(n){},complete:function(t){n.hideIndicator()}})}else e.toast({content:"请扫描智能防伪二维码"})}}),setTimeout(function(){c(".scan-button").removeAttr("disabled"),c(".scan-button").text("点击扫描标签")},1e3)})},n}),define("check/info-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,t,e,o,i){var n=new n,c=Dom7;Template7;return n.run=function(){var n=this;n.setPageTitle("隐私信息"),n.loadData(n.params.uuid,n.params.number_code),n.popstate()},n.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)})},n.loadData=function(n,o){var i=this;c.ajax({method:"POST",url:t.to("check/default/get-info"),data:{uuid:n,number_code:o},dataType:"json",beforeSend:function(){i.showIndicator()},success:function(n){try{n.success?i.render(n.data):e.toast({content:n.message,closeDelay:3e3})}catch(t){e.toast({content:"出错",closeDelay:3e3})}},error:function(n){e.toast({content:"提交出错,请联系系统管理员"})},complete:function(n){i.hideIndicator()}})},n.popstate=function(){window.addEventListener("popstate",function(n){window.location.href=t.to("check#index")},!1)},n}),define("check/scan-count-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,t,e,o,i){var n=new n,c=Dom7,r=(Template7,0),a="";return n.run=function(){var n=this;r=parseInt(n.params.scancount),a=n.params.uuid,n.setPageTitle("验证标签"),n.render(),c(".count-num").html(r)},n.bindEvents=function(){c(".scan-button").click(function(){""!=a&&void 0!=a?window.location.href=t.to("check#submit/"+a):window.location.href=t.to("check#index")})},n}),define("check/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,t,e,o,i){var n=new n,c=Dom7,r=(Template7,"");return n.run=function(){var n=this;r=n.params.uuid,n.setPageTitle("验证标签"),i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["chooseImage","previewImage","uploadImage","getLocalImgData"]}),n.render()},n.bindEvents=function(){var n=this;c(".scan-image").click(function(){n.uploadImg(c(this))}),c(".scan-button").click(function(){var o=c(".scan-image").attr("data");return e.isEmpty(o)?(e.toast({content:"请拍照文件上传后再试!"}),!1):void c.ajax({method:"POST",url:t.to("check/default/check-actived"),data:{upload_file:o,uuid:r},dataType:"json",beforeSend:function(){n.showIndicator()},success:function(n){try{n.success?window.location.href=t.to("check#success/"+r):window.location.href=t.to("check#error/"+r)}catch(o){e.toast({content:"出错",closeDelay:3e3})}},error:function(n){e.toast({content:"提交出错,请联系系统管理员"})},complete:function(t){n.hideIndicator()}})})},n.uploadImg=function(n){var t=this;i.ready(function(){i.chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(e){e.localIds.length>0&&t.upload(e.localIds,n)}})})},n.upload=function(n,o){var a=this;return void 0==n[0]?"":void i.uploadImage({localId:n[0],isShowProgressTips:1,success:function(n){c.ajax({method:"POST",url:t.to("check/default/update-serviceid"),data:{service_id:n.serverId,uuid:r},dataType:"json",beforeSend:function(){a.showIndicator()},success:function(n){try{if(n.success){var t=n.img_path;o.attr("data",t),o.attr("src",n.show_path)}else e.toast({content:n.message,closeDelay:3e3})}catch(i){e.toast({content:"出错",closeDelay:3e3})}},error:function(n){e.toast({content:"提交出错,请联系系统管理员"})},complete:function(n){a.hideIndicator()}})},fail:function(n){a.app.alert(JSON.stringify(n))}})},n}),define("check/success-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,t,e,o,i){var n=new n,c=Dom7,r=(Template7,"");return n.run=function(){var n=this;r=n.params.uuid,n.setPageTitle("验证结果"),n.render()},n.bindEvents=function(){var n=this;c(".btn-submit").click(function(){var o=c(".input-num").val();return e.isEmpty(o)?(e.toast({content:"请填写提取码"}),c(".input-num").focus(),!1):e.isEmpty(r)?(e.toast({content:"缺少必要参数请退出重试"}),!1):void c.ajax({method:"POST",url:t.to("check/default/get-info"),data:{uuid:r,number_code:o},dataType:"json",beforeSend:function(){n.showIndicator()},success:function(n){try{n.success?window.location.href=t.to("check#info/"+r+"/"+o):e.toast({content:n.message,closeDelay:3e3})}catch(i){e.toast({content:"出错",closeDelay:3e3})}},error:function(n){e.toast({content:"提交出错,请联系系统管理员"})},complete:function(t){n.hideIndicator()}})})},n}),define("check/warning-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,t,e,o,i){var n=new n,c=Dom7,r=(Template7,"");return n.run=function(){var n=this;r=n.params.uuid,n.setPageTitle("验证标签"),n.render()},n.bindEvents=function(){c(".scan-jump-button").click(function(){""!=r&&void 0!=r?window.location.href=t.to("smart#enter/"+r):window.location.href=t.to("check#index")})},n}); | |
3 | 3 | \ No newline at end of file | ... | ... |
app-wx/web/src/js/check/info-controller.js
... | ... | @@ -19,6 +19,7 @@ define( |
19 | 19 | var me = this; |
20 | 20 | me.setPageTitle("隐私信息"); |
21 | 21 | me.loadData(me.params.uuid, me.params.number_code) |
22 | + me.popstate(); | |
22 | 23 | }; |
23 | 24 | |
24 | 25 | ctrl.bindEvents = function () { |
... | ... | @@ -57,6 +58,14 @@ define( |
57 | 58 | }, |
58 | 59 | }); |
59 | 60 | } |
61 | + | |
62 | + ctrl.popstate = function () { | |
63 | + window.addEventListener("popstate", function (e) { | |
64 | + // 监听到了浏览器的返回按钮事件,根据自己的需求实现自己的功能 | |
65 | + window.location.href = url.to('check#index'); | |
66 | + }, false); | |
67 | + } | |
68 | + | |
60 | 69 | return ctrl; |
61 | 70 | } |
62 | 71 | ); |
63 | 72 | \ No newline at end of file | ... | ... |
domain/smart/SellerInputRecord.php
... | ... | @@ -34,10 +34,16 @@ class SellerInputRecord |
34 | 34 | if($result) { |
35 | 35 | // 新增用户地址 |
36 | 36 | if (trim($item['delivery_address'])) { |
37 | - $userAddress = UserAddress::create([ | |
38 | - "user_id" => trim($item["user_mp_id"]), | |
39 | - "address" => trim($item['delivery_address']), | |
40 | - ]); | |
37 | + $userAddressFind = UserAddressRepository::findOne(["user_id" => trim($item["user_mp_id"])]); | |
38 | + if ($userAddressFind) { | |
39 | + $userAddressFind->address = trim($item['delivery_address']); | |
40 | + $userAddressFind->save(); | |
41 | + } else { | |
42 | + $userAddress = UserAddress::create([ | |
43 | + "user_id" => trim($item["user_mp_id"]), | |
44 | + "address" => trim($item['delivery_address']), | |
45 | + ]); | |
46 | + } | |
41 | 47 | } |
42 | 48 | $result = $sellerInputRecordModel->id; |
43 | 49 | } else { | ... | ... |