切换导航条
此项目
正在载入...
登录
景龙
/
feifangu
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
jinglong
5 years ago
提交
9d06e34a4382289d6225eca503bf4ae1dc89fddf
1 个父辈
cfd52089
master
1 个管道 的构建
通过
耗费 6 秒
修改退款逻辑
变更
2
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
48 行增加
和
23 行删除
application/admin/controller/Order.php
application/api/controller/Common.php
application/admin/controller/Order.php
查看文件 @
9d06e34
...
...
@@ -2,6 +2,7 @@
namespace
app\admin\controller
;
use
app\api\controller\Common
;
use
app\common\controller\Backend
;
use
think\Db
;
use
EasyWeChat\Factory
;
...
...
@@ -126,32 +127,47 @@ class Order extends Backend
$pk
=
$this
->
model
->
getPk
();
$res
=
Db
::
name
(
'order'
)
->
where
(
$pk
,
$ids
)
->
field
(
'id,pay_order_sn,total_goods_price'
)
->
find
();
$status
=
config
(
'verify.status'
);
$res1
=
$this
->
model
->
where
(
$pk
,
'='
,
$ids
)
->
update
([
'status'
=>
$status
[
4
]]);
if
(
$res1
){
//处理退款逻辑
$config
=
config
(
'verify.wx_pay'
);
$app
=
Factory
::
payment
(
$config
);
// $security_price = $res['total_goods_price']*100;
$security_price
=
1
;
$refundNumber
=
$this
->
genPayOrderSn
(
'refund'
);
//商户退款单号
$result
=
$app
->
refund
->
byOutTradeNumber
(
$res
[
'pay_order_sn'
],
$refundNumber
,
$security_price
,
$security_price
,
[
// 可在此处传入其他参数,详细参数见微信支付文档
]);
if
(
$result
[
'return_code'
]
===
'SUCCESS'
&&
$result
[
'result_code'
]
===
'SUCCESS'
){
$this
->
model
->
where
(
$pk
,
'='
,
$ids
)
->
update
([
'status'
=>
$status
[
4
]]);
//增加库存
$res1
=
Db
::
name
(
'ogoods'
)
->
where
([
'o_id'
=>
$res
[
'id'
]])
->
field
(
'id,g_id,style,goods_number'
)
->
select
();
$g_ids
=
array_column
(
$res1
,
'g_id'
);
$res_stock
=
Common
::
selectSoftWhereData
(
'goods'
,[
'id'
=>
[
'in'
,
$g_ids
]],
'id,style g_style,stock'
);
$goodsModel
=
new
\app\admin\model\Goods
();
foreach
(
$res_stock
as
$g_value
){
$arr_stock
=
explode
(
'|'
,
$g_value
[
'stock'
]);
$sale_number
=
1
;
foreach
(
$res1
as
$value
){
if
(
$g_value
[
'id'
]
==
$value
[
'g_id'
]){
$s_index
=
array_search
(
$value
[
'style'
],
Common
::
salePrice
(
$g_value
[
'g_style'
]));
$stock
=
Common
::
salePrice
(
$g_value
[
'stock'
])[
$s_index
]
+
$value
[
'goods_number'
];
$arr_stock
[
$s_index
]
=
$stock
;
$sale_number
=
$value
[
'goods_number'
];
}
}
//更新增加库存
$stock1
=
implode
(
'|'
,
$arr_stock
);
$goodsModel
->
where
([
'id'
=>
$g_value
[
'id'
]])
->
update
([
'stock'
=>
$stock1
]);
//减少销售
Common
::
decSales
([
'id'
=>
[
'in'
,
$g_ids
]],
$sale_number
);
}
$this
->
success
(
'成功'
);
}
else
{
$this
->
error
(
'失败'
);
$this
->
error
(
'
退款
失败'
);
}
//处理退款逻辑
// $config = config('verify.wx_pay');
// $app = Factory::payment($config);
// $security_price = $res['total_goods_price']*100;
// $refundNumber = $this->genPayOrderSn('refund');//商户退款单号
// $result = $app->refund->byOutTradeNumber($res['pay_order_sn'], $refundNumber, $security_price, $security_price, [
// // 可在此处传入其他参数,详细参数见微信支付文档
// ]);
// if($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS'){
// $this->model->where($pk, '=', $ids)->update(['status'=>$status[4]]);
//
// //增加库存
// $res2 = Db::name('ogoods')->where(['o_id'=>$res['id']])->field('id,g_id')->select();
// $g_ids = array_column($res2,'g_id');
// $goodsModel = new \app\admin\model\Goods();
// $goodsModel->where(['id'=>['in',$g_ids]])->setInc('stock',1);
// $this->success('成功');
// }else{
// $this->error('退款失败');
// }
}
$this
->
error
(
__
(
'Parameter %s can not be empty'
,
'ids'
));
...
...
application/api/controller/Common.php
查看文件 @
9d06e34
...
...
@@ -550,6 +550,15 @@ class Common
}
/**
* 减少销量
* @ApiInternal
*/
public
static
function
decSales
(
$where
,
$sale_number
){
$goodsModel
=
new
\app\admin\model\Goods
();
$goodsModel
->
where
(
$where
)
->
setDec
(
'sales'
,
$sale_number
);
}
/**
* 删购物车
* @ApiInternal
*/
...
...
请
注册
或
登录
后发表评论