mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-04 04:49:33 +08:00
pay
This commit is contained in:
parent
d2171d6e43
commit
cb37f8fea2
@ -53,6 +53,7 @@ textarea {
|
||||
.spacing { padding-top: 20rpx; }
|
||||
.spacing-10 { padding-top: 10rpx; }
|
||||
.spacing-mb { margin-bottom: 20rpx; }
|
||||
.spacing-mt { margin-top: 20rpx; }
|
||||
|
||||
/* 在线客服 */
|
||||
.customer-service {
|
||||
@ -77,6 +78,7 @@ textarea {
|
||||
|
||||
|
||||
/* 边框 */
|
||||
.br { border: solid 1rpx #efefef; }
|
||||
.br-b { border-bottom: solid 1rpx #efefef; }
|
||||
.br-t { border-top: solid 1rpx #efefef; }
|
||||
.br-l { border-left: solid 1rpx #efefef; }
|
||||
|
@ -47,7 +47,7 @@ App({
|
||||
|
||||
// 请求地址
|
||||
request_url: "https://demo.shopxo.net/",
|
||||
request_url: 'http://localhost/project/shopxo/service/',
|
||||
//request_url: 'http://localhost/project/shopxo/service/',
|
||||
|
||||
// 基础信息
|
||||
application_title: "ShopXO电商系统",
|
||||
|
@ -1,3 +1,10 @@
|
||||
.page {
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
.address {
|
||||
padding: 10rpx;
|
||||
}
|
||||
@ -24,6 +31,9 @@
|
||||
line-height: 85rpx;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
.goods .goods-item:not(:last-child) {
|
||||
border-bottom: 1px dashed #efefef;
|
||||
}
|
||||
@ -50,6 +60,9 @@
|
||||
min-height: 160rpx;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航
|
||||
*/
|
||||
.buy-nav {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
@ -71,6 +84,36 @@
|
||||
.nav-submit button {
|
||||
border-radius: 0;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 120rpx;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
*/
|
||||
.payment-list .item {
|
||||
width: 50%;
|
||||
}
|
||||
.payment-list .item-content {
|
||||
margin: 20rpx;
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
.payment-list .item-content image {
|
||||
width: 50rpx;
|
||||
height: 50rpx !important;
|
||||
vertical-align: middle;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩展数据
|
||||
*/
|
||||
.extension-list {
|
||||
background-color: #ffffeb;
|
||||
}
|
||||
.extension-list .item {
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
.extension-list .item:not(:last-child) {
|
||||
border-bottom: 1px dashed #ffe2cf;
|
||||
}
|
||||
.extension-list .item .text-tips {
|
||||
color: #ff8f44;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
<view a:if="{{goods_list.length > 0}}" class="page">
|
||||
<!-- 地址 -->
|
||||
<view class="address bg-white arrow-right">
|
||||
<navigator url="/pages/user-address/user-address?is_back=1" hover-class="none">
|
||||
<view a:if="{{address != null}}">
|
||||
@ -18,6 +19,7 @@
|
||||
</view>
|
||||
<view class="address-divider spacing-mb"></view>
|
||||
|
||||
<!-- 商品 -->
|
||||
<view class="goods bg-white spacing-mb">
|
||||
<view a:for="{{goods_list}}" class="goods-item oh">
|
||||
<image class="goods-image fl" src="{{item.images}}" mode="aspectFill" />
|
||||
@ -33,14 +35,36 @@
|
||||
</text>
|
||||
<text a:if="{{item.original_price > 0}}" class="original-price">¥{{item.original_price}}
|
||||
</text>
|
||||
<text class="buy-number">x{{item.buy_number}}
|
||||
<text class="buy-number cr-888">x{{item.stock}}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<textarea onInput="bind_user_note_event" maxlength="60" auto-height placeholder="留言" />
|
||||
<!-- 留言 -->
|
||||
<textarea onInput="bind_user_note_event" maxlength="60" auto-height placeholder="留言" class="spacing-mb" />
|
||||
|
||||
<!-- 扩展数据展示 -->
|
||||
<view a:if="{{extension_list.length > 0}}" class="extension-list spacing-mb">
|
||||
<view a:for="{{extension_list}}" class="item oh">
|
||||
<text class="cr-666">{{item.name}}
|
||||
</text>
|
||||
<text class="text-tips fr">{{item.tips}}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 支付方式 -->
|
||||
<view a:if="{{payment_list.length > 0}}" class="payment-list bg-white oh">
|
||||
<view class="item tc fl" a:for="{{payment_list}}">
|
||||
<view class="item-content br" data-value="{{item.id}}" onTap="payment_event">
|
||||
<image a:if="{{(item.logo || null) != null}}" class="icon" src="{{item.logo}}" mode="widthFix" />
|
||||
<text>{{item.name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 导航 -->
|
||||
<view class="buy-nav oh wh-auto">
|
||||
<view class="nav-base bg-white fl single-text">
|
||||
<text>合计:</text>
|
||||
|
@ -5,12 +5,15 @@ Page({
|
||||
buy_submit_disabled_status: false,
|
||||
data_list_loding_msg: '',
|
||||
params: null,
|
||||
payment_list: [],
|
||||
goods_list: [],
|
||||
address: null,
|
||||
is_first: 1,
|
||||
address_id: 0,
|
||||
total_price: 0,
|
||||
user_note_value: '',
|
||||
is_first: 1,
|
||||
extension_list: [],
|
||||
payment_id: 0,
|
||||
},
|
||||
onLoad(params) {
|
||||
if((params.data || null) == null || app.get_length(JSON.parse(params.data)) == 0)
|
||||
@ -78,10 +81,16 @@ Page({
|
||||
this.setData({
|
||||
goods_list: data.goods_list,
|
||||
total_price: data.base.total_price,
|
||||
address: data.base.address,
|
||||
address_id: ((data.base.address || null) == null) ? 0 : data.base.address.id,
|
||||
payment_list: data.payment_list || [],
|
||||
extension_list: data.extension_list || [],
|
||||
data_list_loding_status: 3,
|
||||
});
|
||||
if (this.data.address == null || this.data.address_id == 0) {
|
||||
this.setData({
|
||||
address: data.base.address,
|
||||
address_id: ((data.base.address || null) == null) ? 0 : data.base.address.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
@ -116,81 +125,54 @@ Page({
|
||||
|
||||
// 提交订单
|
||||
buy_submit_event(e) {
|
||||
if((this.data.address_id || 0) == 0)
|
||||
{
|
||||
my.showToast({
|
||||
type: "fail",
|
||||
content: "请选择地址"
|
||||
// 表单数据
|
||||
var data = this.data.params;
|
||||
data['address_id'] = this.data.address_id;
|
||||
data['payment_id'] = this.data.payment_id;
|
||||
data['user_note'] = this.data.user_note_value;
|
||||
|
||||
// 数据验证
|
||||
var validation = [
|
||||
{ fields: 'address_id', msg: '请选择地址' },
|
||||
{ fields: 'payment_id', msg: '请选择支付方式' }
|
||||
];
|
||||
if (app.fields_check(data, validation)) {
|
||||
// 加载loding
|
||||
my.showLoading({content: '提交中...'});
|
||||
this.setData({
|
||||
buy_submit_disabled_status: true,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
var self = this;
|
||||
// 加载loding
|
||||
my.showLoading({content: '提交中...'});
|
||||
this.setData({
|
||||
buy_submit_disabled_status: true,
|
||||
});
|
||||
|
||||
my.httpRequest({
|
||||
url: app.get_request_url("Submit", "Buy"),
|
||||
method: "POST",
|
||||
data: {
|
||||
goods: this.data.params,
|
||||
address_id: this.data.address_id,
|
||||
user_note: this.data.user_note_value,
|
||||
},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
if(data.status == 1)
|
||||
{
|
||||
my.confirm({
|
||||
title: '',
|
||||
content: res.data.msg,
|
||||
confirmButtonText: '立即支付',
|
||||
cancelButtonText: '进入订单',
|
||||
success: (result) => {
|
||||
self.setData({buy_submit_disabled_status: false});
|
||||
var is_pay = (result.confirm) ? 1 : 0;
|
||||
my.redirectTo({
|
||||
url: '/pages/user-order/user-order?is_pay='+is_pay+'&order_id='+res.data.data.id
|
||||
});
|
||||
},
|
||||
my.httpRequest({
|
||||
url: app.get_request_url("Add", "Buy"),
|
||||
method: "POST",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
my.redirectTo({
|
||||
url: '/pages/user-order/user-order?is_pay=1' + '&order_id=' + res.data.data.order.id
|
||||
});
|
||||
} else {
|
||||
my.showToast({
|
||||
type: "success",
|
||||
content: res.data.msg
|
||||
});
|
||||
setTimeout(function()
|
||||
{
|
||||
self.setData({buy_submit_disabled_status: false});
|
||||
my.redirectTo({
|
||||
url: '/pages/user-order/user-order'
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
} else {
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
self.setData({buy_submit_disabled_status: false});
|
||||
|
||||
my.showToast({
|
||||
type: "fail",
|
||||
content: res.data.msg
|
||||
content: "服务器请求出错"
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
self.setData({buy_submit_disabled_status: false});
|
||||
|
||||
my.showToast({
|
||||
type: "fail",
|
||||
content: "服务器请求出错"
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 支付方式选择
|
||||
payment_event(e) {
|
||||
var payment_id = e.currentTarget.dataset.value || 0;
|
||||
this.setData({ payment_id: payment_id});
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -9,9 +9,7 @@
|
||||
</view>
|
||||
|
||||
<view class="btn-box">
|
||||
<navigator class="dy-wib" open-type="navigateBack">
|
||||
<button class="my-btn-default" type="default" hover-class="none" size="mini">返回</button>
|
||||
</navigator>
|
||||
<button class="my-btn-default dy-wib" type="default" hover-class="none" size="mini" onTap="back_event">返回</button>
|
||||
<navigator a:if="{{(params.page || null) != null && (params.title || null) != null}}" class="dy-wib" url="/pages/{{params.page}}/{{params.page}}" open-type="redirect">
|
||||
<button class="my-btn-default" type="default" hover-class="none" size="mini">{{params.title}}</button>
|
||||
</navigator>
|
||||
|
@ -51,10 +51,15 @@ Page({
|
||||
options['msg'] = msg;
|
||||
|
||||
// 支付成功返回的信息
|
||||
var pay = ((options.result || null) == null) ? {} : JSON.parse(options.result);;
|
||||
var pay = ((options.result || null) == null || options.result == 'undefined') ? {} : JSON.parse(options.result);
|
||||
options['pay'] = pay.alipay_trade_app_pay_response;
|
||||
|
||||
// 设置信息
|
||||
this.setData({params: options});
|
||||
},
|
||||
|
||||
// 返回
|
||||
back_event(e) {
|
||||
my.navigateBack();
|
||||
}
|
||||
});
|
||||
|
@ -90,7 +90,7 @@ Page({
|
||||
{
|
||||
if(this.data.params.order_id == temp_data_list[i]['id'])
|
||||
{
|
||||
this.pay_fun(this.data.params.order_id, 0);
|
||||
this.pay_handle(this.data.params.order_id, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -170,11 +170,11 @@ Page({
|
||||
pay_event(e, order_id, index) {
|
||||
var id = e.target.dataset.value;
|
||||
var index = e.target.dataset.index;
|
||||
this.pay_fun(id, index);
|
||||
this.pay_handle(id, index);
|
||||
},
|
||||
|
||||
// 支付方法
|
||||
pay_fun(order_id, index) {
|
||||
pay_handle(order_id, index) {
|
||||
// 加载loding
|
||||
my.showLoading({ content: "请求中..." });
|
||||
|
||||
@ -187,35 +187,42 @@ Page({
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
|
||||
if (res.data.code == 0) {
|
||||
my.tradePay({
|
||||
orderStr: res.data.data,
|
||||
success: res => {
|
||||
// 数据设置
|
||||
if (res.resultCode == "9000") {
|
||||
var temp_data_list = this.data.data_list;
|
||||
temp_data_list[index]["status"] = 2;
|
||||
temp_data_list[index]['status_text'] = '已支付';
|
||||
this.setData({ data_list: temp_data_list });
|
||||
}
|
||||
// 线下支付成功
|
||||
if (res.data.data.is_under_line == 1) {
|
||||
var temp_data_list = this.data.data_list;
|
||||
temp_data_list[index]["status"] = 2;
|
||||
temp_data_list[index]['status_name'] = '待发货';
|
||||
this.setData({ data_list: temp_data_list });
|
||||
} else {
|
||||
my.tradePay({
|
||||
orderStr: res.data.data.data,
|
||||
success: res => {
|
||||
// 数据设置
|
||||
if (res.resultCode == "9000") {
|
||||
var temp_data_list = this.data.data_list;
|
||||
temp_data_list[index]["status"] = 2;
|
||||
temp_data_list[index]['status_text'] = '待发货';
|
||||
this.setData({ data_list: temp_data_list });
|
||||
}
|
||||
|
||||
// 跳转支付页面
|
||||
my.navigateTo({
|
||||
url:
|
||||
"/pages/paytips/paytips?code=" +
|
||||
res.resultCode +
|
||||
"&result=" +
|
||||
res.result
|
||||
});
|
||||
},
|
||||
fail: res => {
|
||||
my.showToast({
|
||||
type: "fail",
|
||||
content: "唤起支付模块失败"
|
||||
});
|
||||
}
|
||||
});
|
||||
// 跳转支付页面
|
||||
my.navigateTo({
|
||||
url:
|
||||
"/pages/paytips/paytips?code=" +
|
||||
res.resultCode +
|
||||
"&result=" +
|
||||
res.result
|
||||
});
|
||||
},
|
||||
fail: res => {
|
||||
my.showToast({
|
||||
type: "fail",
|
||||
content: "唤起支付模块失败"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
my.showToast({
|
||||
type: "fail",
|
||||
|
@ -135,7 +135,7 @@ class PaymentController extends CommonController
|
||||
'is_enable' => 0,
|
||||
'is_open_user' => 0,
|
||||
'is_install' => 0,
|
||||
'apply_terminal'=> array_column(L('common_apply_terminal_list'), 'value'),
|
||||
'apply_terminal'=> array_column(L('common_platform_type'), 'value'),
|
||||
'config' => '',
|
||||
];
|
||||
}
|
||||
@ -181,7 +181,7 @@ class PaymentController extends CommonController
|
||||
$this->assign('data', $data);
|
||||
|
||||
// 适用平台
|
||||
$this->assign('common_apply_terminal_list', L('common_apply_terminal_list'));
|
||||
$this->assign('common_platform_type', L('common_platform_type'));
|
||||
|
||||
// 参数
|
||||
$this->assign('param', array_merge($_POST, $_GET));
|
||||
|
@ -30,6 +30,6 @@ return array(
|
||||
'role_edit_name' => '角色编辑',
|
||||
'power_icon_text' => '图标class',
|
||||
'power_icon_format' => '图标格式 0~30 个字符之间',
|
||||
'power_icon_tips' => '参考 [http://amazeui.org/css/icon]',
|
||||
'power_icon_tips' => '参考 http://www.iconfont.cn/ 将icon放到 [ /Public/Admin/Default/Css/IconfontMenu.css ] 文件中',
|
||||
);
|
||||
?>
|
@ -49,8 +49,8 @@
|
||||
<td>
|
||||
<if condition="!empty($v['apply_terminal'])">
|
||||
<foreach name="v.apply_terminal" key="terminal_k" item="terminal_v">
|
||||
{{:L('common_apply_terminal_list')[$terminal_v]['name']}}
|
||||
<if condition="$terminal_k LT count($v['apply_terminal'])-1">,</if>
|
||||
{{:L('common_platform_type')[$terminal_v]['name']}}
|
||||
<if condition="$terminal_k LT count($v['apply_terminal'])-1"><br /></if>
|
||||
</foreach>
|
||||
<else />
|
||||
<span class="cr-ddd">{{:L('common_on_fill_in_the_text')}}</span>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<div class="am-form-group">
|
||||
<label>{{:L('payment_apply_terminal_text')}}</label>
|
||||
<select name="apply_terminal" class="am-radius c-p chosen-select" multiple="multiple" minchecked="1" data-placeholder="{{:L('common_select_can_choose')}}" data-validation-message="{{:L('payment_apply_terminal_format')}}" required>
|
||||
<foreach name="common_apply_terminal_list" item="v">
|
||||
<foreach name="common_platform_type" item="v">
|
||||
<option value="{{$v.value}}" <if condition="isset($data['apply_terminal']) and in_array($v['value'], $data['apply_terminal'])">selected</if>>{{$v.name}}</option>
|
||||
</foreach>
|
||||
</select>
|
||||
|
@ -70,7 +70,7 @@
|
||||
<else />
|
||||
<label class="c-p m-l-20">
|
||||
</if>
|
||||
<span><if condition="!empty($v['icon'])"><span class="{{$v.icon}}"></span></if> {{$v.name}}</span>
|
||||
<span><if condition="!empty($v['icon'])"><span class="iconfont {{$v.icon}}"></span></if> {{$v.name}}</span>
|
||||
</label>
|
||||
<div class="fr m-r-20 list-submit">
|
||||
<span class="am-icon-edit am-icon-md c-p submit-edit <if condition="!empty($v['item'])">m-r-5</if>" data-am-modal="{target: '#power-save-win'}" data-json='{{:json_encode($v)}}' data-tag="power-save-win" data-item="<if condition="!empty($v['item'])">ok<else />no</if>"></span>
|
||||
@ -84,7 +84,7 @@
|
||||
<foreach name="v.item" item="vs">
|
||||
<li id="data-list-{{$vs.id}}" <if condition="$vs['is_show'] eq 0">class="bk-cr-ffd"</if>>
|
||||
<label class="c-p">
|
||||
<span><if condition="!empty($vs['icon'])"><span class="{{$vs.icon}}"></span></if> {{$vs.name}}</span>
|
||||
<span><if condition="!empty($vs['icon'])"><span class="iconfont {{$vs.icon}}"></span></if> {{$vs.name}}</span>
|
||||
</label>
|
||||
<div class="fr m-l-10 find-submit">
|
||||
<span class="am-icon-edit am-icon-sm c-p submit-edit" data-am-modal="{target: '#power-save-win'}" data-json='{{:json_encode($vs)}}' data-tag="power-save-win" data-item="no"></span>
|
||||
|
@ -62,14 +62,21 @@ class BuyController extends CommonController
|
||||
'address' => UserService::UserDefaultAddress(['user'=>$this->user])['data'],
|
||||
];
|
||||
|
||||
// 数据返回组装
|
||||
$express_list = ResourcesService::ExpressList(['is_enable'=>1, 'is_open_user'=>1]);
|
||||
// 支付方式
|
||||
$payment_list = ResourcesService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]);
|
||||
|
||||
// 扩展展示数据
|
||||
$extension_list = [
|
||||
// ['name'=>'感恩节9折', 'tips'=>'-¥23元'],
|
||||
// ['name'=>'运费', 'tips'=>'+¥10元'],
|
||||
];
|
||||
|
||||
// 数据返回组装
|
||||
$result = [
|
||||
'goods_list' => $ret['data'],
|
||||
'express_list' => $express_list,
|
||||
'payment_list' => $payment_list,
|
||||
'base' => $base,
|
||||
'extension_list' => $extension_list,
|
||||
];
|
||||
$this->ajaxReturn(L('common_operation_success'), 0, $result);
|
||||
} else {
|
||||
@ -78,248 +85,19 @@ class BuyController extends CommonController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户地址
|
||||
* 订单添加
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-07-20
|
||||
* @date 2018-09-25
|
||||
* @desc description
|
||||
*/
|
||||
private function GetBuyUserAddress()
|
||||
public function Add()
|
||||
{
|
||||
$where = ['user_id'=>$this->user['id'], 'is_delete_time'=>0];
|
||||
if(empty($this->data_post['address_id']))
|
||||
{
|
||||
$where['is_default'] = 1;
|
||||
} else {
|
||||
$where['id'] = intval($this->data_post['address_id']);
|
||||
}
|
||||
$data = M('UserAddress')->where($where)->find();
|
||||
if(!empty($data))
|
||||
{
|
||||
$data['province_name'] = ResourcesService::RegionName($data['province']);
|
||||
$data['city_name'] = ResourcesService::RegionName($data['city']);
|
||||
$data['county_name'] = ResourcesService::RegionName($data['county']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取清单商品
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-07-20
|
||||
* @desc description
|
||||
*/
|
||||
private function GetBuyGoods()
|
||||
{
|
||||
// 请求参数
|
||||
$params = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'goods',
|
||||
'error_msg' => '商品信息有误',
|
||||
]
|
||||
];
|
||||
$ret = params_checked($this->data_post, $params);
|
||||
if($ret !== true)
|
||||
{
|
||||
$this->ajaxReturn($ret);
|
||||
}
|
||||
|
||||
// 商品信息
|
||||
$data = json_decode($_POST['goods'], true);
|
||||
if(empty($data))
|
||||
{
|
||||
$this->ajaxReturn('商品信息有误');
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$total_price = 0;
|
||||
$m = M('Goods');
|
||||
$attr_type_m = M('GoodsAttributeType');
|
||||
$attr_m = M('GoodsAttribute');
|
||||
$image_host = C('IMAGE_HOST');
|
||||
foreach($data as $v)
|
||||
{
|
||||
$goods = $m->find($v['goods_id']);
|
||||
|
||||
// 基础判断
|
||||
if(empty($goods))
|
||||
{
|
||||
$this->ajaxReturn('['.$v['goods_id'].']商品不存在');
|
||||
}
|
||||
if($goods['is_shelves'] != 1)
|
||||
{
|
||||
$this->ajaxReturn('['.$v['goods_id'].']商品已下架');
|
||||
}
|
||||
if($v['buy_number'] > $goods['inventory'])
|
||||
{
|
||||
$this->ajaxReturn('['.$v['goods_id'].']商品超过库存数量['.$v['buy_number'].'>'.$goods['inventory'].']');
|
||||
}
|
||||
if($goods['buy_min_number'] > 1 && $v['buy_number'] < $goods['buy_min_number'])
|
||||
{
|
||||
$this->ajaxReturn('['.$v['goods_id'].']商品购买低于起购数量['.$v['buy_number'].'<'.$goods['buy_min_number'].']');
|
||||
}
|
||||
if($goods['buy_max_number'] > 1 && $v['buy_number'] > $goods['buy_max_number'])
|
||||
{
|
||||
$this->ajaxReturn('['.$v['goods_id'].']商品购买超过限购数量['.$v['buy_number'].'>'.$goods['buy_max_number'].']');
|
||||
}
|
||||
|
||||
// 属性
|
||||
$attribute_all = [];
|
||||
if(!empty($v['attribute']))
|
||||
{
|
||||
$attribute = explode(',', $v['attribute']);
|
||||
if(!empty($attribute))
|
||||
{
|
||||
foreach($attribute as $vs)
|
||||
{
|
||||
$attr = explode(':', $vs);
|
||||
if(empty($attr) || count($attr) < 2)
|
||||
{
|
||||
$this->ajaxReturn('['.$v['goods_id'].']商品属性有误-'.$vs);
|
||||
}
|
||||
|
||||
// 属性类型
|
||||
$attr_type = $attr_type_m->find($attr[0]);
|
||||
if(empty($attr_type))
|
||||
{
|
||||
$this->ajaxReturn('['.$v['goods_id'].']商品属性类型有误-'.$attr[0]);
|
||||
}
|
||||
|
||||
// 具体属性
|
||||
$attr_content = $attr_m->find($attr[1]);
|
||||
if(empty($attr_content))
|
||||
{
|
||||
$this->ajaxReturn('['.$v['goods_id'].']商品属性有误-'.$attr[1]);
|
||||
}
|
||||
|
||||
// 属性组装
|
||||
$attribute_all[] = $attr_type['name'].':'.$attr_content['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$goods['attribute'] = empty($attribute_all) ? '' : implode(',', $attribute_all);
|
||||
|
||||
|
||||
// 数据处理
|
||||
$goods['images_url'] = empty($goods['images']) ? null : $image_host.$goods['images'];
|
||||
$goods['buy_number'] = $v['buy_number'];
|
||||
|
||||
// 总价
|
||||
$total_price += $goods['price']*$v['buy_number'];
|
||||
|
||||
$result[] = $goods;
|
||||
}
|
||||
return [
|
||||
'goods' => $result,
|
||||
'total_price' => round($total_price, 2),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单提交
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-07-20
|
||||
* @desc description
|
||||
*/
|
||||
public function Submit()
|
||||
{
|
||||
// 清单商品
|
||||
$goods = $this->GetBuyGoods();
|
||||
|
||||
// 用户地址
|
||||
$address = $this->GetBuyUserAddress();
|
||||
if(empty($address))
|
||||
{
|
||||
$this->ajaxReturn('地址有误');
|
||||
}
|
||||
|
||||
// 优惠金额
|
||||
$preferential_price = 0.00;
|
||||
|
||||
// 店铺
|
||||
$shop_id = 0;
|
||||
|
||||
// 订单写入
|
||||
$order = [
|
||||
'user_id' => $this->user['id'],
|
||||
'shop_id' => $shop_id,
|
||||
'receive_address_id' => $address['id'],
|
||||
'receive_name' => $address['name'],
|
||||
'receive_tel' => $address['tel'],
|
||||
'receive_province' => $address['province'],
|
||||
'receive_city' => $address['city'],
|
||||
'receive_county' => $address['county'],
|
||||
'receive_address' => $address['address'],
|
||||
'user_note' => I('user_note'),
|
||||
'status' => 1,
|
||||
'preferential_price' => $preferential_price,
|
||||
'price' => $goods['total_price'],
|
||||
'total_price' => $goods['total_price']-$preferential_price,
|
||||
'add_time' => time(),
|
||||
'confirm_time' => time(),
|
||||
];
|
||||
|
||||
// 开始事务
|
||||
$m = M('Order');
|
||||
$m->startTrans();
|
||||
|
||||
// 订单添加
|
||||
$order_id = $m->add($order);
|
||||
if($order_id > 0)
|
||||
{
|
||||
$detail_m = M('OrderDetail');
|
||||
foreach($goods['goods'] as $v)
|
||||
{
|
||||
$detail = [
|
||||
'order_id' => $order_id,
|
||||
'user_id' => $this->user['id'],
|
||||
'shop_id' => $shop_id,
|
||||
'goods_id' => $v['id'],
|
||||
'title' => $v['title'],
|
||||
'images' => $v['images'],
|
||||
'original_price' => $v['original_price'],
|
||||
'price' => $v['price'],
|
||||
'attribute' => $v['attribute'],
|
||||
'buy_number' => $v['buy_number'],
|
||||
'add_time' => time(),
|
||||
];
|
||||
if($detail_m->add($detail) <= 0)
|
||||
{
|
||||
$m->rollback();
|
||||
$this->ajaxReturn('订单详情添加失败');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$m->rollback();
|
||||
$this->ajaxReturn('订单添加失败');
|
||||
}
|
||||
$m->commit();
|
||||
|
||||
// 获取订单信息
|
||||
$data = $m->find($order_id);
|
||||
switch($order['status'])
|
||||
{
|
||||
// 预约成功
|
||||
case 0 :
|
||||
$msg = L('common_booking_success');
|
||||
break;
|
||||
|
||||
// 提交成功
|
||||
case 1 :
|
||||
$msg = L('common_submit_success');
|
||||
break;
|
||||
|
||||
// 默认操作成功
|
||||
default :
|
||||
$msg = L('common_operation_success');
|
||||
}
|
||||
$this->ajaxReturn($msg, 0, $data);
|
||||
$params = $this->data_post;
|
||||
$params['user'] = $this->user;
|
||||
$ret = BuyService::OrderAdd($params);
|
||||
$this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
|
||||
}
|
||||
}
|
||||
?>
|
@ -100,6 +100,23 @@ class OrderController extends CommonController
|
||||
$this->ajaxReturn(L('common_not_data_tips'), -100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单支付
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-28
|
||||
* @desc description
|
||||
*/
|
||||
public function Pay()
|
||||
{
|
||||
$params = $this->data_post;
|
||||
$params['user'] = $this->user;
|
||||
$ret = OrderService::Pay($params);
|
||||
$this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [Cancel 订单取消]
|
||||
* @author Devil
|
||||
@ -170,53 +187,53 @@ class OrderController extends CommonController
|
||||
$this->ajaxReturn(L('common_confirm_error'));
|
||||
}
|
||||
|
||||
/**
|
||||
* [Pay 订单支付]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-07-22T22:10:46+0800
|
||||
*/
|
||||
public function Pay()
|
||||
{
|
||||
if(empty($this->data_post['id']))
|
||||
{
|
||||
$this->ajaxReturn('请选择订单');
|
||||
}
|
||||
// /**
|
||||
// * [Pay 订单支付]
|
||||
// * @author Devil
|
||||
// * @blog http://gong.gg/
|
||||
// * @version 1.0.0
|
||||
// * @datetime 2018-07-22T22:10:46+0800
|
||||
// */
|
||||
// public function Pay()
|
||||
// {
|
||||
// if(empty($this->data_post['id']))
|
||||
// {
|
||||
// $this->ajaxReturn('请选择订单');
|
||||
// }
|
||||
|
||||
$m = M('Order');
|
||||
$where = ['id'=>intval($this->data_post['id']), 'user_id' => $this->user['id']];
|
||||
$data = $m->where($where)->field('id,status,total_price')->find();
|
||||
if(empty($data))
|
||||
{
|
||||
$this->ajaxReturn(L('common_data_no_exist_error'));
|
||||
}
|
||||
if($data['total_price'] <= 0.00)
|
||||
{
|
||||
$this->ajaxReturn('金额不能为0');
|
||||
}
|
||||
if($data['status'] != 1)
|
||||
{
|
||||
$status_text = L('common_order_user_status')[$data['status']]['name'];
|
||||
$this->ajaxReturn('状态不可操作['.$status_text.']');
|
||||
}
|
||||
// $m = M('Order');
|
||||
// $where = ['id'=>intval($this->data_post['id']), 'user_id' => $this->user['id']];
|
||||
// $data = $m->where($where)->field('id,status,total_price')->find();
|
||||
// if(empty($data))
|
||||
// {
|
||||
// $this->ajaxReturn(L('common_data_no_exist_error'));
|
||||
// }
|
||||
// if($data['total_price'] <= 0.00)
|
||||
// {
|
||||
// $this->ajaxReturn('金额不能为0');
|
||||
// }
|
||||
// if($data['status'] != 1)
|
||||
// {
|
||||
// $status_text = L('common_order_user_status')[$data['status']]['name'];
|
||||
// $this->ajaxReturn('状态不可操作['.$status_text.']');
|
||||
// }
|
||||
|
||||
// 发起支付
|
||||
$notify_url = __MY_URL__.'Notify/order.php';
|
||||
$pay_data = array(
|
||||
'out_user' => md5($this->user['id']),
|
||||
'order_sn' => $data['id'].GetNumberCode(6),
|
||||
'name' => '订单支付',
|
||||
'total_price' => $data['total_price'],
|
||||
'notify_url' => $notify_url,
|
||||
);
|
||||
$pay = (new \Library\Alipay())->SoonPay($pay_data, C("alipay_key_secret"));
|
||||
if(empty($pay))
|
||||
{
|
||||
$this->ajaxReturn('支付接口异常');
|
||||
}
|
||||
$this->ajaxReturn(L('common_operation_success'), 0, $pay);
|
||||
}
|
||||
// // 发起支付
|
||||
// $notify_url = __MY_URL__.'Notify/order.php';
|
||||
// $pay_data = array(
|
||||
// 'out_user' => md5($this->user['id']),
|
||||
// 'order_sn' => $data['id'].GetNumberCode(6),
|
||||
// 'name' => '订单支付',
|
||||
// 'total_price' => $data['total_price'],
|
||||
// 'notify_url' => $notify_url,
|
||||
// );
|
||||
// $pay = (new \Library\Alipay())->SoonPay($pay_data, C("alipay_key_secret"));
|
||||
// if(empty($pay))
|
||||
// {
|
||||
// $this->ajaxReturn('支付接口异常');
|
||||
// }
|
||||
// $this->ajaxReturn(L('common_operation_success'), 0, $pay);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 确认
|
||||
|
@ -511,13 +511,6 @@ return array(
|
||||
2 => array('id' => 2, 'name' => '禁止登录', 'tips' => '用户被禁止登录'),
|
||||
),
|
||||
|
||||
// 适用终端
|
||||
'common_apply_terminal_list' => array(
|
||||
'pc' => array('value' => 'pc', 'name' => '电脑端'),
|
||||
'wap' => array('value' => 'wap', 'name' => 'WAP手机端'),
|
||||
'app' => array('value' => 'app', 'name' => 'APP手机端'),
|
||||
),
|
||||
|
||||
// 是否已评价
|
||||
'common_comments_status_list' => array(
|
||||
0 => array('value' => 0, 'name' => '待评价'),
|
||||
|
@ -56,9 +56,6 @@ class BuyController extends CommonController
|
||||
// 用户地址
|
||||
$this->assign('user_address_list', UserService::UserAddressList(['user'=>$this->user])['data']);
|
||||
|
||||
// 快递
|
||||
$this->assign('express_list', ResourcesService::ExpressList(['is_enable'=>1, 'is_open_user'=>1]));
|
||||
|
||||
// 支付方式
|
||||
$this->assign('payment_list', ResourcesService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]));
|
||||
|
||||
|
@ -70,27 +70,6 @@
|
||||
</empty>
|
||||
</div>
|
||||
|
||||
<!-- 物流 -->
|
||||
<div class="business-item logistics" data-type="logistics">
|
||||
<h3>选择快递</h3>
|
||||
<notempty name="express_list">
|
||||
<ul class="logistics-list">
|
||||
<foreach name="express_list" item="express">
|
||||
<li data-value="{{$express.id}}">
|
||||
<notempty name="express.icon">
|
||||
<img src="{{$express.icon}}" />
|
||||
</notempty>
|
||||
<span>{{$express.name}}</span>
|
||||
<i class="icon-active"></i>
|
||||
</li>
|
||||
</foreach>
|
||||
</ul>
|
||||
</notempty>
|
||||
<empty name="express_list">
|
||||
<div class="table-no"><i class="am-icon-warning"></i> {{:L('buy_express_not_data_tips')}}</div>
|
||||
</empty>
|
||||
</div>
|
||||
|
||||
<!-- 支付方式 -->
|
||||
<div class="business-item payment" data-type="payment">
|
||||
<h3>选择支付</h3>
|
||||
@ -243,7 +222,6 @@
|
||||
<input type="hidden" name="attr" value='<if condition="isset($params['attr'])">{{$params.attr}}</if>' />
|
||||
<input type="hidden" name="ids" value="<if condition="isset($params['ids'])">{{$params.ids}}</if>" />
|
||||
<input type="hidden" name="address_id" value="0" />
|
||||
<input type="hidden" name="express_id" value="0" />
|
||||
<input type="hidden" name="payment_id" value="0" />
|
||||
<input type="hidden" name="user_note" value="" />
|
||||
<div class="go-btn-wrap">
|
||||
|
325
service/Application/Library/Payment/AlipayMini.class.php
Normal file
325
service/Application/Library/Payment/AlipayMini.class.php
Normal file
@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
namespace Library\Payment;
|
||||
|
||||
/**
|
||||
* 支付宝小程序支付
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
*/
|
||||
class AlipayMini
|
||||
{
|
||||
// 插件配置参数
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数(支付配置参数)]
|
||||
*/
|
||||
public function __construct($params = [])
|
||||
{
|
||||
$this->config = $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
*/
|
||||
public function Config()
|
||||
{
|
||||
// 基础信息
|
||||
$base = [
|
||||
'name' => '支付宝', // 插件名称
|
||||
'version' => '0.0.1', // 插件版本
|
||||
'apply_version' => '不限', // 适用系统版本描述
|
||||
'desc' => '即时到帐支付方式,买家的交易资金直接打入卖家支付宝账户,快速回笼交易资金。 <a href="http://www.alipay.com/" target="_blank">立即申请</a>', // 插件描述(支持html)
|
||||
'author' => 'Devil', // 开发者
|
||||
'author_url' => 'http://shopxo.net/', // 开发者主页
|
||||
];
|
||||
|
||||
// 配置信息
|
||||
$element = [
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'appid',
|
||||
'placeholder' => 'appid',
|
||||
'title' => 'appid',
|
||||
'is_required' => 1,
|
||||
'message' => '请填写小程序appid',
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'account',
|
||||
'placeholder' => '支付宝账号',
|
||||
'title' => '支付宝账号',
|
||||
'is_required' => 1,
|
||||
'message' => '请填写支付宝账号',
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'partner',
|
||||
'placeholder' => '合作者身份 partner ID',
|
||||
'title' => '合作者身份 partner ID',
|
||||
'is_required' => 1,
|
||||
'message' => '请填写合作者身份 partner ID',
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'key',
|
||||
'placeholder' => '交易安全校验码 key',
|
||||
'title' => '交易安全校验码 key',
|
||||
'is_required' => 1,
|
||||
'message' => '请填写交易安全校验码 key',
|
||||
],
|
||||
[
|
||||
'element' => 'textarea',
|
||||
'name' => 'rsa_public',
|
||||
'placeholder' => '应用公钥',
|
||||
'title' => '应用公钥',
|
||||
'is_required' => 1,
|
||||
'rows' => 6,
|
||||
],
|
||||
[
|
||||
'element' => 'textarea',
|
||||
'name' => 'rsa_private',
|
||||
'placeholder' => '应用私钥',
|
||||
'title' => '应用私钥',
|
||||
'is_required' => 1,
|
||||
'rows' => 6,
|
||||
],
|
||||
[
|
||||
'element' => 'textarea',
|
||||
'name' => 'out_rsa_public',
|
||||
'placeholder' => '支付宝公钥',
|
||||
'title' => '支付宝公钥',
|
||||
'is_required' => 1,
|
||||
'rows' => 6,
|
||||
],
|
||||
];
|
||||
|
||||
return [
|
||||
'base' => $base,
|
||||
'element' => $element,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付入口
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function Pay($params = [])
|
||||
{
|
||||
$parameter = array(
|
||||
'app_id' => $this->config['appid'],
|
||||
'method' => 'alipay.trade.app.pay',
|
||||
'format' => 'JSON',
|
||||
'charset' => 'utf-8',
|
||||
'sign_type' => 'RSA2',
|
||||
'timestamp' => date('Y-m-d H:i:s'),
|
||||
'version' => '1.0',
|
||||
'notify_url' => $params['notify_url'],
|
||||
);
|
||||
$biz_content = array(
|
||||
'subject' => $params['name'],
|
||||
'out_trade_no' => $params['order_no'],
|
||||
'total_amount' => $params['total_price'],
|
||||
'product_code' => 'QUICK_MSECURITY_PAY',
|
||||
);
|
||||
$parameter['biz_content'] = json_encode($biz_content, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
// 生成签名参数+签名
|
||||
$params = $this->GetParamSign($parameter);
|
||||
$params['param'] .= '&sign='.urlencode($this->MyRsaSign($params['value']));
|
||||
|
||||
// 直接返回支付信息
|
||||
return DataReturn('处理成功', 0, $params['param']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付回调处理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function Respond($params = [])
|
||||
{
|
||||
$data = empty($_POST) ? $_GET : array_merge($_GET, $_POST);
|
||||
ksort($data);
|
||||
|
||||
// 参数字符串
|
||||
foreach($data AS $key=>$val)
|
||||
{
|
||||
if ($key != 'sign' && $key != 'sign_type' && $key != 'code')
|
||||
{
|
||||
$sign .= "$key=$val&";
|
||||
}
|
||||
}
|
||||
$sign = substr($sign, 0, -1);
|
||||
|
||||
// 签名
|
||||
if(!$this->OutRsaVerify($sign, $data['sign']))
|
||||
{
|
||||
return DataReturn('签名校验失败', -1);
|
||||
}
|
||||
|
||||
// 支付状态
|
||||
$status = isset($data['trade_status']) ? $data['trade_status'] : $data['result'];
|
||||
switch($status)
|
||||
{
|
||||
case 'TRADE_SUCCESS':
|
||||
case 'TRADE_FINISHED':
|
||||
case 'success':
|
||||
return DataReturn('支付成功', 0, $this->ReturnData($data));
|
||||
break;
|
||||
}
|
||||
return DataReturn('处理异常错误', -100);
|
||||
}
|
||||
|
||||
/**
|
||||
* [ReturnData 返回数据统一格式]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-10-06T16:54:24+0800
|
||||
* @param [array] $data [返回数据]
|
||||
*/
|
||||
private function ReturnData($data)
|
||||
{
|
||||
// 兼容web版本支付参数
|
||||
$buyer_user = isset($data['buyer_logon_id']) ? $data['buyer_logon_id'] : (isset($data['buyer_email']) ? $data['buyer_email'] : '');
|
||||
$pay_price = isset($data['total_amount']) ? $data['total_amount'] : (isset($data['total_fee']) ? $data['total_fee'] : '');
|
||||
|
||||
// 返回数据固定基础参数
|
||||
$data['trade_no'] = $data['trade_no']; // 支付平台 - 订单号
|
||||
$data['buyer_user'] = $buyer_user; // 支付平台 - 用户
|
||||
$data['out_trade_no'] = $data['out_trade_no']; // 本系统发起支付的 - 订单号
|
||||
$data['subject'] = $data['subject']; // 本系统发起支付的 - 商品名称
|
||||
$data['pay_price'] = $pay_price; // 本系统发起支付的 - 总价
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* [GetParamSign 生成参数和签名]
|
||||
* @param [array] $data [待生成的参数]
|
||||
* @return [array] [生成好的参数和签名]
|
||||
*/
|
||||
private function GetParamSign($data)
|
||||
{
|
||||
$param = '';
|
||||
$sign = '';
|
||||
ksort($data);
|
||||
|
||||
foreach($data AS $key => $val)
|
||||
{
|
||||
$param .= "$key=" .urlencode($val). "&";
|
||||
$sign .= "$key=$val&";
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'param' => substr($param, 0, -1),
|
||||
'value' => substr($sign, 0, -1),
|
||||
);
|
||||
$result['sign'] = $result['value'].$this->config['key'];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* [MyRsaSign 签名字符串]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2017-09-24T08:38:28+0800
|
||||
* @param [string] $prestr [需要签名的字符串]
|
||||
* @return [string] [签名结果]
|
||||
*/
|
||||
private function MyRsaSign($prestr)
|
||||
{
|
||||
$res = "-----BEGIN RSA PRIVATE KEY-----\n";
|
||||
$res .= wordwrap($this->config['rsa_private'], 64, "\n", true);
|
||||
$res .= "\n-----END RSA PRIVATE KEY-----";
|
||||
return openssl_sign($prestr, $sign, $res, OPENSSL_ALGO_SHA256) ? base64_encode($sign) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* [MyRsaDecrypt RSA解密]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2017-09-24T09:12:06+0800
|
||||
* @param [string] $content [需要解密的内容,密文]
|
||||
* @return [string] [解密后内容,明文]
|
||||
*/
|
||||
private function MyRsaDecrypt($content)
|
||||
{
|
||||
$res = "-----BEGIN PUBLIC KEY-----\n";
|
||||
$res .= wordwrap($this->config['rsa_public'], 64, "\n", true);
|
||||
$res .= "\n-----END PUBLIC KEY-----";
|
||||
$res = openssl_get_privatekey($res);
|
||||
$content = base64_decode($content);
|
||||
$result = '';
|
||||
for($i=0; $i<strlen($content)/128; $i++)
|
||||
{
|
||||
$data = substr($content, $i * 128, 128);
|
||||
openssl_private_decrypt($data, $decrypt, $res, OPENSSL_ALGO_SHA256);
|
||||
$result .= $decrypt;
|
||||
}
|
||||
openssl_free_key($res);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* [OutRsaVerify 支付宝验证签名]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2017-09-24T08:39:50+0800
|
||||
* @param [string] $prestr [需要签名的字符串]
|
||||
* @param [string] $sign [签名结果]
|
||||
* @return [boolean] [正确true, 错误false]
|
||||
*/
|
||||
private function OutRsaVerify($prestr, $sign)
|
||||
{
|
||||
$res = "-----BEGIN PUBLIC KEY-----\n";
|
||||
$res .= wordwrap($this->config['out_rsa_public'], 64, "\n", true);
|
||||
$res .= "\n-----END PUBLIC KEY-----";
|
||||
$pkeyid = openssl_pkey_get_public($res);
|
||||
$sign = base64_decode($sign);
|
||||
if($pkeyid)
|
||||
{
|
||||
$verify = openssl_verify($prestr, $sign, $pkeyid, OPENSSL_ALGO_SHA256);
|
||||
openssl_free_key($pkeyid);
|
||||
}
|
||||
return (isset($verify) && $verify == 1) ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -46,7 +46,7 @@ class CashPayment
|
||||
'apply_version' => '不限', // 适用系统版本描述
|
||||
'desc' => '现金方式支付货款', // 插件描述(支持html)
|
||||
'author' => 'Devil', // 开发者
|
||||
'author_url' => 'http://gong.gg/', // 开发者主页
|
||||
'author_url' => 'http://shopxo.net/', // 开发者主页
|
||||
];
|
||||
|
||||
// 配置信息
|
||||
|
@ -46,7 +46,7 @@ class DeliveryPayment
|
||||
'apply_version' => '不限', // 适用系统版本描述
|
||||
'desc' => '送货上门后收取货款', // 插件描述(支持html)
|
||||
'author' => 'Devil', // 开发者
|
||||
'author_url' => 'http://gong.gg/', // 开发者主页
|
||||
'author_url' => 'http://shopxo.net/', // 开发者主页
|
||||
];
|
||||
|
||||
// 配置信息
|
||||
|
@ -549,11 +549,6 @@ class BuyService
|
||||
'key_name' => 'address_id',
|
||||
'error_msg' => '地址有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'express_id',
|
||||
'error_msg' => '快递有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'payment_id',
|
||||
@ -608,7 +603,6 @@ class BuyService
|
||||
'preferential_price' => $preferential_price,
|
||||
'price' => $check['data']['total_price'],
|
||||
'total_price' => $check['data']['total_price']-$preferential_price,
|
||||
'express_id' => intval($params['express_id']),
|
||||
'payment_id' => intval($params['payment_id']),
|
||||
'add_time' => time(),
|
||||
];
|
||||
|
@ -87,12 +87,25 @@ class OrderService
|
||||
{
|
||||
// 非线上支付处理
|
||||
$params['user']['user_name_view'] = '用户-'.$params['user']['user_name_view'];
|
||||
self::OrderPaymentUnderLine([
|
||||
$pay_result = self::OrderPaymentUnderLine([
|
||||
'order' => $order,
|
||||
'payment' => $payment[0],
|
||||
'user' => $params['user'],
|
||||
'subject' => $params,
|
||||
]);
|
||||
if($pay_result['code'] != 0)
|
||||
{
|
||||
return $pay_result;
|
||||
}
|
||||
|
||||
// 支付信息返回
|
||||
$ret['data'] = [
|
||||
// 是否为线下支付类型
|
||||
'is_under_line' => in_array($payment[0]['payment'], C('under_line_list')) ? 1 : 0,
|
||||
|
||||
// 支付模块处理数据
|
||||
'data' => $ret['data'],
|
||||
];
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -124,31 +124,9 @@ class ResourcesService
|
||||
foreach($data as $v)
|
||||
{
|
||||
// 根据终端类型筛选
|
||||
switch(APPLICATION)
|
||||
if(in_array(APPLICATION_CLIENT_TYPE, $v['apply_terminal']))
|
||||
{
|
||||
// pc, wap
|
||||
case 'web' :
|
||||
if(IsMobile())
|
||||
{
|
||||
if(in_array('wap', $v['apply_terminal']))
|
||||
{
|
||||
$result[] = $v;
|
||||
}
|
||||
} else {
|
||||
if(in_array('pc', $v['apply_terminal']))
|
||||
{
|
||||
$result[] = $v;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// app
|
||||
case 'app' :
|
||||
if(in_array('app', $v['apply_terminal']))
|
||||
{
|
||||
$result[] = $v;
|
||||
}
|
||||
break;
|
||||
$result[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -4,6 +4,7 @@
|
||||
table.am-table .th-desc { width: 20%; }
|
||||
table.am-table .td-desc, table.am-table .td-version { font-size: 12px; }
|
||||
table.am-table .td-version { color: #d2364c; margin: 0; }
|
||||
.am-form-file input[type="file"] { margin-top: 0; }
|
||||
|
||||
/**
|
||||
* 插件部分
|
||||
|
@ -7,15 +7,11 @@ $(function()
|
||||
$('form.delivery-form input[name=express_number]').val('');
|
||||
var express_id = $(this).data('express-id') || 0;
|
||||
var user_id = $(this).data('user-id') || 0;
|
||||
if($('.express-items-'+express_id).length > 0)
|
||||
{
|
||||
$('form.delivery-form input[name=express_id]').val(express_id);
|
||||
$('form.delivery-form input[name=user_id]').val(user_id);
|
||||
$('form.delivery-form input[name=express_id]').val(express_id);
|
||||
$('form.delivery-form input[name=user_id]').val(user_id);
|
||||
$('ul.express-list li.selected').removeClass('selected');
|
||||
if(express_id != 0) {
|
||||
$('.express-items-'+express_id).addClass('selected').siblings('li').removeClass('selected');
|
||||
} else {
|
||||
$('form.delivery-form input[name=express_id]').val(0);
|
||||
$('form.delivery-form input[name=user_id]').val(0);
|
||||
$('ul.express-list li.selected').removeClass('selected');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -3,7 +3,6 @@ if(store.enabled)
|
||||
// 选择缓存key
|
||||
var store_address_key = 'store-buy-address-selected-index';
|
||||
var store_use_new_address_status_key = 'store-buy-use-new-address-status-count';
|
||||
var store_logistics_key = 'store-lbuy-ogistics-selected-index';
|
||||
var store_payment_key = 'store-buy-payment-selected-index';
|
||||
}
|
||||
|
||||
@ -30,13 +29,7 @@ $(function()
|
||||
{
|
||||
$('ul.address-list li').eq(store_address_value).addClass('address-default').siblings().removeClass('address-default');
|
||||
}
|
||||
// 快递
|
||||
var store_logistics_value = store.get(store_logistics_key);
|
||||
if(store_logistics_value !== undefined)
|
||||
{
|
||||
$('ul.logistics-list li').eq(store_logistics_value).addClass('selected');
|
||||
}
|
||||
// 快递
|
||||
// 支付方式
|
||||
var store_payment_value = store.get(store_payment_key);
|
||||
if(store_payment_value !== undefined)
|
||||
{
|
||||
@ -67,10 +60,6 @@ $(function()
|
||||
case 'payment' :
|
||||
temp_store_key = store_payment_key;
|
||||
break;
|
||||
|
||||
case 'logistics' :
|
||||
temp_store_key = store_logistics_key;
|
||||
break;
|
||||
}
|
||||
if ($(this).hasClass('selected')) {
|
||||
$(this).removeClass('selected');
|
||||
@ -146,16 +135,6 @@ $(function()
|
||||
msg = '请选择地址';
|
||||
}
|
||||
|
||||
if(status === true)
|
||||
{
|
||||
var express_id = $('ul.logistics-list li.selected').data('value') || null;
|
||||
if(express_id === null)
|
||||
{
|
||||
status = false;
|
||||
msg = '请选择快递';
|
||||
}
|
||||
}
|
||||
|
||||
if(status === true)
|
||||
{
|
||||
var payment_id = $('ul.payment-list li.selected').data('value') || null;
|
||||
@ -178,7 +157,6 @@ $(function()
|
||||
}
|
||||
|
||||
$('form.nav-buy input[name=address_id]').val(address_id);
|
||||
$('form.nav-buy input[name=express_id]').val(express_id);
|
||||
$('form.nav-buy input[name=payment_id]').val(payment_id);
|
||||
$('form.nav-buy input[name=user_note]').val($('.order-user-info input.memo-input').val());
|
||||
});
|
||||
|
@ -60,7 +60,7 @@ define('APPLICATION', empty($_REQUEST['application']) ? 'web' : trim($_REQUEST['
|
||||
// 请求客户端 [default, ...] 默认default
|
||||
define('APPLICATION_CLIENT', empty($_REQUEST['application_client']) ? 'default' : trim($_REQUEST['application_client']));
|
||||
|
||||
// 请求客户端 [pc, h5, alipay, wechat] 默认pc
|
||||
// 请求客户端 [pc, wap/h5, alipay, wechat, baidu] 默认pc
|
||||
define('APPLICATION_CLIENT_TYPE', empty($_REQUEST['application_client_type']) ? 'pc' : trim($_REQUEST['application_client_type']));
|
||||
|
||||
?>
|
21
service/payment_order_alipaymini_notify.php
Normal file
21
service/payment_order_alipaymini_notify.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 订单支付异步入口
|
||||
*/
|
||||
|
||||
// 默认绑定模块
|
||||
$_GET['m'] = 'Api';
|
||||
$_GET['c'] = 'OrderNotify';
|
||||
$_GET['a'] = 'Notify';
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', 'AlipayMini');
|
||||
|
||||
// 引入公共入口文件
|
||||
require './core.php';
|
||||
|
||||
// 引入ThinkPHP入口文件
|
||||
require './ThinkPHP/ThinkPHP.php';
|
||||
|
||||
?>
|
21
service/payment_order_alipaymini_respond.php
Normal file
21
service/payment_order_alipaymini_respond.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 订单支付同步入口
|
||||
*/
|
||||
|
||||
// 默认绑定模块
|
||||
$_GET['m'] = 'Home';
|
||||
$_GET['c'] = 'Order';
|
||||
$_GET['a'] = 'Respond';
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', 'AlipayMini');
|
||||
|
||||
// 引入公共入口文件
|
||||
require './core.php';
|
||||
|
||||
// 引入ThinkPHP入口文件
|
||||
require './ThinkPHP/ThinkPHP.php';
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user