diff --git a/commands/Script1minController.php b/commands/Script1minController.php
index 913502a..1813a2d 100644
--- a/commands/Script1minController.php
+++ b/commands/Script1minController.php
@@ -11,6 +11,7 @@ use app\components\YopointApi;
use app\models\BallCart;
use app\models\BallMark;
use app\models\Order;
+use app\models\Signing;
use app\models\YopointNotify;
use app\modules\api\components\Mqtt;
use yii\console\Controller;
@@ -38,25 +39,47 @@ class Script1minController extends Controller
{
$redis_name = "cxaibc:console:script1min_lock";
try {
- $get = \Yii::$app->redis->setnx($redis_name,1);
- if(empty($get)){
+ $get = \Yii::$app->redis->setnx($redis_name, 1);
+ if (empty($get)) {
$ttl = \Yii::$app->redis->ttl($redis_name);
- if($ttl === -1){
- \Yii::$app->redis->expire($redis_name,60);
+ if ($ttl === -1) {
+ \Yii::$app->redis->expire($redis_name, 60);
}
var_dump("1分钟脚本正在执行中");
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);
- }catch (\Exception $e){
+ } catch (\Exception $e) {
\Yii::$app->redis->del($redis_name);
var_dump($e->getMessage());
}
echo "1分钟脚本";
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();
+ }
+
+ }
+
+
+ }
+
}
diff --git a/components/TongLianPay.php b/components/TongLianPay.php
index 890835b..9e04032 100644
--- a/components/TongLianPay.php
+++ b/components/TongLianPay.php
@@ -24,7 +24,7 @@ class TongLianPay
'cusid' => $this->cusid,
'appid' => $this->appid,
'version' => '11',
- 'trxamt' => $signing->moy * 100,
+ 'trxamt' => $signing->moy * 100,
'reqsn' => $signing->order_no,
'paytype' => 'W06',
'randomstr' => date('dHis') . rand(1000000, 9999999),
@@ -70,7 +70,7 @@ class TongLianPay
return $signing->save();
}
- public function refund($signingId)
+ public function refund($signingId, $reason)
{
$signing = Signing::findOne($signingId);
@@ -82,6 +82,7 @@ class TongLianPay
'trxamt' => $signing->moy * 100,
'reqsn' => date('YmdH') . rand(10000, 99999),
'oldtrxid' => $signing->trxid,
+ 'oldreqsn' => $signing->order_no,
'randomstr' => date('YmdH') . rand(10000, 99999),
'signtype' => 'RSA',
];
@@ -96,13 +97,16 @@ class TongLianPay
if ($result['trxstatus'] == '0000') {
- $signing->status = 2;
+ $signing->status = 3;
+
+ $signing->reason = $reason;
$signing->save();
return $this->apiReturnSuccess('操作成功');
}
- return $this->apiReturnError($result['errmsg']);
+
+ return $this->apiReturnError($result['errmsg'], $result);
}
return $this->apiReturnError('订单异常');
}
diff --git a/modules/admin/controllers/SigningController.php b/modules/admin/controllers/SigningController.php
index a927823..a089374 100644
--- a/modules/admin/controllers/SigningController.php
+++ b/modules/admin/controllers/SigningController.php
@@ -39,15 +39,28 @@ class SigningController extends Controller
public function actionRefund()
{
-
if (\Yii::$app->request->isAjax) {
$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());
+ }
+
}
diff --git a/modules/admin/models/SigningForm.php b/modules/admin/models/SigningForm.php
index b43ed77..a1a64da 100644
--- a/modules/admin/models/SigningForm.php
+++ b/modules/admin/models/SigningForm.php
@@ -18,11 +18,13 @@ class SigningForm extends AdminModel
public $status;
+ public $id;
+
public function rules()
{
return [
[['order_no'], 'string'],
- [['page', 'limit', 'status'], 'integer'],
+ [['page', 'limit', 'status', 'id'], 'integer'],
[['page'], 'default', 'value' => 1],
[['limit'], 'default', 'value' => 20],
[['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('订单异常');
+ }
}
\ No newline at end of file
diff --git a/modules/admin/views/mall/goods/edit.php b/modules/admin/views/mall/goods/edit.php
index 42d1e19..f532e08 100644
--- a/modules/admin/views/mall/goods/edit.php
+++ b/modules/admin/views/mall/goods/edit.php
@@ -234,7 +234,7 @@ $this->params['breadcrumbs'][] = $this->title;
'label' => '签约头部图片',
'value' => $model->goodsHub ? $model->goodsHub->signing_head_img : '',
// 'tip' => '图片大小750×750',
- 'required' => true,
+
'imageCompressEnable' => 1,
'imageCompressBorder' => 750,
]) ?>
@@ -246,7 +246,7 @@ $this->params['breadcrumbs'][] = $this->title;
'label' => '签约底部图片',
'value' => $model->goodsHub ? $model->goodsHub->signing_foot_img : '',
// 'tip' => '图片大小750×750',
- 'required' => true,
+
'imageCompressEnable' => 1,
'imageCompressBorder' => 750,
]) ?>
diff --git a/modules/admin/views/signing/index.php b/modules/admin/views/signing/index.php
index b568372..41411b6 100644
--- a/modules/admin/views/signing/index.php
+++ b/modules/admin/views/signing/index.php
@@ -41,9 +41,10 @@ $status = \Yii::$app->request->get('status');
@@ -69,18 +70,21 @@ $status = \Yii::$app->request->get('status');
{{# if(d.status == 0){ }}
待支付
{{# } else if(d.status == 1){ }}
- 已签约
- {{# } else if(d.status == -1){ }}
- 已取消
+ 待签约
{{# } else if(d.status == 2){ }}
- 已退款
+ 已签约
+ {{# } else if(d.status == 3){ }}
+ 签约失败
+ {{# } else if(d.status == 4){ }}
+ 已取消
{{# } }}
@@ -161,8 +165,62 @@ $status = \Yii::$app->request->get('status');
table.on('tool(dtable)', function (obj) {
var lay_event = obj.event;
if (lay_event == 'refund') {
- confirm_tip = '确定退款?';
+
confirm_url = '=\Yii::$app->urlManager->createUrl(["/admin/signing/refund"])?>';
+
+ layer.confirm('', {
+ 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) {
layer.confirm(confirm_tip, {
diff --git a/modules/api/models/SigningForm.php b/modules/api/models/SigningForm.php
index 668cc93..8c949ec 100644
--- a/modules/api/models/SigningForm.php
+++ b/modules/api/models/SigningForm.php
@@ -27,7 +27,7 @@ class SigningForm extends ApiModel
{
return [
[['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']
];
}
@@ -94,17 +94,16 @@ class SigningForm extends ApiModel
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) {
- $query->where(['status' => $status]);
+ $query->andWhere(['status' => $status]);
}
$pagination = new Pagination(['totalCount' => $query->count(), 'defaultPageSize' => $limit]);
$models = $query->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
-
return $this->apiReturnSuccess('success', ['pagination' => $pagination, 'data' => $models]);
}
}
\ No newline at end of file