| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers\cloud;
- use app\models\Admin;
- use app\models\Share;
- use yii\base\BaseObject;
- use yii\helpers\Json;
- use app\jobs\BatchDownGoodsJob;
- use app\constants\OptionSetting;
- use app\models\Option;
- //use linslin\yii2\curl;
- use app\modules\admin\controllers\BaseController;
- use app\modules\admin\models\SupplierForm;
- use app\modules\alliance\models\purchase\order\OrderForm;
- use app\modules\alliance\models\purchase\order\OrderListForm;
- use app\models\PurchaseOrder;
- use app\modules\admin\controllers\cloud\behaviors\SupplierBehaviors;
- use yii\helpers\ArrayHelper;
- use app\constants\Kefu;
- use app\models\Supplier;
- use app\models\Store;
- class SupplierController extends BaseController
- {
- /**
- * @return array
- */
- public function behaviors()
- {
- return ArrayHelper::merge(parent::behaviors(), [
- [
- 'class' => SupplierBehaviors::class
- ]
- ]);
- }
- //获取运费规则
- public function actionSupplierGetRules(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierGetRules());
- }
- //删除运费规则
- public function actionSupplierDelRules(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierDelRules());
- }
- //删除运费规则
- public function actionSupplierSetStatus(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierSetStatus());
- }
- //获取运费规则列表
- public function actionSupplierGetRulesList(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierGetRulesList());
- }
- //订单取消审核
- // public function actionSupplierOrderCancel(){
- // $post = post_params();
- // $form = new SupplierForm();
- // $form->attributes = $post;
- // $this->asJson($form->supplierOrderCancel());
- // }
- //订单取消审核
- public function actionSupplierOrderRevoke(){
- $form = new OrderForm();
- $form->attributes = post_params();
- // $form->delete_pass = 1;
- // $form->remark = '';
- $cloud_order_id = (string)post_params('order_id', 0);
- $order = PurchaseOrder::find()->where(['cloud_order_id' => $cloud_order_id, 'is_delete' => 0])->one();
- if (!$order) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '订单不存在'
- ]);
- }
- return $this->asJson($form->revokeApply($order));
- }
- //供货单修改收货地址 / 卖家备注
- public function actionSupplierOrderSetAddress(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierOrderSetAddress());
- }
- //转单修改收货地址 / 卖家备注
- public function actionSupplierPurchaseOrderSetAddress(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierPurchaseOrderSetAddress());
- }
- //供货单发货
- public function actionSupplierOrderSend(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierOrderSend());
- }
- //供货单xlsx发货
- public function actionSupplierOrderXlsxSend(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierOrderSend());
- }
- //供货单列表
- public function actionSupplierOrderList(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson(OrderListForm::appendOrderInfo($form->supplierOrderList()));
- }
- //供货单列表
- public function actionSupplierSendTypeList(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson(OrderListForm::appendOrderInfo($form->supplierSendTypeList()));
- }
- //云仓库存列表
- public function actionGetCloudPreviewNum(){
- $post = get_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->getCloudPreviewNum());
- }
- //云仓库存详情
- public function actionGetCloudPreviewNumInfo(){
- $post = get_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->getCloudPreviewNumInfo());
- }
- //订单取消审核
- public function actionSupplierPurchaseCancel(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierPurchaseCancel());
- }
- //订单发货
- public function actionSupplierPurchaseSend(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierPurchaseSend());
- }
- //订单发货
- public function actionUpdateOrderSendInfo(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->updateOrderSendInfo());
- }
- //订单删除
- public function actionSupplierPurchaseDel(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierPurchaseDel());
- }
- //订单删除
- public function actionSupplierOrderDel(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierOrderDel());
- }
-
- //转单列表
- public function actionSupplierPurchaseOrderList(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierPurchaseOrderList());
- }
- //转单售后列表
- public function actionSupplierPurchaseOrderRefundList(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierPurchaseOrderRefundList());
- }
- //转单售后列表
- public function actionSupplierSendTypeRefundList(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierSendTypeRefundList());
- }
- //处理退换货请求
- public function actionSupplierApplyHandle()
- {
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierApplyHandle());
- }
- //供货商提现申请
- public function actionSetSupplierCash(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->storeSetSupplierCash());
- }
- //余额记录
- public function actionSupplierGetBalanceLog(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierGetBalanceLog());
- }
- //余额冻结记录
- public function actionSupplierGetBalanceFrozenLog(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->supplierGetBalanceFrozenLog());
- }
- //编辑运费
- public function actionSetRules(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->setRules());
- }
- //提交审核
- public function actionAuditSubmit(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->auditSubmit());
- }
- //商品上下架操作
- public function actionSetGoodsStatus(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->setGoodsStatus());
- }
- //添加编辑规格
- public function actionSetGoodsAttr(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->setGoodsAttr());
- }
- //创建编辑商品
- public function actionSetGoods(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->setGoods());
- }
- //获取供货商商品列表
- public function actionGoodsList(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->goodsList());
- }
- //获取供货商商品列表
- public function actionGoodsAuditList(){
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->goodsAuditList());
- }
- //获取供货商转单订单详情
- public function actionPurchaseOrderInfo(){
- $post = get_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- // $this->asJson($form->purchaseOrderInfo(111));
- $form->purchaseOrderInfo(get_params("order_id"), get_params("supplier_id"));
- }
- //获取集采列表
- public function actionAgentOrderGroupList(){
- $post = get_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->agentOrderGroupList());
- }
- //生成配货单
- public function actionAgentOrderDistribution() {
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->agentOrderDistribution());
- }
- //配送单列表
- public function actionAgentOrderDistributionList() {
- $post = get_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->agentOrderDistributionList());
- }
- //更改配货单状态
- public function actionSetDistributionStatus() {
- $post = post_params();
- $form = new SupplierForm();
- $form->attributes = $post;
- $this->asJson($form->setDistributionStatus());
- }
- public function actionGetKefuInfo()
- {
- $supplier = Supplier::findOne(get_supplier_id());
- if (!$supplier) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '数据不存在',
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data'=> [
- 'kefu_id' => $supplier->kefu_id ?: '',
- ]
- ]);
- }
- public function actionSetKefuInfo()
- {
- $kefu_id = \post_params('kefu_id');
- $supplier = Supplier::findOne(get_supplier_id());
- if (!$supplier) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '数据不存在',
- ]);
- }
- if (!empty($kefu_id)) {
- $url = Kefu::API_HOST;
- $host = \str_replace(['http://', 'https://'], '', \Yii::$app->request->hostInfo);
- $res = http_post($url . '/api/regKefu', [
- 'form_params' => [
- 'token' => \Yii::$app->getKefuApiToken(),
- 'host' => $host,
- 'mobile' => $kefu_id,
- ]
- ]);
- if ($res->getStatusCode() != 200) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '请求出错!',
- ]);
- }
- $content = json_decode((string)$res->getBody(), true);
- if ($content['code'] == 0) {
- $supplier->kefu_id = $kefu_id;
- $supplier->save();
- }
- } else {
- $supplier->kefu_id = '';
- $supplier->save();
- $content = [
- 'code' => 0,
- 'msg' => '保存成功',
- ];
- }
- return $this->asJson($content);
- }
- /**
- * 修改价格
- * @return mixed
- */
- public function actionModifyPrice()
- {
- $form = new SupplierForm();
- $form->attributes = post_params();
- return $this->asJson($form->modifyPrice());
- }
- //获取仓库采购订单
- public function actionPurchaseList() {
- $form = new \app\modules\admin\models\agent\front_erp\PurchaseForm();
- // $admin = get_admin();
- // if (!$admin) {
- // return $this->asJson([
- // 'code' => 1,
- // 'msg' => '需要登录'
- // ]);
- // }
- // if ($admin->type !== Admin::ADMIN_TYPE_SUPPLIER) {
- // return $this->asJson([
- // 'code' => 1,
- // 'msg' => '当前供货商身份验证失败'
- // ]);
- // }
- $form->admin_supplier_id = get_supplier_id();
- $form->attributes = post_params();
- return $this->asJson($form->search());
- }
- //获取仓库采购订单
- public function actionPurchaseInfo() {
- $form = new \app\modules\admin\models\agent\front_erp\PurchaseForm();
- // $admin = get_admin();
- // if (!$admin) {
- // return $this->asJson([
- // 'code' => 1,
- // 'msg' => '需要登录'
- // ]);
- // }
- // if ($admin->type !== Admin::ADMIN_TYPE_SUPPLIER) {
- // return $this->asJson([
- // 'code' => 1,
- // 'msg' => '当前供货商身份验证失败'
- // ]);
- // }
- $form->admin_supplier_id = get_supplier_id();
- $form->attributes = all_params();
- return $this->asJson($form->info());
- }
- //打印仓库采购订单
- public function actionPrintPurchase() {
- $form = new \app\modules\admin\models\agent\front_erp\PurchaseForm();
- $form->admin_supplier_id = get_supplier_id();
- $form->attributes = all_params();
- $res = $form->searchPurchase();
- return $this->asJson($res);
- }
- //供货商修改采购订单状态(发货)
- public function actionSetPurchaseOrderStatus() {
- $form = new \app\modules\admin\models\agent\front_erp\PurchaseForm();
- // $admin = get_admin();
- // if (!$admin) {
- // return $this->asJson([
- // 'code' => 1,
- // 'msg' => '需要登录'
- // ]);
- // }
- // if ($admin->type !== Admin::ADMIN_TYPE_SUPPLIER) {
- // return $this->asJson([
- // 'code' => 1,
- // 'msg' => '当前供货商身份验证失败'
- // ]);
- // }
- $form->admin_supplier_id = get_supplier_id();
- $form->attributes = all_params();
- return $this->asJson($form->setPurchaseOrderStatus());
- }
- }
|