Jelajahi Sumber

Merge branch 'master' of git.huaml.com:zhh/huahuibao

shishao-home 6 tahun lalu
induk
melakukan
77e5ffce83

+ 5 - 4
app/business/controllers/AdController.php

@@ -98,14 +98,15 @@ class AdController extends BaseController
 		util::ok('删除成功');
 	}
 
-	//下架广告
-	public function actionOff()
+	//下架广告
+	public function actionUpdateStatus()
 	{
 		$id = Yii::$app->request->get('id', 0);
+		$status = Yii::$app->request->get('status', 1);
 		$info = AdService::getById($id);
 		AdService::valid($info, $this->merchantId);
-		AdService::updateById($id,['status'=>0]);
-		util::ok('下架成功');
+		AdService::updateById($id,['status'=>$status]);
+		util::ok('操作成功');
 	}
 	
 	//广告详情

+ 2 - 2
app/client/controllers/TestController.php

@@ -9,9 +9,9 @@ class TestController extends BaseController
 
 	public function actionRabbit()
 	{
-		$producer = Yii::$app->rabbitmq->getProducer('producer_1');
+		$producer = Yii::$app->rabbitmq->getProducer('producerCommon');
 		$msg = serialize(['user_id' => rand(111,999)]);
-		$producer->publish($msg, 'ex_1', 'route_1');
+		$producer->publish($msg, 'exCommon', 'routeCommon');
 	}
 
 }

+ 2 - 46
biz/merchant/models/MerchantAsset.php

@@ -4,54 +4,10 @@ use biz\base\models\Base;
 
 class MerchantAsset extends Base
 {
-	/**
-	 * @inheritdoc
-	 */
+
 	public static function tableName()
 	{
 		return 'xhMerchantAsset';
 	}
-	
-	/**
-	 * @inheritdoc
-	 */
-	public function rules()
-	{
-		return [
-			[['balance', 'freezeBalance', 'totalRecharge', 'totalUseRecharge', 'totalIncome', 'totalExpend'], 'number'],
-			[['totalVisit', 'totalUser', 'totalMember', 'totalFans', 'totalWeixinFans', 'totalIntegral', 'totalPoint', 'totalGoods', 'totalOrder', 'totalDeal', 'merchantId'], 'integer'],
-			[['createTime'], 'required'],
-			[['createTime', 'updateTime'], 'safe'],
-			[['merchantId'], 'unique'],
-		];
-	}
-	
-	/**
-	 * @inheritdoc
-	 */
-	public function attributeLabels()
-	{
-		return [
-			'id' => 'ID',
-			'balance' => 'Balance',
-			'freezeBalance' => 'Freeze Balance',
-			'totalVisit' => 'Total Visit',
-			'totalUser' => 'Total User',
-			'totalMember' => 'Total Member',
-			'totalFans' => 'Total Fans',
-			'totalWeixinFans' => 'Total Weixin Fans',
-			'totalIntegral' => 'Total Integral',
-			'totalPoint' => 'Total Point',
-			'totalGoods' => 'Total Goods',
-			'totalRecharge' => 'Total Recharge',
-			'totalUseRecharge' => 'Total Use Recharge',
-			'totalOrder' => 'Total Order',
-			'totalDeal' => 'Total Deal',
-			'merchantId' => 'Merchant ID',
-			'totalIncome' => 'Total Income',
-			'totalExpend' => 'Total Expend',
-			'createTime' => 'Create Time',
-			'updateTime' => 'Update Time',
-		];
-	}
+
 }

+ 96 - 0
biz/message/classes/InformAdminClass.php

