// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\api\controller; use think\response\Json; use app\api\model\Retail as RetailModel; use app\api\model\RetailOrder as RetailOrderModel; use app\api\model\Agreement as AgreementModel; use app\common\model\RetailDescribe as RetailDescribeModel; use app\api\service\order\Checkout as CheckoutService; use app\api\service\User as UserService; class Retail extends Controller { /** * 获取零售批发会员列表 * @param int $retailType * @return Json */ public function list(int $retailType): Json { $list = RetailModel::withoutGlobalScope()->where('retail_type',$retailType)->where('retail_status',10)->select(); return $this->renderSuccess(compact('list')); } /** * 获取软件付费协议 * @return Json */ public function getSoftAgreement(): Json { $params = $this->request->param(); if (empty($params['type'])) { return $this->renderSuccess("参数错误"); } $detail = AgreementModel::detail(['type' => $params['type']]); if (!empty($detail->content)) { $detail->content = str_ireplace('nowrap', 'inherit', $detail->content); } return $this->renderSuccess(compact('detail')); } /** * 获取零售批发会员列表 * @param int $retailType * @return Json */ public function retailPayList(): Json { $client = $this->request->post(); if (!$client['client']) { return $this->renderError('客户端不能为空'); } $model =new \app\api\service\Retail(); $list = $model->userCenter($client); return $this->renderSuccess(compact('list')); } public function submit(): Json { $method = $this->request->post('method'); if (!$method) { return $this->renderError('支付方式不能为空'); } $client = $this->request->post('client'); if (!$client) { return $this->renderError('客户端不能为空'); } $retailPriceId = intval($this->request->post('retail_price_id')); if (!$retailPriceId) { return $this->renderError('缺少必要参数'); } $service = new \app\api\service\Retail(); $data = $service->setMethod($method) ->setClient($client) ->orderPay($retailPriceId); return $this->renderSuccess($data, $service->getMessage() ?: '下单成功'); } /** * 商厂权限 */ public function describe() { $list = RetailDescribeModel::withoutGlobalScope()->select(); $grouped = []; foreach ($list as $item) { $grouped[$item['plate_id']][] = $item; } return $this->renderSuccess(compact('grouped')); } }