修改退款
This commit is contained in:
parent
d40cb1cc9c
commit
fd17b847ad
@ -11,6 +11,7 @@ use app\components\YopointApi;
|
|||||||
use app\models\BallCart;
|
use app\models\BallCart;
|
||||||
use app\models\BallMark;
|
use app\models\BallMark;
|
||||||
use app\models\Order;
|
use app\models\Order;
|
||||||
|
use app\models\Signing;
|
||||||
use app\models\YopointNotify;
|
use app\models\YopointNotify;
|
||||||
use app\modules\api\components\Mqtt;
|
use app\modules\api\components\Mqtt;
|
||||||
use yii\console\Controller;
|
use yii\console\Controller;
|
||||||
@ -38,25 +39,47 @@ class Script1minController extends Controller
|
|||||||
{
|
{
|
||||||
$redis_name = "cxaibc:console:script1min_lock";
|
$redis_name = "cxaibc:console:script1min_lock";
|
||||||
try {
|
try {
|
||||||
$get = \Yii::$app->redis->setnx($redis_name,1);
|
$get = \Yii::$app->redis->setnx($redis_name, 1);
|
||||||
if(empty($get)){
|
if (empty($get)) {
|
||||||
$ttl = \Yii::$app->redis->ttl($redis_name);
|
$ttl = \Yii::$app->redis->ttl($redis_name);
|
||||||
if($ttl === -1){
|
if ($ttl === -1) {
|
||||||
\Yii::$app->redis->expire($redis_name,60);
|
\Yii::$app->redis->expire($redis_name, 60);
|
||||||
}
|
}
|
||||||
var_dump("1分钟脚本正在执行中");
|
var_dump("1分钟脚本正在执行中");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
\Yii::$app->redis->expire($redis_name,60*10);
|
\Yii::$app->redis->expire($redis_name, 60 * 10);
|
||||||
// 执行体
|
// 执行体
|
||||||
$this->YopointPayCall();
|
$this->signingCancel();
|
||||||
// 结束执行
|
// 结束执行
|
||||||
\Yii::$app->redis->del($redis_name);
|
\Yii::$app->redis->del($redis_name);
|
||||||
}catch (\Exception $e){
|
} catch (\Exception $e) {
|
||||||
\Yii::$app->redis->del($redis_name);
|
\Yii::$app->redis->del($redis_name);
|
||||||
var_dump($e->getMessage());
|
var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
echo "1分钟脚本";
|
echo "1分钟脚本";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function signingCancel()
|
||||||
|
{
|
||||||
|
$signings = Signing::find()->where(['status' => '0'])->all();
|
||||||
|
|
||||||
|
foreach ($signings as $item) {
|
||||||
|
|
||||||
|
$time = time() - $item->create_time;
|
||||||
|
|
||||||
|
if ($time > 600) {
|
||||||
|
$signing = Signing::findOne($item->id);
|
||||||
|
$signing->status = 4;
|
||||||
|
$signing->reason = '超时未支付';
|
||||||
|
$signing->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class TongLianPay
|
|||||||
'cusid' => $this->cusid,
|
'cusid' => $this->cusid,
|
||||||
'appid' => $this->appid,
|
'appid' => $this->appid,
|
||||||
'version' => '11',
|
'version' => '11',
|
||||||
'trxamt' => $signing->moy * 100,
|
'trxamt' => $signing->moy * 100,
|
||||||
'reqsn' => $signing->order_no,
|
'reqsn' => $signing->order_no,
|
||||||
'paytype' => 'W06',
|
'paytype' => 'W06',
|
||||||
'randomstr' => date('dHis') . rand(1000000, 9999999),
|
'randomstr' => date('dHis') . rand(1000000, 9999999),
|
||||||
@ -70,7 +70,7 @@ class TongLianPay
|
|||||||
return $signing->save();
|
return $signing->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refund($signingId)
|
public function refund($signingId, $reason)
|
||||||
{
|
{
|
||||||
$signing = Signing::findOne($signingId);
|
$signing = Signing::findOne($signingId);
|
||||||
|
|
||||||
@ -82,6 +82,7 @@ class TongLianPay
|
|||||||
'trxamt' => $signing->moy * 100,
|
'trxamt' => $signing->moy * 100,
|
||||||
'reqsn' => date('YmdH') . rand(10000, 99999),
|
'reqsn' => date('YmdH') . rand(10000, 99999),
|
||||||
'oldtrxid' => $signing->trxid,
|
'oldtrxid' => $signing->trxid,
|
||||||
|
'oldreqsn' => $signing->order_no,
|
||||||
'randomstr' => date('YmdH') . rand(10000, 99999),
|
'randomstr' => date('YmdH') . rand(10000, 99999),
|
||||||
'signtype' => 'RSA',
|
'signtype' => 'RSA',
|
||||||
];
|
];
|
||||||
@ -96,13 +97,16 @@ class TongLianPay
|
|||||||
|
|
||||||
if ($result['trxstatus'] == '0000') {
|
if ($result['trxstatus'] == '0000') {
|
||||||
|
|
||||||
$signing->status = 2;
|
$signing->status = 3;
|
||||||
|
|
||||||
|
$signing->reason = $reason;
|
||||||
|
|
||||||
$signing->save();
|
$signing->save();
|
||||||
|
|
||||||
return $this->apiReturnSuccess('操作成功');
|
return $this->apiReturnSuccess('操作成功');
|
||||||
}
|
}
|
||||||
return $this->apiReturnError($result['errmsg']);
|
|
||||||
|
return $this->apiReturnError($result['errmsg'], $result);
|
||||||
}
|
}
|
||||||
return $this->apiReturnError('订单异常');
|
return $this->apiReturnError('订单异常');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,15 +39,28 @@ class SigningController extends Controller
|
|||||||
|
|
||||||
public function actionRefund()
|
public function actionRefund()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (\Yii::$app->request->isAjax) {
|
if (\Yii::$app->request->isAjax) {
|
||||||
|
|
||||||
$tongLianPay = new TongLianPay();
|
$tongLianPay = new TongLianPay();
|
||||||
|
|
||||||
return $this->responseHandler($tongLianPay->refund(\Yii::$app->request->post('id')));
|
return $this->responseHandler($tongLianPay->refund(\Yii::$app->request->post('id'), \Yii::$app->request->post('reason')));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionSigning()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (\Yii::$app->request->isAjax) {
|
||||||
|
|
||||||
|
$signingForm = new SigningForm();
|
||||||
|
|
||||||
|
$signingForm->attributes = \Yii::$app->request->post();
|
||||||
|
|
||||||
|
return $this->responseHandler($signingForm->signing());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,11 +18,13 @@ class SigningForm extends AdminModel
|
|||||||
|
|
||||||
public $status;
|
public $status;
|
||||||
|
|
||||||
|
public $id;
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['order_no'], 'string'],
|
[['order_no'], 'string'],
|
||||||
[['page', 'limit', 'status'], 'integer'],
|
[['page', 'limit', 'status', 'id'], 'integer'],
|
||||||
[['page'], 'default', 'value' => 1],
|
[['page'], 'default', 'value' => 1],
|
||||||
[['limit'], 'default', 'value' => 20],
|
[['limit'], 'default', 'value' => 20],
|
||||||
[['status'], 'default', 'value' => null],
|
[['status'], 'default', 'value' => null],
|
||||||
@ -56,5 +58,19 @@ class SigningForm extends AdminModel
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function signing()
|
||||||
|
{
|
||||||
|
$signing = Signing::findOne($this->id);
|
||||||
|
|
||||||
|
if ($signing->status == 1) {
|
||||||
|
|
||||||
|
$signing->status = 2;
|
||||||
|
|
||||||
|
$signing->signing_time = time();
|
||||||
|
|
||||||
|
return $signing->save() ? $this->apiReturnSuccess('操作成功') : $this->apiReturnError('操作失败');
|
||||||
|
}
|
||||||
|
return $this->apiReturnError('订单异常');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'label' => '签约头部图片',
|
'label' => '签约头部图片',
|
||||||
'value' => $model->goodsHub ? $model->goodsHub->signing_head_img : '',
|
'value' => $model->goodsHub ? $model->goodsHub->signing_head_img : '',
|
||||||
// 'tip' => '图片大小750×750',
|
// 'tip' => '图片大小750×750',
|
||||||
'required' => true,
|
|
||||||
'imageCompressEnable' => 1,
|
'imageCompressEnable' => 1,
|
||||||
'imageCompressBorder' => 750,
|
'imageCompressBorder' => 750,
|
||||||
]) ?>
|
]) ?>
|
||||||
@ -246,7 +246,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'label' => '签约底部图片',
|
'label' => '签约底部图片',
|
||||||
'value' => $model->goodsHub ? $model->goodsHub->signing_foot_img : '',
|
'value' => $model->goodsHub ? $model->goodsHub->signing_foot_img : '',
|
||||||
// 'tip' => '图片大小750×750',
|
// 'tip' => '图片大小750×750',
|
||||||
'required' => true,
|
|
||||||
'imageCompressEnable' => 1,
|
'imageCompressEnable' => 1,
|
||||||
'imageCompressBorder' => 750,
|
'imageCompressBorder' => 750,
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|||||||
@ -41,9 +41,10 @@ $status = \Yii::$app->request->get('status');
|
|||||||
<select class="layui-select" name="status">
|
<select class="layui-select" name="status">
|
||||||
<option value="" <?= $status === null ? 'selected' : '' ?>>全部</option>
|
<option value="" <?= $status === null ? 'selected' : '' ?>>全部</option>
|
||||||
<option value="0" <?= $status === 0 ? 'selected' : '' ?>>待支付</option>
|
<option value="0" <?= $status === 0 ? 'selected' : '' ?>>待支付</option>
|
||||||
<option value="1" <?= $status === 1 ? 'selected' : '' ?>>已签约</option>
|
<option value="1" <?= $status === 1 ? 'selected' : '' ?>>待签约</option>
|
||||||
<option value="-1" <?= $status === -1 ? 'selected' : '' ?>>已取消</option>
|
<option value="2" <?= $status === 2 ? 'selected' : '' ?>>已签约</option>
|
||||||
<option value="2" <?= $status === 2 ? 'selected' : '' ?>>已退款</option>
|
<option value="3" <?= $status === 3 ? 'selected' : '' ?>>签约失败</option>
|
||||||
|
<option value="4" <?= $status === 4 ? 'selected' : '' ?>>已取消</option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -69,18 +70,21 @@ $status = \Yii::$app->request->get('status');
|
|||||||
{{# if(d.status == 0){ }}
|
{{# if(d.status == 0){ }}
|
||||||
<span class="layui-badge-rim">待支付</span>
|
<span class="layui-badge-rim">待支付</span>
|
||||||
{{# } else if(d.status == 1){ }}
|
{{# } else if(d.status == 1){ }}
|
||||||
<span class="layui-badge-rim">已签约</span>
|
<span class="layui-badge-rim">待签约</span>
|
||||||
{{# } else if(d.status == -1){ }}
|
|
||||||
<span class="layui-badge-rim">已取消</span>
|
|
||||||
{{# } else if(d.status == 2){ }}
|
{{# } else if(d.status == 2){ }}
|
||||||
<span class="layui-badge-rim">已退款</span>
|
<span class="layui-badge-rim">已签约</span>
|
||||||
|
{{# } else if(d.status == 3){ }}
|
||||||
|
<span class="layui-badge-rim">签约失败</span>
|
||||||
|
{{# } else if(d.status == 4){ }}
|
||||||
|
<span class="layui-badge-rim">已取消</span>
|
||||||
{{# } }}
|
{{# } }}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--行操作列模板-->
|
<!--行操作列模板-->
|
||||||
<script type="text/html" id="rowBarTpl">
|
<script type="text/html" id="rowBarTpl">
|
||||||
{{# if(d.status == 1){ }}
|
{{# if(d.status == 1){ }}
|
||||||
<a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="refund">退还</a>
|
<a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="signing">通过</a>
|
||||||
|
<a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="refund">退款</a>
|
||||||
{{# } }}
|
{{# } }}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -161,8 +165,62 @@ $status = \Yii::$app->request->get('status');
|
|||||||
table.on('tool(dtable)', function (obj) {
|
table.on('tool(dtable)', function (obj) {
|
||||||
var lay_event = obj.event;
|
var lay_event = obj.event;
|
||||||
if (lay_event == 'refund') {
|
if (lay_event == 'refund') {
|
||||||
confirm_tip = '确定退款?';
|
|
||||||
confirm_url = '<?=\Yii::$app->urlManager->createUrl(["/admin/signing/refund"])?>';
|
confirm_url = '<?=\Yii::$app->urlManager->createUrl(["/admin/signing/refund"])?>';
|
||||||
|
|
||||||
|
layer.confirm('<input type="text" id="tuihuan" required placeholder="请输入退款理由" autocomplete="off" class="layui-input">', {
|
||||||
|
title: '确定退款?',
|
||||||
|
btn: ['确定', '取消'],
|
||||||
|
|
||||||
|
}, function () {
|
||||||
|
var reason = $('#tuihuan').val();
|
||||||
|
if (reason == ''){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax(confirm_url, {
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
id: obj.data.id,
|
||||||
|
reason:reason,
|
||||||
|
_csrf: _csrf
|
||||||
|
},
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code == 0) {
|
||||||
|
layer.msg(res.msg, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 1
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 2
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhr, type, err) {
|
||||||
|
layer.msg(xhr.responseText, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 2
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lay_event == 'signing') {
|
||||||
|
confirm_tip = '确定通过签约?';
|
||||||
|
confirm_url = '<?=\Yii::$app->urlManager->createUrl(["/admin/signing/signing"])?>';
|
||||||
}
|
}
|
||||||
if (confirm_url != null) {
|
if (confirm_url != null) {
|
||||||
layer.confirm(confirm_tip, {
|
layer.confirm(confirm_tip, {
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class SigningForm extends ApiModel
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['goods_hub_id', 'company_name', 'brand_name', 'product', 'type', 'number'], 'required'],
|
[['goods_hub_id', 'company_name', 'brand_name', 'product', 'type', 'number'], 'required'],
|
||||||
[['goods_hub_id', 'number'], 'integer'],
|
[['goods_hub_id', 'number','user_id'], 'integer'],
|
||||||
[['remark'], 'string']
|
[['remark'], 'string']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -94,17 +94,16 @@ class SigningForm extends ApiModel
|
|||||||
public function orderList($status, $limit, $page)
|
public function orderList($status, $limit, $page)
|
||||||
{
|
{
|
||||||
|
|
||||||
$query = Signing::find()->with(['goods.goodsHub'])->where(['user_id' => $this->user_id]);
|
$query = Signing::find()->with(['goods.goodsHub'])->andWhere(['user_id' => $this->user_id]);
|
||||||
|
|
||||||
if ($status != null) {
|
if ($status != null) {
|
||||||
$query->where(['status' => $status]);
|
$query->andWhere(['status' => $status]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pagination = new Pagination(['totalCount' => $query->count(), 'defaultPageSize' => $limit]);
|
$pagination = new Pagination(['totalCount' => $query->count(), 'defaultPageSize' => $limit]);
|
||||||
|
|
||||||
$models = $query->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
|
$models = $query->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
|
||||||
|
|
||||||
|
|
||||||
return $this->apiReturnSuccess('success', ['pagination' => $pagination, 'data' => $models]);
|
return $this->apiReturnSuccess('success', ['pagination' => $pagination, 'data' => $models]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user