@@ -9,5 +9,101 @@ class InformAdminClass extends BaseClass
 {
 	
 	public static $baseFile = '\biz\message\models\InformAdmin';
+	
+	//宝贝售出通知 shish 2019.12.24
+	public static function goodsSoldInformAdmin($params, $informWay = 0, $TMList = [])
+	{
+		$params = [];
+		if ($informWay == 'wx') {
+			//收入提醒
+			$shortTempId = 'OPENTM207422813';
+			$tempId = isset($TMList[$shortTempId]) ? $TMList[$shortTempId] : '';
+			$tmData = ["touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderId, "data" => [
+				"first" => ["value" => '您有宝贝售出哦!', "color" => "#173177"],
+				"keyword1" => ["value" => (string)$orderId, "color" => "#173177"],
+				"keyword2" => ["value" => $orderName, "color" => "#173177"],
+				"keyword3" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
+				"keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
+				"keyword5" => ["value" => $userName, "color" => "#173177"],
+				"remark" => ["value" => '点此查看详细、编辑收花人信息。', "color" => "#173177"]]];
+			return $tmData;
+		}
+		if ($informWay == 'sms') {
+			return "客户" . $userName . "付款" . $totalFee . '元';
+		}
+	}
 
+	//宝贝售出通知 shish 2019.12.24
+	public static function inform($params, $type, $informWay = 0, $TMList = [])
+	{
+		switch ($type) {
+			case 'goodsSoldInformAdmin':
+				$respond = self::goodsSoldInformAdmin($params, $informWay, $TMList);
+				break;
+			default:
+		}
+		return $respond;
+	}
+	
+	//门店收入提醒 shish 2019.12.24
+	public static function shopIncomeInformAdmin2($data, $merchantId = 0)
+	{
+		$TMList = xhTMessageService::getList($merchantId);
+		$adminList = AdminClass::getAllNoticeAdmin($merchantId);
+		$merchant = MerchantService::getById($merchantId);
+		$shortTempId = 'OPENTM207422813';//收入提醒
+		if (isset($TMList[$shortTempId]) == false) {
+			util::fail('没有找到公众号的消息模样:' . $shortTempId);
+		}
+		$tempId = $TMList[$shortTempId];
+		foreach ($adminList as $adminKey => $admin) {
+			$openId = $admin['openId'];
+			if (!empty($openId) && $admin['subscribe'] == 1) {
+				$data = ["touser" => $openId, "template_id" => $tempId,
+					"url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderId, "data" => [
+						"first" => ["value" => $userName . $payWay . '付款', "color" => "#173177"],
+						"keyword1" => ["value" => $totalFee . '元', "color" => "#173177"],
+						"keyword2" => ["value" => '客户付款', "color" => "#173177"],
+						"keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
+						"remark" => ["value" => "点击查看明细", "color" => "#173177"]]];
+				$respond = weixinUtil::sendTaskInform($data, $merchant);
+				Yii::info('tm:' . json_encode($respond));
+			} else {
+				$mobile = $admin['mobile'];
+				$msg = "客户" . $userName . "付款" . $totalFee . '元';
+				sms::merchantSend($mobile, $msg, $merchant);
+			}
+		}
+	}
+	
+	//宝贝售出通知 shish 2019.12.24
+	public static function goodsSoldInformAdmin2($merchantId)
+	{
+		
+		$TMList = xhTMessageService::getList($merchantId);
+		$merchant = MerchantService::getById($merchantId);
+		$shortTempId = 'OPENTM207422813';//收入提醒
+		$tempId = isset($TMList[$shortTempId]) ? $TMList[$shortTempId] : '';
+		foreach ($adminList as $adminKey => $admin) {
+			$openId = $admin['openId'];
+			if (!empty($openId) && $admin['subscribe'] == 1) {
+				$sendData = ["touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderId, "data" => [
+					"first" => ["value" => '您有宝贝售出哦!', "color" => "#173177"],
+					"keyword1" => ["value" => (string)$orderId, "color" => "#173177"],
+					"keyword2" => ["value" => $orderName, "color" => "#173177"],
+					"keyword3" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
+					"keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
+					"keyword5" => ["value" => $userName, "color" => "#173177"],
+					"remark" => ["value" => '点此查看详细、编辑收花人信息。', "color" => "#173177"]]];
+				$respond = weixinUtil::sendTaskInform($sendData, $merchant);
+				Yii::info('tm:' . json_encode($respond));
+			} else {
+				$mobile = $admin['mobile'];
+				$msg = "客户" . $userName . "付款" . $totalFee . '元';
+				sms::merchantSend($mobile, $msg, $merchant);
+			}
+		}
+	}
+	
+	
 }

