12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\api\controller\mall;
- use app\common\controller\Api;
- use app\common\model\Refund;
- use app\common\service\RefundService;
- /**
- * 订单退款
- * @inheritdoc
- */
- class OrderRefund extends Api
- {
- protected $noNeedRight = "*";
- /**
- * 退款退货配置
- * @ApiMethod (POST)
- * @ApiParams (name=order_info_id,description=退货子订单ID)
- * @ApiParams (name=num,description=退货数量)
- * @ApiParams (name=num_install,description=退货安装数量)
- * @ApiReturnParams (name=reason,description=退款原因选项)
- * @ApiReturnParams (name=type,description=退货方式选项)
- */
- public function config()
- {
- $info=[
- 'reason'=>array_values(Refund::getReasons()),
- 'type'=>array_values(Refund::getRefundBys()),
- 'amount'=>0,
- ];
- $data=$this->_validate([
- 'order_info_id'=>['require','integer'],
- 'num'=>['require','integer','egt:0'],
- 'num_install'=>['require','integer','egt:0'],
- ]);
- $orderInfo=$this->auth->getUser()->orderInfo()->find($data['order_info_id']);
- if($orderInfo){
- list($amount,$amount_install)=RefundService::setOrderInfo($orderInfo,$data['num'],$data['num_install'])->amount();
- $info['amount']=bcadd($amount,$amount_install);
- }
- $this->success('', $info);
- }
- }
|