feat: 修改订单控制器中的核销码验证、订单支付、退款申请等方法
This commit is contained in:
parent
9f44216503
commit
e6acf8b542
@ -43,14 +43,14 @@ class OrderController extends BaseApiController
|
|||||||
public function write_code()
|
public function write_code()
|
||||||
{
|
{
|
||||||
$code = $this->request->post('code');
|
$code = $this->request->post('code');
|
||||||
if(empty($code)){
|
if (empty($code)) {
|
||||||
return $this->fail('缺失参数');
|
return $this->fail('缺失参数');
|
||||||
}
|
}
|
||||||
$res = OrderLogic::getOne($code);
|
$res = OrderLogic::getOne($code);
|
||||||
if($res){
|
if ($res) {
|
||||||
$res = $res[0];
|
$res = $res[0];
|
||||||
}
|
}
|
||||||
return $this->success('ok',$res);
|
return $this->success('ok', $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[
|
#[
|
||||||
@ -67,20 +67,19 @@ class OrderController extends BaseApiController
|
|||||||
]
|
]
|
||||||
public function write_list()
|
public function write_list()
|
||||||
{
|
{
|
||||||
$status = (int)$this->request->post('status',1);
|
$status = (int)$this->request->post('status', 1);
|
||||||
$page_no = (int)$this->request->post('page_no',1);
|
$page_no = (int)$this->request->post('page_no', 1);
|
||||||
$page_size = (int)$this->request->post('page_size',15);
|
$page_size = (int)$this->request->post('page_size', 15);
|
||||||
$params = $this->request->post();
|
$params = $this->request->post();
|
||||||
if(empty($page_no) || empty($page_size)){
|
if (empty($page_no) || empty($page_size)) {
|
||||||
$params['page_no'] = 1;
|
$params['page_no'] = 1;
|
||||||
$params['page_size'] = 15;
|
$params['page_size'] = 15;
|
||||||
}
|
}
|
||||||
$info = $this->userInfo;
|
$info = $this->userInfo;
|
||||||
$res = OrderLogic::write_list($info,$status,$params);
|
$res = OrderLogic::write_list($info, $status, $params);
|
||||||
$res['page_no'] =$params['page_no'];
|
$res['page_no'] = $params['page_no'];
|
||||||
$res['page_size'] =$params['page_size'];
|
$res['page_size'] = $params['page_size'];
|
||||||
return $this->success('ok',$res);
|
return $this->success('ok', $res);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[
|
#[
|
||||||
@ -96,8 +95,8 @@ class OrderController extends BaseApiController
|
|||||||
{
|
{
|
||||||
$info = $this->userInfo;
|
$info = $this->userInfo;
|
||||||
$params = $this->request->post();
|
$params = $this->request->post();
|
||||||
$res = OrderLogic::write_count($info,$params);
|
$res = OrderLogic::write_count($info, $params);
|
||||||
return $this->success('ok',$res);
|
return $this->success('ok', $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[
|
#[
|
||||||
@ -112,26 +111,26 @@ class OrderController extends BaseApiController
|
|||||||
ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"),
|
ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"),
|
||||||
ApiDoc\NotHeaders(),
|
ApiDoc\NotHeaders(),
|
||||||
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
ApiDoc\ResponseSuccess("data", type: "array", children:[
|
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||||||
['name' => 'order', 'desc' => '订单信息', 'type' => 'array', 'children' => [
|
['name' => 'order', 'desc' => '订单信息', 'type' => 'array', 'children' => [
|
||||||
['name' => 'create_time', 'desc' => '订单创建时间', 'type' =>'int'],
|
['name' => 'create_time', 'desc' => '订单创建时间', 'type' => 'int'],
|
||||||
['name' => 'order_id', 'desc' => '订单id', 'type' => 'int'],
|
['name' => 'order_id', 'desc' => '订单id', 'type' => 'int'],
|
||||||
['name' => 'total_price', 'desc' => '订单总金额', 'type' => 'float'],
|
['name' => 'total_price', 'desc' => '订单总金额', 'type' => 'float'],
|
||||||
['name' => 'pay_price', 'desc' => '实际支付金额', 'type' =>'float'],
|
['name' => 'pay_price', 'desc' => '实际支付金额', 'type' => 'float'],
|
||||||
['name' => 'total_num', 'desc' => '订单总数量', 'type' =>'int'],
|
['name' => 'total_num', 'desc' => '订单总数量', 'type' => 'int'],
|
||||||
['name' => 'pay_type', 'desc' => '支付方式', 'type' =>'int'],
|
['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'int'],
|
||||||
['name' => 'cart_id', 'desc' => '购物车id', 'type' =>'string'],
|
['name' => 'cart_id', 'desc' => '购物车id', 'type' => 'string'],
|
||||||
['name' => 'store_id', 'desc' => '店铺id', 'type' =>'int'],
|
['name' => 'store_id', 'desc' => '店铺id', 'type' => 'int'],
|
||||||
['name' => 'shipping_type', 'desc' => '配送方式', 'type' =>'int'],
|
['name' => 'shipping_type', 'desc' => '配送方式', 'type' => 'int'],
|
||||||
]],
|
]],
|
||||||
['name' => 'cart_list', 'desc' => '购物车商品列表', 'type' => 'array', 'children' => [
|
['name' => 'cart_list', 'desc' => '购物车商品列表', 'type' => 'array', 'children' => [
|
||||||
['name' => 'goods', 'desc' => '商品id', 'type' => 'int'],
|
['name' => 'goods', 'desc' => '商品id', 'type' => 'int'],
|
||||||
['name' => 'cart_num', 'desc' => '购买数量', 'type' =>'int'],
|
['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'int'],
|
||||||
['name' => 'total', 'desc' => '商品总价', 'type' => 'float'],
|
['name' => 'total', 'desc' => '商品总价', 'type' => 'float'],
|
||||||
['name' => 'price', 'desc' => '商品单价', 'type' => 'float'],
|
['name' => 'price', 'desc' => '商品单价', 'type' => 'float'],
|
||||||
['name' => 'product_id', 'desc' => '商品id', 'type' =>'int'],
|
['name' => 'product_id', 'desc' => '商品id', 'type' => 'int'],
|
||||||
['name' => 'old_cart_id', 'desc' => '原购物车id', 'type' =>'string'],
|
['name' => 'old_cart_id', 'desc' => '原购物车id', 'type' => 'string'],
|
||||||
['name' => 'verify_code', 'desc' => '校验码', 'type' =>'string'],
|
['name' => 'verify_code', 'desc' => '校验码', 'type' => 'string'],
|
||||||
]],
|
]],
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
@ -181,13 +180,13 @@ class OrderController extends BaseApiController
|
|||||||
return $this->fail('购物车商品不能超过100个');
|
return $this->fail('购物车商品不能超过100个');
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($pay_type == 9 || $pay_type == 17 ||$pay_type==13) {
|
// if ($pay_type == 9 || $pay_type == 17 ||$pay_type==13) {
|
||||||
// if (empty($this->request->userInfo['merchant'])) {
|
// if (empty($this->request->userInfo['merchant'])) {
|
||||||
// return $this->fail('请先绑定商户');
|
// return $this->fail('请先绑定商户');
|
||||||
// }
|
// }
|
||||||
// $mer_id = $this->request->userInfo['merchant']['mer_id'];
|
// $mer_id = $this->request->userInfo['merchant']['mer_id'];
|
||||||
// $params['mer_id'] = $mer_id;
|
// $params['mer_id'] = $mer_id;
|
||||||
// }
|
// }
|
||||||
$order = OrderLogic::createOrder($cartId, $addressId, null, $params);
|
$order = OrderLogic::createOrder($cartId, $addressId, null, $params);
|
||||||
if ($order != false) {
|
if ($order != false) {
|
||||||
switch ($pay_type) {
|
switch ($pay_type) {
|
||||||
@ -199,10 +198,10 @@ class OrderController extends BaseApiController
|
|||||||
//现金支付
|
//现金支付
|
||||||
PayNotifyLogic::handle('cash_pay', $order['order_id']);
|
PayNotifyLogic::handle('cash_pay', $order['order_id']);
|
||||||
return $this->success('现金支付成功');
|
return $this->success('现金支付成功');
|
||||||
case PayEnum::WECHAT_PAY:
|
case PayEnum::WECHAT_PAY_MINI:
|
||||||
//微信支付
|
//微信小程序支付
|
||||||
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
|
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
|
||||||
$result = PaymentLogic::pay($pay_type, 'wechat_common', $order, $this->userInfo['terminal']??1, $redirectUrl);
|
$result = PaymentLogic::pay($pay_type, 'wechat_common', $order, $this->userInfo['terminal'] ?? 1, $redirectUrl);
|
||||||
if (PaymentLogic::hasError()) {
|
if (PaymentLogic::hasError()) {
|
||||||
return $this->fail(PaymentLogic::getError(), $params);
|
return $this->fail(PaymentLogic::getError(), $params);
|
||||||
}
|
}
|
||||||
@ -219,7 +218,7 @@ class OrderController extends BaseApiController
|
|||||||
Redis::send('send-code-pay', ['number' => $order['number']]);
|
Redis::send('send-code-pay', ['number' => $order['number']]);
|
||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
return $this->success('支付成功', ['out_trade_no'=>$result['out_trade_no'],'pay_type'=>PayEnum::WECHAT_PAY_BARCODE,'transaction_id'=>$result['transaction_id']]);
|
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);
|
||||||
case PayEnum::ALIPAY_BARCODE:
|
case PayEnum::ALIPAY_BARCODE:
|
||||||
//支付宝条码支付
|
//支付宝条码支付
|
||||||
$result = PaymentLogic::ali_auth_code($auth_code, $order);
|
$result = PaymentLogic::ali_auth_code($auth_code, $order);
|
||||||
@ -230,11 +229,11 @@ class OrderController extends BaseApiController
|
|||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
$result['create_time'] = $order['create_time'];
|
$result['create_time'] = $order['create_time'];
|
||||||
return $this->success('支付成功', ['out_trade_no'=>$result['out_trade_no'],'pay_type'=>PayEnum::ALIPAY_BARCODE,'transaction_id'=>$result['trade_no']]);
|
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no']]);
|
||||||
default:
|
default:
|
||||||
return $this->fail('支付方式错误');
|
return $this->fail('支付方式错误');
|
||||||
}
|
}
|
||||||
// return $this->data(['order_id' => $order->id]);
|
// return $this->data(['order_id' => $order->id]);
|
||||||
} else {
|
} else {
|
||||||
return $this->fail(OrderLogic::getError());
|
return $this->fail(OrderLogic::getError());
|
||||||
}
|
}
|
||||||
@ -245,23 +244,23 @@ class OrderController extends BaseApiController
|
|||||||
{
|
{
|
||||||
$userId = $this->request->userId;
|
$userId = $this->request->userId;
|
||||||
$where = ['uid' => $userId, 'paid' => 0];
|
$where = ['uid' => $userId, 'paid' => 0];
|
||||||
$no_pay = StoreOrder::where($where)->count();//待付款
|
$no_pay = StoreOrder::where($where)->count(); //待付款
|
||||||
|
|
||||||
$where['paid'] = 1;
|
$where['paid'] = 1;
|
||||||
$where['status'] = 1;
|
$where['status'] = 1;
|
||||||
$waiting = StoreOrder::where($where)->count();//待核销
|
$waiting = StoreOrder::where($where)->count(); //待核销
|
||||||
|
|
||||||
$where['status'] = 2;
|
$where['status'] = 2;
|
||||||
$receiving = StoreOrder::where($where)->count();//已核销
|
$receiving = StoreOrder::where($where)->count(); //已核销
|
||||||
|
|
||||||
$where['status'] = -1;
|
$where['status'] = -1;
|
||||||
$applyRefund= StoreOrder::where($where)->count();//申请退款
|
$applyRefund = StoreOrder::where($where)->count(); //申请退款
|
||||||
|
|
||||||
$where['status'] = 4;
|
$where['status'] = 4;
|
||||||
$refund= StoreOrder::where($where)->count();//已退款
|
$refund = StoreOrder::where($where)->count(); //已退款
|
||||||
|
|
||||||
$all = StoreOrder::where(['uid' => $userId])->count();//全部
|
$all = StoreOrder::where(['uid' => $userId])->count(); //全部
|
||||||
return $this->success('ok', ['no_pay' => $no_pay, 'waiting' => $waiting, 'receiving' => $receiving,'all'=>$all,'applyRefund'=>$applyRefund,'refund'=>$refund]);
|
return $this->success('ok', ['no_pay' => $no_pay, 'waiting' => $waiting, 'receiving' => $receiving, 'all' => $all, 'applyRefund' => $applyRefund, 'refund' => $refund]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[
|
#[
|
||||||
@ -303,8 +302,8 @@ class OrderController extends BaseApiController
|
|||||||
PayNotifyLogic::handle('cash_pay', $order['order_id']);
|
PayNotifyLogic::handle('cash_pay', $order['order_id']);
|
||||||
return $this->success('现金支付成功');
|
return $this->success('现金支付成功');
|
||||||
break;
|
break;
|
||||||
case PayEnum::WECHAT_PAY:
|
case PayEnum::WECHAT_PAY_MINI:
|
||||||
//微信支付
|
//微信小程序支付
|
||||||
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
|
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
|
||||||
if ($addressId != $order['address_id']) {
|
if ($addressId != $order['address_id']) {
|
||||||
$address = UserAddress::where(['address_id' => $addressId, 'uid' => Request()->userId])->find();
|
$address = UserAddress::where(['address_id' => $addressId, 'uid' => Request()->userId])->find();
|
||||||
@ -316,7 +315,7 @@ class OrderController extends BaseApiController
|
|||||||
StoreOrder::where(['id' => $order_id, 'uid' => Request()->userId])->update($_order);
|
StoreOrder::where(['id' => $order_id, 'uid' => Request()->userId])->update($_order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result = PaymentLogic::pay($pay_type, 'wechat_common', $order, $this->userInfo['terminal']??1, $redirectUrl);
|
$result = PaymentLogic::pay($pay_type, 'wechat_common', $order, $this->userInfo['terminal'] ?? 1, $redirectUrl);
|
||||||
if (PaymentLogic::hasError()) {
|
if (PaymentLogic::hasError()) {
|
||||||
return $this->fail(PaymentLogic::getError());
|
return $this->fail(PaymentLogic::getError());
|
||||||
}
|
}
|
||||||
@ -334,7 +333,7 @@ class OrderController extends BaseApiController
|
|||||||
Redis::send('send-code-pay', ['number' => $order['number']]);
|
Redis::send('send-code-pay', ['number' => $order['number']]);
|
||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
return $this->success('支付成功', ['out_trade_no'=>$result['out_trade_no'],'pay_type'=>PayEnum::WECHAT_PAY_BARCODE,'transaction_id'=>$result['transaction_id']]);
|
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);
|
||||||
break;
|
break;
|
||||||
case PayEnum::ALIPAY_BARCODE:
|
case PayEnum::ALIPAY_BARCODE:
|
||||||
//支付宝条码支付
|
//支付宝条码支付
|
||||||
@ -345,7 +344,7 @@ class OrderController extends BaseApiController
|
|||||||
if ($result['msg'] !== 'Success') {
|
if ($result['msg'] !== 'Success') {
|
||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
return $this->success('支付成功', ['out_trade_no'=>$result['out_trade_no'],'pay_type'=>PayEnum::ALIPAY_BARCODE,'transaction_id'=>$result['trade_no']]);
|
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no']]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return $this->fail('支付方式错误');
|
return $this->fail('支付方式错误');
|
||||||
@ -460,15 +459,15 @@ class OrderController extends BaseApiController
|
|||||||
public function writeoff_order()
|
public function writeoff_order()
|
||||||
{
|
{
|
||||||
$params = (new OrderValidate())->post()->goCheck('check');
|
$params = (new OrderValidate())->post()->goCheck('check');
|
||||||
$count = StoreOrder::where('verify_code',$params['verify_code'])->count();
|
$count = StoreOrder::where('verify_code', $params['verify_code'])->count();
|
||||||
if(empty($count)){
|
if (empty($count)) {
|
||||||
return $this->fail('无该核销码请检查');
|
return $this->fail('无该核销码请检查');
|
||||||
}
|
}
|
||||||
$res = OrderLogic::writeOff($params);
|
$res = OrderLogic::writeOff($params);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return $this->success('核销成功');
|
return $this->success('核销成功');
|
||||||
}
|
}
|
||||||
return $this->fail('核销失败'.OrderLogic::getError());
|
return $this->fail('核销失败' . OrderLogic::getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -476,8 +475,8 @@ class OrderController extends BaseApiController
|
|||||||
public function merchant_order_count()
|
public function merchant_order_count()
|
||||||
{
|
{
|
||||||
$date = $this->request->get('date', date('Y-m-d'));
|
$date = $this->request->get('date', date('Y-m-d'));
|
||||||
$store_id = SystemStoreStaff::where('phone',$this->userInfo['mobile'])->value('store_id');
|
$store_id = SystemStoreStaff::where('phone', $this->userInfo['mobile'])->value('store_id');
|
||||||
if(empty($store_id)){
|
if (empty($store_id)) {
|
||||||
throw new \Exception('该用户未绑定店铺');
|
throw new \Exception('该用户未绑定店铺');
|
||||||
}
|
}
|
||||||
$where[] = ['store_id', '=', $store_id];
|
$where[] = ['store_id', '=', $store_id];
|
||||||
@ -506,7 +505,7 @@ class OrderController extends BaseApiController
|
|||||||
$params = (new OrderValidate())->post()->goCheck('add');
|
$params = (new OrderValidate())->post()->goCheck('add');
|
||||||
$uid = $this->userId;
|
$uid = $this->userId;
|
||||||
//拆单逻辑
|
//拆单逻辑
|
||||||
OrderLogic::dealRefund($uid,$params);
|
OrderLogic::dealRefund($uid, $params);
|
||||||
return $this->success('申请成功');
|
return $this->success('申请成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,9 +519,9 @@ class OrderController extends BaseApiController
|
|||||||
]
|
]
|
||||||
public function refund_reason()
|
public function refund_reason()
|
||||||
{
|
{
|
||||||
$data = DictData::where('type_value','reason')->where('status',YesNoEnum::YES)
|
$data = DictData::where('type_value', 'reason')->where('status', YesNoEnum::YES)
|
||||||
->select()->toArray();
|
->select()->toArray();
|
||||||
return $this->success('ok',$data);
|
return $this->success('ok', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -547,10 +546,5 @@ class OrderController extends BaseApiController
|
|||||||
} else {
|
} else {
|
||||||
return $this->fail('取消失败');
|
return $this->fail('取消失败');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user