+ 13 - 57
biz/message/services/InformAdminService.php

@@ -3,84 +3,40 @@
 namespace biz\message\services;
 
 use biz\admin\classes\AdminClass;
-use biz\admin\services\AdminService;
 use biz\base\services\BaseService;
 use biz\merchant\services\MerchantService;
+use biz\message\classes\InformAdminClass;
 use common\components\sms;
-use common\components\util;
+use common\components\weixinUtil;
+use common\services\xhTMessageService;
 use Yii;
-use linslin\yii2\curl;
 
 class InformAdminService extends BaseService
 {
-	
+
 	public static $baseFile = '\biz\message\classes\InformAdminClass';
-	
-	//门店收入提醒 shish 2019.12.24
-	public static function shopIncomeInformAdmin($data, $merchantId = 0)
+
+	//通知到员工 shish 2020.1.1
+	public static function inform($merchantId, $type, $params)
 	{
-		$TMList = xhTMessageService::getList($merchantId);
 		$adminList = AdminClass::getAllNoticeAdmin($merchantId);
-		$merchant = MerchantService::getById($merchantId);
-		$shortTempId = 'OPENTM207422813';//收入提醒
-		if (isset($TMList[$shortTempId]) == false) {
-			util::fail('没有找到公众号的消息模样:' . $shortTempId);
-		}
-		$tempId = $TMList[$shortTempId];
-		foreach ($adminList as $adminKey => $admin) {
-			$openId = $admin['openId'];
-			if (!empty($openId) && $admin['subscribe'] == 1) {
-				$data = ["touser" => $openId, "template_id" => $tempId,
-					"url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderId, "data" => [
-						"first" => ["value" => $userName . $payWay . '付款', "color" => "#173177"],
-						"keyword1" => ["value" => $totalFee . '元', "color" => "#173177"],
-						"keyword2" => ["value" => '客户付款', "color" => "#173177"],
-						"keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
-						"remark" => ["value" => "点击查看明细", "color" => "#173177"]]];
-				$respond = weixinUtil::sendTaskInform($data, $merchant);
-				Yii::info('tm:' . json_encode($respond));
-			} else {
-				$mobile = $admin['mobile'];
-				$msg = "客户" . $userName . "付款" . $totalFee . '元';
-				sms::merchantSend($mobile, $msg, $merchant);
-			}
+		if (empty($adminList)) {
+			return false;
 		}
-	}
-
-	//宝贝售出通知 shish 2019.12.24
-	//有多少人要通知
-	public static function goodsSoldInformAdmin($data)
-	{
 		$TMList = xhTMessageService::getList($merchantId);
-		$adminList = AdminClass::getAllNoticeAdmin($merchantId);
 		$merchant = MerchantService::getById($merchantId);
-		$shortTempId = 'OPENTM207422813';//收入提醒
-		if (isset($TMList[$shortTempId]) == false) {
-			util::fail('没有找到公众号的消息模样:' . $shortTempId);
-		}
-		$tempId = $TMList[$shortTempId];
 		foreach ($adminList as $adminKey => $admin) {
 			$openId = $admin['openId'];
+			$informWay = !empty($openId) && $admin['subscribe'] == 1 ? 'wx' : 'sms';
+			$sendData = InformAdminClass::inform($params, $type, $informWay, $TMList);
 			if (!empty($openId) && $admin['subscribe'] == 1) {
-				$tmData = ["touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderId, "data" => [
-					"first" => ["value" => '您有宝贝售出哦!', "color" => "#173177"],
-					"keyword1" => ["value" => (string)$orderId, "color" => "#173177"],
-					"keyword2" => ["value" => $orderName, "color" => "#173177"],
-					"keyword3" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
-					"keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
-					"keyword5" => ["value" => $userName, "color" => "#173177"],
-					"remark" => ["value" => '点此查看详细、编辑收花人信息。', "color" => "#173177"]]];
-				$respond = weixinUtil::sendTaskInform($tmData, $merchant);
+				$respond = weixinUtil::sendTaskInform($sendData, $merchant);
 				Yii::info('tm:' . json_encode($respond));
 			} else {
 				$mobile = $admin['mobile'];
-				$msg = "客户" . $userName . "付款" . $totalFee . '元';
-				sms::merchantSend($mobile, $msg, $merchant);
+				sms::merchantSend($mobile, $sendData, $merchant);
 			}
 		}
-
-
-
 	}
 	
 }

