Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
U
User
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangjun
User
Commits
7d2c9fac
Commit
7d2c9fac
authored
Aug 10, 2022
by
zhangjun
Browse files
Options
Browse Files
Download
Plain Diff
合并分支 'release_personal_202207' 到 'release'
优惠券 查看合并请求
!7
parents
d0933fc3
25b9b459
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
294 additions
and
49 deletions
+294
-49
esf_center_api.php
center/controllers/esf_center_api.php
+57
-6
user.php
center/controllers/user.php
+87
-43
zero_yuan_pay.php
center/views/zero_yuan_pay.php
+23
-0
constants.php
esf_core/config/constants.php
+8
-0
package_model.php
esf_core/models/package_model.php
+72
-0
user_model.php
esf_core/models/user_model.php
+47
-0
No files found.
center/controllers/esf_center_api.php
View file @
7d2c9fac
...
...
@@ -2919,12 +2919,13 @@ class Esf_center_api extends MY_Controller {
public
function
notify
(){
$data
=
$_POST
;
$msg
=
"************************************************
\n
"
;
$msg
.=
date
(
'Y-m-d H:i:s'
)
.
var_export
(
$_POST
,
true
)
.
"
\n
"
;
$log
=
dirname
(
__FILE__
)
.
"/notify"
;
file_put_contents
(
$log
,
$msg
,
FILE_APPEND
);
$log2
=
dirname
(
__FILE__
)
.
"/notifylog2.txt"
;
file_put_contents
(
$log2
,
$msg
,
FILE_APPEND
);
$this
->
user_model
->
addLog
(
"微信支付回调参数数据2:"
,
json_encode
(
$data
)
);
// $msg = "************************************************ \n";
// $msg .= date('Y-m-d H:i:s').var_export($_POST,true)." \n";
// $log = dirname(__FILE__)."/notify";
// file_put_contents($log,$msg,FILE_APPEND );
// $log2 = dirname(__FILE__ ) . "/notifylog2.txt";
// file_put_contents( $log2, $msg,FILE_APPEND );
$result
[
'status'
]
=
'FAIL'
;
if
(
GB_CITY
!=
'nj'
&&
GB_CITY
!=
'wh'
){
$result
[
'msg'
]
=
'city error'
;
...
...
@@ -2991,6 +2992,56 @@ class Esf_center_api extends MY_Controller {
}
}
/**
* 0元支付回调
*/
public
function
zeroNotify
()
{
$result
[
'status'
]
=
0
;
$data
=
$_POST
;
$transactionId
=
isset
(
$data
[
'transaction_id'
]
)
?
$data
[
'transaction_id'
]
:
''
;
// 订单数据
$orderInfo
=
$this
->
package_model
->
getOrderInfoByTransactionId
(
$transactionId
);
if
(
empty
(
$orderInfo
)
)
{
$result
[
'msg'
]
=
'订单数据不存在'
;
echo
json_encode
(
$result
);
exit
;
}
//判断订单状态
if
(
$orderInfo
[
'order_status'
]
!=
1
){
$result
[
'msg'
]
=
'订单已关闭'
;
echo
json_encode
(
$result
);
exit
;
}
if
(
$orderInfo
[
'pay_status'
]
!=
0
){
$result
[
'msg'
]
=
'订单已失效'
;
echo
json_encode
(
$result
);
exit
;
}
$payTransactionId
=
isset
(
$data
[
'pay_transaction_id'
]
)
?
$data
[
'pay_transaction_id'
]
:
''
;
if
(
empty
(
$payTransactionId
)
)
{
$result
[
'msg'
]
=
'支付凭证不能为空'
;
echo
json_encode
(
$result
);
exit
;
}
//支付成功后的操作
$res
=
$this
->
package_model
->
payFinish
(
$orderInfo
,
array
(
'transaction_id'
=>
$payTransactionId
)
);
if
(
!
$res
)
{
$result
[
'msg'
]
=
'生成推广相关数据失败'
;
echo
json_encode
(
$result
);
exit
;
}
// 发送短信
if
(
GB_CITY
==
'nj'
)
{
$this
->
sendMsg
(
$orderInfo
);
}
$result
[
'status'
]
=
1
;
$result
[
'msg'
]
=
'成功'
;
echo
json_encode
(
$result
);
exit
;
}
// 支付回调修复数据 20200605
public
function
notify_modify_data
(){
$data
=
$_POST
;
...
...
center/controllers/user.php
View file @
7d2c9fac
...
...
@@ -1814,8 +1814,10 @@ class User extends MY_Controller
$packageKeyword
=
intval
(
$this
->
input
->
post
(
'package_keyword'
,
true
));
$day
=
intval
(
$this
->
input
->
post
(
'day_'
.
$packageType
,
true
));
$payType
=
addslashes
(
$this
->
input
->
post
(
'pay_type'
,
true
));
//
租房8折优惠券 20200507添加
//
是否使用优惠券
$use_coupon
=
intval
(
$this
->
input
->
post
(
'use_coupon'
,
true
));
// 优惠券ID
$coupon_id
=
intval
(
$this
->
input
->
post
(
'coupon_id'
,
true
));
$from_url
=
$this
->
input
->
post
(
'from_url'
,
true
);
if
(
empty
(
$packageId
)
||
empty
(
$houseId
)
||
empty
(
$tbl
)
||
empty
(
$packageType
)
||
(
!
in_array
(
$packageType
,
array
(
4
,
5
))
&&
empty
(
$day
))
||
empty
(
$payType
)
||
!
in_array
(
$payType
,
$payTypeArr
)){
return
$this
->
jump
(
USER_CENTER
,
'参数缺失'
,
3000
,
'warning'
);
...
...
@@ -1849,73 +1851,89 @@ class User extends MY_Controller
$packageData
[
'package_desc'
]
=
unserialize
(
$packageData
[
'package_desc'
]);
foreach
(
$packageData
[
'package_desc'
]
as
$item
){
if
(
$packageType
==
4
){
$price
=
floatval
(
$item
[
'price'
]);
$price
=
$originalPrice
=
floatval
(
$item
[
'price'
]);
}
else
if
(
$packageType
==
5
){
if
(
$item
[
'property_type'
]
==
$infoType
){
$price
=
floatval
(
$item
[
'price'
]);
$price
=
$originalPrice
=
floatval
(
$item
[
'price'
]);
//处理折扣
if
(
isset
(
$item
[
'discount'
])
&&
$item
[
'discount'
]
>
0
){
$price
=
$this
->
pirceDiscount
(
$price
,
$item
[
'discount'
]);
$price
=
$
originalPrice
=
$
this
->
pirceDiscount
(
$price
,
$item
[
'discount'
]);
}
}
}
else
{
if
(
$item
[
'property_type'
]
==
$infoType
&&
$item
[
'day'
]
==
$day
){
$price
=
floatval
(
$item
[
'price'
]);
$price
=
$originalPrice
=
floatval
(
$item
[
'price'
]);
if
(
GB_CITY
==
'wh'
&&
$packageType
==
2
){
//处理折扣
if
(
isset
(
$item
[
'discount'
])
&&
$item
[
'discount'
]
>
0
){
$price
=
$this
->
pirceDiscount
(
$price
,
$item
[
'discount'
]);
$price
=
$
originalPrice
=
$
this
->
pirceDiscount
(
$price
,
$item
[
'discount'
]);
}
}
// 列表套餐8折券使用 20200507
// 优惠券修改为 6折
if
(
GB_CITY
==
'nj'
&&
$packageType
==
2
&&
$tbl
==
'rent'
){
//
$checkbox_status
=
0
;
// 检查是否有可用的优惠券,如果有则使用,如果无,则跳转提示
$userInfoData
=
$this
->
user_model
->
getuserdetail
(
$this
->
user_id
);
$passport_uid
=
$userInfoData
?
$userInfoData
[
'passport_uid'
]
:
0
;
// 测试数据
$couponUserIdArr
=
array
(
'1785149'
,
'3367096'
,
'4112782'
);
if
(
in_array
(
$this
->
user_id
,
$couponUserIdArr
)
){
$price
=
0.05
;
}
if
(
isset
(
$use_coupon
)
&&
$use_coupon
==
1
){
$check_coupon
=
$this
->
rent_coupon_model
->
checkCoupon
(
$passport_uid
);
if
(
!
$check_coupon
){
$from_url
=
$from_url
?
$from_url
:
USER_CENTER
;
return
$this
->
jumpNew
(
$from_url
,
'已有待支付订单,勿重复下单!<br/>请30分钟后再试。'
,
3000
,
'warning'
);
}
$checkbox_status
=
1
;
// 列表优先套餐8折
// 修改为6折 20200927
$price
=
sprintf
(
"%.2f"
,
$price
*
0.6
);
// 锁定半小时
$this
->
rent_coupon_model
->
lockCoupon
(
$passport_uid
);
}
// 设置8折优惠券的选中状态
$this
->
rent_coupon_model
->
setCheckbox
(
$passport_uid
,
$checkbox_status
);
// if( GB_CITY == 'nj' && $packageType == 2 && $tbl == 'rent'){
// //
// $checkbox_status = 0;
// // 检查是否有可用的优惠券,如果有则使用,如果无,则跳转提示
// $userInfoData = $this->user_model->getuserdetail($this->user_id);
// $passport_uid = $userInfoData ? $userInfoData['passport_uid'] : 0;
//
// // 测试数据
// $couponUserIdArr = array('1785149','3367096','4112782');
// if( in_array($this->user_id,$couponUserIdArr) ){
// $price = 0.05;
// }
//
// if( isset($use_coupon) && $use_coupon == 1){
//
// $check_coupon = $this->rent_coupon_model->checkCoupon($passport_uid);
// if( !$check_coupon ){
// $from_url = $from_url ? $from_url : USER_CENTER;
// return $this->jumpNew($from_url,'已有待支付订单,勿重复下单!<br/>请30分钟后再试。',3000,'warning');
// }
// $checkbox_status = 1;
// // 列表优先套餐8折
// // 修改为6折 20200927
// $price = sprintf("%.2f",$price * 0.6);
// // 锁定半小时
// $this->rent_coupon_model->lockCoupon($passport_uid);
//
//
// }
//
// // 设置8折优惠券的选中状态
// $this->rent_coupon_model->setCheckbox($passport_uid,$checkbox_status);
//
// }
}
}
}
}
// 使用优惠券
if
(
GB_CITY
==
'nj'
)
{
if
(
isset
(
$use_coupon
)
&&
$use_coupon
==
1
)
{
$couponRes
=
$this
->
user_model
->
checkCoupon
(
$this
->
user_id
,
$coupon_id
,
$price
,
$packageType
);
if
(
isset
(
$couponRes
[
'result'
]
)
&&
$couponRes
[
'result'
]
==
1
)
{
$price
=
$price
-
$couponRes
[
'data'
][
'coupon_price'
]
;
}
}
}
$userIdArr
=
array
(
4112782
,
5355879
,
1729793
,
4449390
);
if
(
in_array
(
$this
->
user_id
,
$userIdArr
)){
$price
=
0.01
;
$price
=
$price
*
0.01
;
}
// 付款方式
$payType
=
$price
<=
0
?
'zeroyuanpay'
:
$payType
;
//校验参数正确性
if
(
$packageType
!=
$packageData
[
'package_type'
]
||
empty
(
$price
)
||
$price
<=
0
){
return
$this
->
jump
(
USER_CENTER
,
'套餐价格数据异常'
,
3000
,
'warning'
);
// if($packageType != $packageData['package_type'] || empty($price) || $price <= 0){
// return $this->jump(USER_CENTER,'套餐价格数据异常',3000,'warning');
// }
if
(
$packageType
!=
$packageData
[
'package_type'
]){
return
$this
->
jump
(
USER_CENTER
,
'套餐数据异常'
,
3000
,
'warning'
);
}
if
(
$packageType
==
1
&&
(
$packageKeyword
!=
$packageData
[
'package_keyword'
]
||
$packageKeyword
<=
0
)
){
return
$this
->
jump
(
USER_CENTER
,
'套餐关键词异常'
,
3000
,
'warning'
);
...
...
@@ -1973,7 +1991,7 @@ class User extends MY_Controller
$tblArr
=
array
(
'sell'
=>
1
,
'rent'
=>
2
);
$tableId
=
$tblArr
[
$tbl
];
$orderData
=
array
();
$orderData
[
'transaction_id'
]
=
$this
->
package_model
->
getTransactionId
(
$packageType
);
$orderData
[
'transaction_id'
]
=
$this
->
package_model
->
getTransactionId
(
$packageType
);
$orderData
[
'user_id'
]
=
$this
->
user_id
;
$orderData
[
'house_type'
]
=
$tableId
;
$orderData
[
'house_id'
]
=
$houseId
;
...
...
@@ -1983,6 +2001,12 @@ class User extends MY_Controller
if
(
$packageType
==
1
){
$orderData
[
'package_keyword'
]
=
$packageKeyword
;
}
// 优惠券字段
if
(
isset
(
$couponRes
[
'result'
]
)
&&
$couponRes
[
'result'
]
==
1
)
{
$orderData
[
'coupon_name'
]
=
isset
(
$couponRes
[
'data'
][
'name'
]
)
?
iconv
(
'utf-8'
,
'gbk'
,
$couponRes
[
'data'
][
'name'
])
:
0
;
$orderData
[
'coupon_price'
]
=
isset
(
$couponRes
[
'data'
][
'coupon_price'
]
)
?
$couponRes
[
'data'
][
'coupon_price'
]
:
0
;
$orderData
[
'coupon_id'
]
=
isset
(
$couponRes
[
'data'
][
'id'
]
)
?
$couponRes
[
'data'
][
'id'
]
:
0
;
}
$orderData
[
'package_days'
]
=
$day
;
$orderData
[
'price'
]
=
$price
;
$orderData
[
'create_time'
]
=
time
();
...
...
@@ -1996,6 +2020,26 @@ class User extends MY_Controller
return
$this
->
jump
(
USER_CENTER
,
'订单创建失败'
,
3000
,
'warning'
);
}
// 使用优惠券
if
(
GB_CITY
==
'nj'
){
if
(
isset
(
$use_coupon
)
&&
$use_coupon
==
1
)
{
$this
->
user_model
->
useCoupon
(
$orderData
[
'transaction_id'
],
$this
->
user_id
,
$coupon_id
,
$originalPrice
,
$packageType
);
// 0元支付
if
(
$price
<=
0
)
{
//支付成功后的操作
$result
=
$this
->
package_model
->
payFinish
(
$orderData
,
array
(
'transaction_id'
=>
$this
->
package_model
->
getPaymentTransactionId
(
$packageType
)));
if
(
GB_CITY
==
'nj'
)
{
$this
->
package_model
->
sendMsg
(
$orderData
);
}
$data
[
'orderData'
]
=
$orderData
;
$data
[
'title'
]
=
'0元支付'
;
$this
->
load
->
view
(
'zero_yuan_pay'
,
$data
);
return
;
}
}
}
$data
=
$this
->
getWxPayCodeByHouse365
(
$orderId
);
if
(
$data
[
'status'
]
!=
1
){
return
$this
->
jump
(
USER_CENTER
,
$data
[
'msg'
],
3000
,
'warning'
);
...
...
center/views/zero_yuan_pay.php
0 → 100644
View file @
7d2c9fac
<?php
require
APPPATH_MVC
.
'views/header.php'
;
?>
<div
class=
"paysuc popw"
>
<div
class=
"release-failBack"
>
</div>
<div
class=
"release-fail yz-pop"
>
<div
class=
"tit"
>
<span>
支付成功
</span>
<div
class=
"closes"
></div>
</div>
<div
class=
"poplist"
>
<div
class=
"pstit"
>
支付成功
</div>
<div
class=
"f16 c3 mt20"
>
前往
<a
href=
"
<?php
echo
USER_CENTER
;
?>
"
class=
"orange"
>
个人中心>>
</a></div>
<div
class=
"f14 c3 mt10"
>
支付金额:
<span
class=
"bold red"
>
<?=
$orderData
[
'price'
]
?>
元
</span>
<a
href=
"
<?php
echo
USER_CENTER
.
'user/orderInvoice/'
.
$orderData
[
'id'
]
?>
"
>
<span
class=
"f14 oranget hand"
>
我要开发票
</span>
</a>
</div>
</div>
<p>
重要提醒:不点陌生链接、不泄露银行卡和验证码信息,谨防诈骗!
</p>
</div>
</div>
<!--2017-11-28 end-->
<?php
require
APPPATH_MVC
.
'views/footer.php'
;
?>
esf_core/config/constants.php
View file @
7d2c9fac
...
...
@@ -413,6 +413,14 @@ define('GB_UCENTER_LOGIN_URL', 'https://ucenter.house365.com/index/login');
define
(
'GB_NEWRENT_INDEX_URL'
,
'http://newrent.house365.com/sell/index'
);
// 退出地址
define
(
'GB_LOGOUT_URL'
,
'http://passport.house365.com/index/logout'
);
// 验证优惠券
define
(
'GB_CHECK_COUPON_URL'
,
'http://newrent.house365.com/api/tf-app/check-coupon-personal'
);
// 使用优惠券
define
(
'GB_USE_COUPON_URL'
,
'http://newrent.house365.com/api/tf-app/use-coupon'
);
// 更新状态接口地址
define
(
'GB_UPDATE_COUPON_URL'
,
'http://newrent.house365.com/api/tf-app/update-coupon-status'
);
// 添加日志
define
(
'GB_ADD_LOG_URL'
,
'http://newrent.house365.com/api/tf-app/add-log'
);
if
(
$_SERVER
[
'SERVER_ADDR'
]
==
'192.168.105.106'
)
{
...
...
esf_core/models/package_model.php
View file @
7d2c9fac
...
...
@@ -58,6 +58,22 @@ class Package_model extends MY_Model
return
time
()
.
$formatType
.
$randValue
;
}
/**
* 获取某个产品的0元支付交易号
* @param int $type 产品类型 1代表首页推荐,2代表列表页推荐,3代表智能刷新,4代表普通刷新
* @return string
*/
public
function
getPaymentTransactionId
(
$type
)
{
//防止订单ID与租售宝重复,$type 定义为从50开始
$type
=
50
+
$type
;
$formatType
=
self
::
formatValue
(
$type
,
2
);
//随机数
$randValue
=
self
::
formatValue
(
self
::
randValue
(),
4
);
//订单号
return
'zeropay-'
.
time
()
.
$formatType
.
$randValue
;
}
/**
* 获取套餐详情
* @param int $id 套餐ID
...
...
@@ -552,6 +568,11 @@ class Package_model extends MY_Model
//订单状态更新成功,设置缓存5分钟内不再允许更新
$this
->
memcached_class
->
add
(
$cacheKey
,
1
,
300
);
//更新优惠券
if
(
GB_CITY
==
'nj'
&&
(
int
)
$orderInfo
[
'coupon_id'
]
>
0
)
{
$this
->
updateCouponStatus
(
$orderInfo
[
'user_id'
],
$orderInfo
[
'coupon_id'
]
);
}
$data
=
array
();
$tableArray
=
array
(
1
=>
'sell'
,
2
=>
'rent'
);
$tbl
=
$tableArray
[
$orderInfo
[
'house_type'
]];
...
...
@@ -947,6 +968,18 @@ class Package_model extends MY_Model
}
/**
* 验证优惠券
* @param $user_id
* @param $coupon_id
*/
public
function
updateCouponStatus
(
$user_id
,
$coupon_id
)
{
$url
=
GB_UPDATE_COUPON_URL
.
'?uid='
.
$user_id
.
'&coupon_id='
.
$coupon_id
;
$couponRes
=
curl_get_contents
(
$url
);
$couponRes
=
!
empty
(
$couponRes
)
?
json_decode
(
$couponRes
,
1
)
:
array
();
return
$couponRes
;
}
/**
* 远程获取
* @author zj
...
...
@@ -968,4 +1001,42 @@ class Package_model extends MY_Model
curl_close
(
$ch
);
return
$str
;
}
/**
* 发送消息
* @author zj
* @date 2020-09-08
*
* @param array $orderInfo 订单数据
* @return bool
*/
public
function
sendMsg
(
$orderInfo
)
{
$message
=
''
;
$this
->
load
->
library
(
"apply_class"
);
if
(
$orderInfo
[
'package_type'
]
==
1
)
{
$message
=
"您已成功购买
{
$orderInfo
[
'package_days'
]
}
天的首页推荐套餐,购买的套餐可以在个人中心-我的订单进行查看。"
;
}
else
if
(
$orderInfo
[
'package_type'
]
==
2
)
{
$message
=
"您已成功购买
{
$orderInfo
[
'package_days'
]
}
天的列表页推荐套餐,购买的套餐可以在个人中心-我的订单进行查看。"
;
}
else
if
(
$orderInfo
[
'package_type'
]
==
3
)
{
$message
=
"您已成功购买
{
$orderInfo
[
'package_days'
]
}
天的智能刷新套餐,购买的套餐可以在个人中心-我的订单进行查看。"
;
}
else
if
(
$orderInfo
[
'package_type'
]
==
6
)
{
$message
=
"您已成功购买24小时
{
$orderInfo
[
'refresh_num'
]
}
次刷新,您可以选择手动去刷新或者设置时间预约刷新,购买的套餐可以在个人中心-我的订单进行查看哦"
;
}
if
(
!
$message
)
{
return
false
;
}
//发送用户中心消息
$subject
=
'购买套餐成功。'
;
$this
->
apply_class
->
send_systemmsg
(
$orderInfo
[
'user_id'
],
$subject
,
$message
,
7
,
GB_CITY
);
//发送短信
$telno
=
isset
(
$orderInfo
[
'house_tel'
]
)
?
$orderInfo
[
'house_tel'
]
:
''
;
if
(
$telno
)
{
sendsms
(
$telno
,
$message
,
'sx'
);
}
return
true
;
}
}
\ No newline at end of file
esf_core/models/user_model.php
View file @
7d2c9fac
...
...
@@ -6114,6 +6114,53 @@ if($searcharr['infotype']==4){
return
$collect_array
;
}
/**
* 验证优惠券
* @param $user_id
* @param $coupon_id
* @param $price
* @param $packageType
*/
public
function
checkCoupon
(
$user_id
,
$coupon_id
,
$price
,
$packageType
)
{
$url
=
GB_CHECK_COUPON_URL
.
'?uid='
.
$user_id
.
'&coupon_id='
.
$coupon_id
.
'&price='
.
$price
.
'&package_type='
.
$packageType
;
$couponRes
=
curl_get_contents
(
$url
);
$couponRes
=
!
empty
(
$couponRes
)
?
json_decode
(
$couponRes
,
1
)
:
array
();
return
$couponRes
;
}
/**
* 验证优惠券
* @param $order_code
* @param $user_id
* @param $coupon_id
* @param $price
* @param $packageType
*/
public
function
useCoupon
(
$order_code
,
$user_id
,
$coupon_id
,
$price
,
$packageType
)
{
$params
=
array
(
'order_code'
=>
$order_code
,
'coupon_id'
=>
$coupon_id
,
'price'
=>
$price
,
'uid'
=>
$user_id
,
'package_type'
=>
$packageType
,
);
$url
=
GB_USE_COUPON_URL
;
$couonRes
=
$this
->
request_post
(
$url
,
$params
);
$couonRes
=
!
empty
(
$couonRes
)
?
json_decode
(
$couonRes
,
1
)
:
array
();
return
$couonRes
;
}
/**
* 记录日志
* @param $params
*/
public
function
addLog
(
$msg
,
$content
)
{
$url
=
GB_ADD_LOG_URL
;
$res
=
$this
->
request_post
(
$url
,
array
(
'msg'
=>
iconv
(
'gbk'
,
'utf-8'
,
$msg
),
'content'
=>
$content
)
);
return
$res
;
}
function
request_post
(
$url
=
''
,
$param
=
''
)
{
if
(
empty
(
$url
)
||
empty
(
$param
))
{
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment