|
|
@@ -2,11 +2,12 @@
|
|
|
|
|
|
namespace ghs\controllers;
|
|
|
|
|
|
+use biz\shop\classes\ShopClass;
|
|
|
use biz\sj\classes\SjClass;
|
|
|
-use bizHd\saas\classes\ApplyClass;
|
|
|
-use bizHd\saas\services\ApplyService;
|
|
|
+use biz\sj\services\MerchantService;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\custom\services\CustomService;
|
|
|
+use bizHd\saas\classes\ApplyClass;
|
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
@@ -14,6 +15,107 @@ use Yii;
|
|
|
class CustomController extends BaseController
|
|
|
{
|
|
|
|
|
|
+ //添加新花店 shish 2021.1.8
|
|
|
+ public function actionAdd()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $post['style'] = SjClass::STYLE_RETAIL;
|
|
|
+ $post['introSjId'] = $this->sjId;
|
|
|
+ $post['introStyle'] = SjClass::STYLE_SUPPLIER;
|
|
|
+ $mobile = $post['mobile'] ?? '';
|
|
|
+ $confirmMobile = $post['confirmMobile'];
|
|
|
+ if (stringUtil::isMobile($mobile) == false) {
|
|
|
+ util::fail(' 请填写正确的手机号');
|
|
|
+ }
|
|
|
+ if ($mobile != $confirmMobile) {
|
|
|
+ util::fail('二次号码填写不一致');
|
|
|
+ }
|
|
|
+ $name = $post['name'] ?? '';
|
|
|
+ if (empty($name)) {
|
|
|
+ util::fail('名称不能为空');
|
|
|
+ }
|
|
|
+ if (stringUtil::getWordNum($name) > 8) {
|
|
|
+ util::fail('名称不能超过8个汉字');
|
|
|
+ }
|
|
|
+ $has = SjClass::getByCondition(['name' => $name, 'style' => ApplyClass::FROM_GHS]);
|
|
|
+ if (!empty($has)) {
|
|
|
+ util::fail('名称已经存在');
|
|
|
+ }
|
|
|
+ $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => ApplyClass::FROM_GHS]);
|
|
|
+ if (!empty($has)) {
|
|
|
+ util::fail('手机号已经添加过');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'id' => 2,
|
|
|
+ 'name' => '小石头',
|
|
|
+ 'avatar' => 'https://img.huaml.com/ghs/home/deserve.png',
|
|
|
+ ];
|
|
|
+ util::success($data);
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $date = date("Y-m-d H:i:s");
|
|
|
+ $shop = $this->shop;
|
|
|
+ $city = $shop->city ?? '';
|
|
|
+ $dist = $shop->dist ?? '';
|
|
|
+ $address = $post['address'] ?? '';
|
|
|
+ $fullAddress = $city . $dist . $address;
|
|
|
+ $apply = [
|
|
|
+ 'logo' => '',
|
|
|
+ 'name' => '',
|
|
|
+ 'hasLicense' => '',
|
|
|
+ 'licenseNo' => '',
|
|
|
+ 'certType' => '',
|
|
|
+ 'adminId' => '',
|
|
|
+ 'adminName' => '未命名',
|
|
|
+ 'mobile' => $mobile,
|
|
|
+ 'introSjId' => 0,
|
|
|
+ 'introSjName' => '',
|
|
|
+ 'introShopId' => 0,
|
|
|
+ 'customId' => '',
|
|
|
+ 'shopAdminId' => '',
|
|
|
+ 'from' => '',
|
|
|
+ 'fee' => '',
|
|
|
+ 'income' => '',
|
|
|
+ 'sjId' => '',
|
|
|
+ 'style' => SjClass::STYLE_RETAIL,
|
|
|
+ 'main' => '',
|
|
|
+ 'long' => '',
|
|
|
+ 'lat' => '',
|
|
|
+ 'province' => $shop->province ?? '',
|
|
|
+ 'city' => $city,
|
|
|
+ 'dist' => $dist,
|
|
|
+ 'address' => $address,
|
|
|
+ 'floor' => '',
|
|
|
+ 'fullAddress' => $fullAddress,
|
|
|
+ 'showAddress' => '',
|
|
|
+ 'remark' => '',
|
|
|
+ 'status' => 2,
|
|
|
+ 'addTime' => $date,
|
|
|
+ 'updateTime' => $date,
|
|
|
+ ];
|
|
|
+ $sj = MerchantService::initSjInfo($apply);
|
|
|
+ $sjId = $sj['id'] ?? 0;
|
|
|
+ if (empty($sjId)) {
|
|
|
+ util::fail('添加客户没有成功');
|
|
|
+ }
|
|
|
+ $hdShop = ShopClass::getByCondition(['sjId' => $sjId], true);
|
|
|
+ $hdShopId = $hdShop->id ?? 0;
|
|
|
+ if (empty($hdShopId)) {
|
|
|
+ util::fail('添加客户没有成功!');
|
|
|
+ }
|
|
|
+ $custom = CustomClass::build($this->shopId, $hdShopId);
|
|
|
+ $transaction->commit();
|
|
|
+ util::success($custom);
|
|
|
+ } catch (\Exception $exception) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("添加客户没有成功:" . $exception->getMessage());
|
|
|
+ util::fail('添加客户没有成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//客户列表 ssh 2021.7.8
|
|
|
public function actionList()
|
|
|
{
|