+ 4 - 3
biz/order/classes/OrderClass.php

@@ -27,10 +27,11 @@ class OrderClass extends BaseClass
 		$year = date("Y");
 		$month = date("m");
 		//后面要把下面二个service方法移到class层
-		xhOrderDayNumService::addOne($time, $merchantId);
-		$monthReturn = xhOrderMonthNumService::addOne($year, $month, $merchantId);
+		//xhOrderDayNumService::addOne($time, $merchantId);
+		//$monthReturn = xhOrderMonthNumService::addOne($year, $month, $merchantId);
 		//将花店每月的总订单数作为编号
-		$data['sendNum'] = (string)$monthReturn['riseNum'];
+		//$data['sendNum'] = (string)$monthReturn['riseNum'];
+		$data['sendNum'] = 0;
 		$return = self::add($data);
 		return $return;
 	}

+ 13 - 0
biz/stat/classes/StatOrderClass.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace biz\stat\classes;
+
+use Yii;
+use biz\base\classes\BaseClass;
+
+class StatOrderClass extends BaseClass
+{
+	
+	public static $baseFile = '\biz\stat\models\StatOrder';
+
+}

+ 13 - 0
biz/stat/models/StatOrder.php

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

+ 13 - 0
biz/stat/services/StatOrderService.php

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

+ 0 - 70
common/models/xhMerchantAsset.php

@@ -2,80 +2,10 @@
 
 namespace common\models;
 
-/**
- * This is the model class for table "xhMerchantAsset".
- *
- * @property int $id
- * @property string $balance 余额
- * @property string $freezeBalance 提现时被冻结的余额
- * @property int $totalVisit 总访问量
- * @property int $totalUser 总用户
- * @property int $totalMember 总会员
- * @property int $totalFans 总粉丝
- * @property int $totalWeixinFans 微信公众号里的粉丝数
- * @property int $totalIntegral 总积分
- * @property int $totalPoint 积分
- * @property int $totalGoods 总计商品数量
- * @property string $totalRecharge 累计给用户充值金额
- * @property string $totalUseRecharge 充值消费收入,给用户充值金额已经使用部分
- * @property int $totalOrder 总计订单,线上
- * @property int $totalDeal 总计交易量,包括线上线下
- * @property int $merchantId 商户id
- * @property string $totalIncome 累计收入
- * @property string $totalExpend 累计消费
- * @property string $createTime 创建时间
- * @property string $updateTime
- */
 class xhMerchantAsset extends xhBaseModel
 {
-    /**
-     * @inheritdoc
-     */
     public static function tableName()
     {
         return 'xhMerchantAsset';
     }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['balance', 'freezeBalance', 'totalRecharge', 'totalUseRecharge', 'totalIncome', 'totalExpend'], 'number'],
