shish %!s(int64=5) %!d(string=hai) anos
pai
achega
1524a5446d

+ 1 - 1
app/hd/controllers/PxApplyController.php

@@ -36,7 +36,7 @@ class PxApplyController extends BaseController
 		$get['classCover'] = $info['cover'] ?? '';
 		$get['applyTime'] = date("Y-m-d H:i:s");
 		$get['status'] = PxApplyClass::STATUS_CONFIRM;
-		PxApplyClass::addApply($get);
+		PxApplyClass::addApply($get, $this->shop);
 		util::complete();
 	}
 	

+ 9 - 0
app/hd/controllers/PxClassController.php

@@ -4,6 +4,7 @@ namespace hd\controllers;
 
 use bizHd\px\classes\PxClassClass;
 use common\components\util;
+use Yii;
 
 /**
  * 培训班
@@ -19,4 +20,12 @@ class PxClassController extends BaseController
 		util::success(['list' => $class]);
 	}
 
+	public function actionDetail()
+	{
+		$id = Yii::$app->request->get('id');
+		$info = PxClassClass::getClassInfo($id);
+		PxClassClass::valid($info, $this->sjId);
+		util::success($info);
+	}
+
 }

+ 14 - 1
biz-hd/px/classes/PxApplyClass.php

@@ -2,7 +2,10 @@
 
 namespace bizHd\px\classes;
 
+use biz\shop\classes\ShopClass;
+use biz\sj\classes\SjCapitalClass;
 use bizHd\custom\classes\CustomClass;
+use bizHd\stat\classes\StatStudentClass;
 use common\components\imgUtil;
 use common\components\orderSn;
 use Yii;
@@ -17,9 +20,19 @@ class PxApplyClass extends BaseClass
 	const  STATUS_CONFIRM = 2;
 	
 	//培训报名 shish 2021.3.17
-	public static function addApply($data)
+	public static function addApply($data, $shop)
 	{
 		$data['orderSn'] = orderSn::getPxApplySn();
+		
+		StatStudentClass::addStudent($shop);
+		
+		$shopId = $shop['id'];
+		$totalIncome = bcadd($shop['totalIncome'], $data['actPrice'], 2);
+		ShopClass::updateById($shopId, ['totalIncome' => $totalIncome]);
+
+		$capitalData = [];
+		SjCapitalClass::addCapital($capitalData);
+		
 		return self::add($data);
 	}
 	

+ 27 - 0
biz-hd/stat/classes/StatStudentClass.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace bizHd\stat\classes;
+
+use Yii;
+use bizHd\base\classes\BaseClass;
+
+class StatStudentClass extends BaseClass
+{
+	
+	public static $baseFile = '\bizHd\stat\models\StatStudent';
+	
+	public static function addStudent($shop, $date = null)
+	{
+		$shopId = $shop['id'];
+		$date = isset($date) ? $date : date("Ymd");
+		$stat = self::getByCondition(['shopId' => $shopId, 'time' => $date], true);
+		if (empty($stat)) {
+			$stat = self::add(['shopId' => $shopId, 'time' => $date], true);
+		}
+		$stat->riseNum += 1;
+		$stat->totalNum = $shop['totalStudent'] + 1;
+		$stat->save();
+		StatStudentMonthClass::addStudent($shop);
+	}
+	
+}

+ 27 - 0
biz-hd/stat/classes/StatStudentMonthClass.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace bizHd\stat\classes;
+
+use Yii;
+use bizHd\base\classes\BaseClass;
+
+class StatStudentMonthClass extends BaseClass
+{
+	
+	public static $baseFile = '\bizHd\stat\models\StatStudentMonth';
+	
+	//月订单数增加 shish 2020.5.25
+	public static function addStudent($shop, $month = null)
+	{
+		$shopId = $shop['id'];
+		$month = isset($month) ? $month : date("Ym");
+		$stat = self::getByCondition(['sjId' => $sjId, 'time' => $month], true);
+		if (empty($stat)) {
+			$stat = self::add(['sjId' => $sjId, 'time' => $month], true);
+		}
+		$stat->riseNum += 1;
+		$stat->totalNum = $shop['totalStudent'] + 1;
+		$stat->save();
+	}
+	
+}

+ 13 - 0
biz-hd/stat/models/StatStudent.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizHd\stat\models;
+use bizHd\base\models\Base;
+
+class StatStudent extends Base
+{
+
+	public static function tableName()
+	{
+		return 'xhStatStudent';
+	}
+
+}

+ 13 - 0
biz-hd/stat/models/StatStudentMonth.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizHd\stat\models;
+use bizHd\base\models\Base;
+
+class StatStudentMonth extends Base
+{
+
+	public static function tableName()
+	{
+		return 'xhStatStudentMonth';
+	}
+
+}

+ 13 - 0
biz-hd/stat/services/StatStudentMonthService.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace bizHd\stat\services;
+
+use bizHd\base\services\BaseService;
+use Yii;
+
+class StatStudentMonthService extends BaseService
+{
+
+	public static $baseFile = '\bizHd\stat\classes\StatStudentMonthClass';
+
+}

+ 19 - 0
biz-hd/stat/services/StatStudentService.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace bizHd\stat\services;
+
+use bizHd\base\services\BaseService;
+use Yii;
+
+class StatStudentService extends BaseService
+{
+
+    public static $baseFile = '\bizHd\stat\classes\StatStudentClass';
+
+    public static function getTodayNum($merchantId)
+    {
+        $today = date("Ymd");
+        return StatOrderClass::getByCondition(['merchantId' => $merchantId, 'time' => $today]);
+    }
+
+}

+ 75 - 1
sql.sql

@@ -1544,4 +1544,78 @@ ALTER TABLE xhPxApply ADD classCover VARCHAR(500) NOT NULL DEFAULT '' COMMENT '
 ALTER TABLE `xhActOrder` CHANGE `payCode` `returnCode` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '支付返回数据';
 ALTER TABLE `xhGhsOrder` CHANGE `payCode` `returnCode` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '支付返回数据';
 ALTER TABLE `xhOrder` CHANGE `payCode` `returnCode` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '支付返回数据';
-ALTER TABLE xhPxApply ADD applyTime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '报名时间' AFTER payTime;
+ALTER TABLE xhPxApply ADD applyTime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '报名时间' AFTER payTime;
+ALTER TABLE xhShop ADD totalStudent INT NOT NULL DEFAULT 0 COMMENT '总学员数' AFTER `totalRecharge`;
+CREATE TABLE `xhStatStudent` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `time` INT(11) NOT NULL DEFAULT '0' COMMENT '时间戳',
+  `riseNum` INT(11) NOT NULL DEFAULT '0' COMMENT '增加数量',
+  `totalNum` INT(11) NOT NULL DEFAULT '0' COMMENT '总数量',
+  `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
+  `shopId` INT(11) NOT NULL DEFAULT '0' COMMENT '门店id',
+  PRIMARY KEY (`id`),
+  KEY `sjId` (`time`,`shopId`)
+) COMMENT='每天新增学员数';
+CREATE TABLE `xhStatStudentMonth` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `time` INT(11) NOT NULL DEFAULT '0' COMMENT '月份',
+  `year` SMALLINT(6) NOT NULL DEFAULT '0' COMMENT '年',
+  `month` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '月份',
+  `riseNum` INT(11) NOT NULL DEFAULT '0' COMMENT '增加数量',
+  `totalNum` INT(11) NOT NULL DEFAULT '0' COMMENT '总数量',
+  `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
+  `shopId` INT(11) NOT NULL DEFAULT '0' COMMENT '门店id',
+  PRIMARY KEY (`id`),
+  KEY `sjId` (`year`,`month`,`shopId`)
+) COMMENT='每月新增学员数';
+DROP TABLE IF EXISTS `xhUserCapital`;
+CREATE TABLE `xhCustomCapital` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `userId` INT(11) NOT NULL DEFAULT '0' COMMENT '用户id',
+  `alipayId` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '支付宝用户id',
+  `merchantId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
+  `relateId` INT(11) NOT NULL DEFAULT '0' COMMENT '关联id;订单id',
+  `capitalType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '流水订单的类型 参考configDict capitalType',
+  `operateId` INT(11) NOT NULL DEFAULT '0' COMMENT '操作人id adminId 等',
+  `balance` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '余额',
+  `amount` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '金额',
+  `io` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '收支类型0支出 1收入',
+  `totalIncome` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计收入',
+  `totalExpend` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计支出',
+  `payWay` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '资金收支方式0微信1支付宝2余额3现金,具体请查看配置文件configDict payWay',
+  `event` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '事项,说明,类型的具体解释',
+  `userName` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '用户名',
+  `remark` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '备注',
+`addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
+  `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+  PRIMARY KEY (`id`)
+) COMMENT='客户收支';
+CREATE TABLE `xhShopCapital` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `relateId` INT(11) NOT NULL DEFAULT '0' COMMENT '关联id;订单id',
+  `capitalType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '流水类型',
+  `balance` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '余额',
+  `affectBalance` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '是否影响商家的可提现余额 0不影响 1影响,如支付宝支付,提现',
+  `amount` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '本次流水金额',
+  `io` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '收支类型 0支出 1收入',
+  `totalIncome` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计收入变化',
+  `totalExpend` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计支出变化',
+  `payWay` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '付款方式;支付方式',
+  `sourceType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '来源',
+  `fromType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '来源 0门店 1商城 2朋友圈 3..',
+  `usageId` INT(11) NOT NULL DEFAULT '0' COMMENT '用途id',
+  `categoryId` INT(11) NOT NULL DEFAULT '0' COMMENT '分类id',
+  `event` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '事项,说明,类型的具体解释',
+  `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
+  `shopId` INT(11) NOT NULL DEFAULT '0' COMMENT '0表示商家所有门店',
+  `userId` INT(11) NOT NULL DEFAULT '0' COMMENT '用户id',
+  `userName` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '用户名',
+  `alipayId` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '支付宝的uid',
+  `operateId` INT(11) NOT NULL DEFAULT '0' COMMENT '操作人 adminId userId merchantId',
+  `remark` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '备注',
+`addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
+  `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+  PRIMARY KEY (`id`)
+) COMMENT='门店收支';
+ALTER TABLE `xhSjCapital` DROP COLUMN `shopId`;
+ALTER TABLE `xhSjCapital` CHANGE merchantId `sjId` INT NOT NULL DEFAULT 0 COMMENT '商家id';