|
|
@@ -34,6 +34,7 @@ class PrintController extends BaseController
|
|
|
* 图片打印
|
|
|
*/
|
|
|
public function photo(){
|
|
|
+ FileLogs::where(['user_id'=> $this->userId,'type'=> 1])->update(['status'=> 2]);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
@@ -41,6 +42,7 @@ class PrintController extends BaseController
|
|
|
* 证件打印
|
|
|
*/
|
|
|
public function papers(){
|
|
|
+ FileLogs::where(['user_id'=> $this->userId,'type'=> 2])->update(['status'=> 2]);
|
|
|
$this->assign('version', date('YmdHis'));
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
@@ -49,6 +51,7 @@ class PrintController extends BaseController
|
|
|
* 文件打印
|
|
|
*/
|
|
|
public function files(){
|
|
|
+ FileLogs::where(['user_id'=> $this->userId,'type'=> 3])->update(['status'=> 2]);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
@@ -139,7 +142,7 @@ class PrintController extends BaseController
|
|
|
$id = input('id',0);
|
|
|
|
|
|
$orderInfo = db('orders')->where(['id'=> $id])
|
|
|
- ->field('id,order_sn,user_id,status')
|
|
|
+ ->field('id,order_sn,user_id,pay_at,status')
|
|
|
->find();
|
|
|
$orderSn = isset($orderInfo['order_sn'])? $orderInfo['order_sn'] : '';
|
|
|
if(empty($orderInfo) || empty($orderSn)){
|
|
|
@@ -163,6 +166,80 @@ class PrintController extends BaseController
|
|
|
showJson(1005, 3015, $data);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 取消订单
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function cancel(){
|
|
|
+ $id = input('id',0);
|
|
|
+
|
|
|
+ $orderInfo = db('orders')->where(['id'=> $id])
|
|
|
+ ->field('id,order_sn,user_id,pay_total,transaction_id,status')
|
|
|
+ ->find();
|
|
|
+ $orderSn = isset($orderInfo['order_sn'])? $orderInfo['order_sn'] : '';
|
|
|
+ if(empty($orderInfo) || empty($orderSn)){
|
|
|
+ showJson(1004,4010);
|
|
|
+ }
|
|
|
+
|
|
|
+ $orserStatus = isset($orderInfo['status'])? $orderInfo['status'] : 0;
|
|
|
+ if($orserStatus != 2){
|
|
|
+ $msgCode = 4010+$orserStatus;
|
|
|
+ showJson(1004,$msgCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ $orserUserId = isset($orderInfo['user_id'])? $orderInfo['user_id'] : 0;
|
|
|
+ if($orserUserId != $this->userId){
|
|
|
+ showJson(1004, 2009);
|
|
|
+ }
|
|
|
+
|
|
|
+ db('orders')->startTrans();
|
|
|
+ if(!db('orders')->where(['id'=> $id])->update(['status'=> 5,'remark'=> '用户手动取消订单'])){
|
|
|
+ showJson(1004, 4024);
|
|
|
+ db('orders')->rollback();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 退还金额
|
|
|
+ $payTotal = isset($orderInfo['pay_total'])? floatval($orderInfo['pay_total']) : 0;
|
|
|
+ if($payTotal){
|
|
|
+ $balance = Member::where(['id' => $this->userId])->value('balance');
|
|
|
+ $updateData = [
|
|
|
+ 'balance' => moneyFormat($balance + $payTotal, 2),
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (db('user')->where(['id' => $this->userId])->update($updateData)) {
|
|
|
+ $transactionId = isset($orderInfo['transaction_id']) ? $orderInfo['transaction_id'] : '';
|
|
|
+ $payAt = isset($orderInfo['pay_at']) ? $orderInfo['pay_at'] : '';
|
|
|
+ $log = [
|
|
|
+ 'type' => 1,
|
|
|
+ 'change_type' => 3,
|
|
|
+ 'user_id' => $this->userId,
|
|
|
+ 'create_time' => time(),
|
|
|
+ 'change' => moneyFormat($payTotal, 2),
|
|
|
+ 'balance' => $balance,
|
|
|
+ 'description' => '订单号:' . $orderSn . ',交易单号:' . $transactionId . ',交易时间: ' . $payAt,
|
|
|
+ 'remark' => '订单已支付为打印用户手动申请退款',
|
|
|
+ 'status' => 2
|
|
|
+ ];
|
|
|
+
|
|
|
+ $res = db('user_balance_log')->insertGetId($log);
|
|
|
+ if(!$res){
|
|
|
+ showJson(1004, 4025);
|
|
|
+ db('orders')->rollback();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ showJson(1004, 4025);
|
|
|
+ db('orders')->rollback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ db('orders')->commit();
|
|
|
+
|
|
|
+ showJson(1004, 4026);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|