-            [['totalVisit', 'totalUser', 'totalMember', 'totalFans', 'totalWeixinFans', 'totalIntegral', 'totalPoint', 'totalGoods', 'totalOrder', 'totalDeal', 'merchantId'], 'integer'],
-            [['createTime'], 'required'],
-            [['createTime', 'updateTime'], 'safe'],
-            [['merchantId'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'balance' => 'Balance',
-            'freezeBalance' => 'Freeze Balance',
-            'totalVisit' => 'Total Visit',
-            'totalUser' => 'Total User',
-            'totalMember' => 'Total Member',
-            'totalFans' => 'Total Fans',
-            'totalWeixinFans' => 'Total Weixin Fans',
-            'totalIntegral' => 'Total Integral',
-            'totalPoint' => 'Total Point',
-            'totalGoods' => 'Total Goods',
-            'totalRecharge' => 'Total Recharge',
-            'totalUseRecharge' => 'Total Use Recharge',
-            'totalOrder' => 'Total Order',
-            'totalDeal' => 'Total Deal',
-            'merchantId' => 'Merchant ID',
-            'totalIncome' => 'Total Income',
-            'totalExpend' => 'Total Expend',
-            'createTime' => 'Create Time',
-            'updateTime' => 'Update Time',
-        ];
-    }
 }

+ 11 - 7
common/services/xhMerchantAssetService.php

@@ -59,7 +59,7 @@ class xhMerchantAssetService
 		Yii::$app->redis->executeCommand('DEL', [$key]);
 		return self::getByMerchantId($merchantId);
 	}
-
+	
 	//收入后资产变更 shish 2019.12.24
 	public static function incomeChangeAsset($merchant, $merchantAsset, $updateData, $order, $capitalType)
 	{
@@ -94,27 +94,31 @@ class xhMerchantAssetService
 						}
 					}
 				}
-				//商城下单后通知
 				if ($order['sourceType'] == 0) {
-					//InformAdminService::goodsSoldInformAdmin($data);
-				//门店收入后通知
+					//商城下单后通知
+					$data = [];
+					InformAdminService::goodsSoldInformAdmin($data);
 				} else {
-					//InformAdminService::shopIncomeInformAdmin($data);
+					//门店收入后通知
+					$data = [];
+					InformAdminService::shopIncomeInformAdmin($data);
 				}
 				break;
 		}
 		$asset = self::updateByMerchantId($merchantId, $updateData);
 		//以下一定要排后面,否则数据不准确
 		if ($totalFee > 0) {
-			xhStatIncomeService::replace($merchantId, $totalFee, $order['payWay']);
-			xhStatIncomeMonthService::replace($merchantId, $totalFee, $order['payWay']);
+			//xhStatIncomeService::replace($merchantId, $totalFee, $order['payWay']);
+			//xhStatIncomeMonthService::replace($merchantId, $totalFee, $order['payWay']);
 			/**收入来源资金增加**/
+			/*
 			StatIncomeSourceService::replaceData([
 				'merchantId' => $order['merchantId'],
 				'sourceType' => $order['sourceType'],
 				'amount' => $order['actPrice'],
 				'payWay' => $order['payWay']
 			]);
+			*/
 		}
 	}
 	

+ 2 - 2
common/services/xhPayToolService.php

@@ -154,9 +154,9 @@ class xhPayToolService
 			$mBalance = $mAsset['balance'];
 			$mExpend = $mAsset['totalExpend'];
 			$mIncome = stringUtil::calcAdd($mAsset['totalIncome'], $totalFee);
-			$mUseRecharge = stringUtil::calcAdd($mAsset['totalUseRecharge'], $totalFee);
+			$mUseRecharge = stringUtil::calcAdd($mAsset['usedRecharge'], $totalFee);
 			$mTotalDeal = $mAsset['totalDeal'] + 1;//总交易数+1
-			$mUpdateData = ['totalIncome' => $mIncome, 'totalUseRecharge' => $mUseRecharge, 'totalDeal' => $mTotalDeal];
+			$mUpdateData = ['totalIncome' => $mIncome, 'usedRecharge' => $mUseRecharge, 'totalDeal' => $mTotalDeal];
 			//支付方式要转到商家资产变更里去
 			$order['payWay'] = $payWay;
 			xhMerchantAssetService::incomeChangeAsset($merchant, $mAsset, $mUpdateData, $order, $capitalType);//商家资产改变