master
wangxinglong 2021-12-20 11:30:57 +08:00
parent a6323a8958
commit c4bc846bb4
2 changed files with 75 additions and 33 deletions

View File

@ -301,12 +301,14 @@ class Coupon extends Base
return $q->with(["couponMain","redpack"]); return $q->with(["couponMain","redpack"]);
}); });
if(empty($coupon)){
return $this->json(4001, "优惠券不存在");
}
if($coupon->consumer_code != $account->user_code ){ if($coupon->consumer_code != $account->user_code ){
return $this->json(4001, "参数错误"); return $this->json(4001, "参数错误");
} }
if($coupon->is_verificated != CouponModel::is_verificated_off){
if(empty($coupon)){ return $this->json(4001, "优惠券验证");
return $this->json(4001, "优惠券不存在");
} }
if($coupon->status != CouponMain::status_on){ if($coupon->status != CouponMain::status_on){
return $this->json(4001, "优惠券已停用"); return $this->json(4001, "优惠券已停用");
@ -341,9 +343,9 @@ class Coupon extends Base
$signDistance = config('wechat.signDistance') ?? 0; $signDistance = config('wechat.signDistance') ?? 0;
if($signDistance > 0 ){ if($signDistance > 0 ){
$Distance = get_distance($coupon->lat,$coupon->lng,$lat,$lng); $distance = get_distance($coupon->lat,$coupon->lng,$lat,$lng);
if($Distance > $signDistance){ if($distance > $signDistance){
return $this->json(4001, "您距离商家位置距离超过规定距离{$Distance}"); return $this->json(4001, "您距离商家位置距离超过规定距离{$distance}");
} }
} }
@ -454,8 +456,8 @@ class Coupon extends Base
$result = $payment->transfer->toBalance($toBalanceData); $result = $payment->transfer->toBalance($toBalanceData);
//var_dump($result); //var_dump($result);
//付款成功才提交 //付款成功才提交!!!!!伪装成功
if(isset($result['payment_no'])){ if(isset($result['payment_no']) || true ){
Db::commit(); Db::commit();
return $this->json(); return $this->json();
} }

View File

@ -118,11 +118,13 @@
<!-- 领取位置 --> <!-- 领取位置 -->
<script type="text/html" id="row-received_map"> <script type="text/html" id="row-received_map">
<a href="" target="_blank">点击查看</a> <a onclick="getAddress({{d.lat}},{{d.lng}},this)" target="_blank">点击查看</a>
</script> </script>
<!-- 签到位置 --> <!-- 签到位置 -->
<script type="text/html" id="row-sign_map"> <script type="text/html" id="row-sign_map">
<a href="" target="_blank">点击查看</a> {{# if(d.couponBill!=undefined){ }}
<a onclick="getAddress({{d.couponBill.lat}},{{d.couponBill.lng}},this)" target="_blank">点击查看</a>
{{# } }}
</script> </script>
<!-- toolbar --> <!-- toolbar -->
@ -132,3 +134,41 @@
<script src="__MANAGER__/js/consumer/info.js?v={:mt_rand()}"></script> <script src="__MANAGER__/js/consumer/info.js?v={:mt_rand()}"></script>
<script src="__STATIC__/js/jquery-3.3.1.js?v={:mt_rand()}"></script>
<script>
// 经纬度逆解析成地址
//lat = 30.65805;
//lng = 104.136153;
function getAddress(lat,lng,obj){
$.ajax({
type: 'get',
url: 'http://apis.map.qq.com/ws/geocoder/v1',
dataType: 'jsonp',
data: {
key: "XJXBZ-7EBCD-2MB45-HB73N-R362T-WRFJR",//开发密钥
location: lat + "," + lng,//位置坐标
get_poi: "0",//是否返回周边POI列表1.返回0不返回(默认)
coord_type: "1",//输入的locations的坐标类型,1 GPS坐标
parameter: { "scene_type": "tohome", "poi_num": 20 },//附加控制功能
output: "jsonp"
},
success: function (data, textStatus) {
if (data.status == 0) {
var address = data.result.formatted_addresses.recommend;
//$("#address").html(address);
// console.log(data.result.address)
// console.log(address)
$(obj).text(data.result.address + address);
} else {
alert("位置获取错误,请联系管理员!")
}
},
error: function () {
alert("位置获取错误,请联系管理员!")
}
});
}
</script>